public Type GetType(IOpenApiObjectToTypeService objectService, IOpenApiUmbrellaTypeResolver typeResolver, IObjectsProcessingKeyStore objectKeyStore, OpenApiReferencedType referencedType, IDictionary <string, IOpenApiType> definitions) { var typeName = _lastTokenService.GetLastToken(referencedType.Type); if (!CurrentTypeHolder.Types.TryGetValue(typeName, out var existingType)) { if (!definitions.TryGetValue(typeName, out var definedNotCreated)) { throw new NotSupportedException($"Referenced type {typeName} is not defined in OpenApi document"); } //handle circular reference objectKeyStore.ThrowIfPresent(typeName); var createdType = typeResolver.GetType(objectService, objectKeyStore, definedNotCreated, definitions, typeName); CurrentTypeHolder.Types[typeName] = createdType; return(createdType); } return(existingType); }
public void CreateOrUpdateShortNames(IEnumerable <OpenApiEndpointModel> endpoints) { foreach (var endpoint in endpoints) { var firstTag = endpoint.Tags?.FirstOrDefault()?.Replace(" ", ""); if (!string.IsNullOrEmpty(endpoint.ShortName)) { endpoint.ShortName = $"{firstTag}{endpoint.ShortName}"; } else { var lastToken = Regex.Replace(_lastTokenService.GetLastToken(endpoint.Path), "({|})", "_"); endpoint.ShortName = $"{firstTag}" + $"{endpoint.Method}" + $"{lastToken}"; } } }