diff --git a/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Document.cs b/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Document.cs index 30680b15..43075931 100644 --- a/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Document.cs +++ b/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Document.cs @@ -37,6 +37,7 @@ public class Document : IDocument private NamingStrategy _strategy; private VisitorCollection _collection; private IHttpRequestDataObject _req; + private bool _useFullName; /// <summary> /// Initializes a new instance of the <see cref="Document"/> class. @@ -119,6 +120,14 @@ public IDocument AddNamingStrategy(NamingStrategy strategy) return this; } + /// <inheritdoc/> + public IDocument AddFullNameOption(bool useFullName = false) + { + this._useFullName = useFullName; + + return this; + } + /// <inheritdoc /> public IDocument AddVisitors(VisitorCollection collection) { @@ -179,9 +188,9 @@ public IDocument Build(Assembly assembly, OpenApiVersionType version = OpenApiVe } operation.Security = this._helper.GetOpenApiSecurityRequirement(method, this._strategy); - operation.Parameters = this._helper.GetOpenApiParameters(method, trigger, this._strategy, this._collection, version); - operation.RequestBody = this._helper.GetOpenApiRequestBody(method, this._strategy, this._collection, version); - operation.Responses = this._helper.GetOpenApiResponses(method, this._strategy, this._collection, version); + operation.Parameters = this._helper.GetOpenApiParameters(method, trigger, this._strategy, this._collection, version, this._useFullName); + operation.RequestBody = this._helper.GetOpenApiRequestBody(method, this._strategy, this._collection, version, this._useFullName); + operation.Responses = this._helper.GetOpenApiResponses(method, this._strategy, this._collection, version, this._useFullName); operations[verb] = operation; item.Operations = operations; @@ -190,7 +199,7 @@ public IDocument Build(Assembly assembly, OpenApiVersionType version = OpenApiVe } this.OpenApiDocument.Paths = paths; - this.OpenApiDocument.Components.Schemas = this._helper.GetOpenApiSchemas(methods, this._strategy, this._collection); + this.OpenApiDocument.Components.Schemas = this._helper.GetOpenApiSchemas(methods, this._strategy, this._collection, this._useFullName); this.OpenApiDocument.Components.SecuritySchemes = this._helper.GetOpenApiSecuritySchemes(methods, this._strategy); // this.OpenApiDocument.SecurityRequirements = this.OpenApiDocument // .Paths diff --git a/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Extensions/DocumentHelperExtensions.cs b/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Extensions/DocumentHelperExtensions.cs index 3cc2f9fc..459ee4c5 100644 --- a/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Extensions/DocumentHelperExtensions.cs +++ b/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Extensions/DocumentHelperExtensions.cs @@ -152,8 +152,9 @@ public static OpenApiOperation GetOpenApiOperation(this IDocumentHelper helper, /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance to create the JSON schema from .NET Types.</param> /// <param name="collection"><see cref="VisitorCollection"/> instance to process parameters.</param> /// <param name="version"><see cref="OpenApiVersionType"/> value.</param> + /// <param name="useFullName"> instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns>List of <see cref="OpenApiParameter"/> instance.</returns> - public static List<OpenApiParameter> GetOpenApiParameters(this IDocumentHelper helper, MethodInfo element, HttpTriggerAttribute trigger, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version) + public static List<OpenApiParameter> GetOpenApiParameters(this IDocumentHelper helper, MethodInfo element, HttpTriggerAttribute trigger, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version, bool useFullName = false) { var parameters = element.GetCustomAttributes<OpenApiParameterAttribute>(inherit: false) .Where(p => p.Deprecated == false) @@ -178,14 +179,14 @@ public static List<OpenApiParameter> GetOpenApiParameters(this IDocumentHelper h var contents = attributes.Where(p => p.Deprecated == false) .Where(p => p.ContentType == "application/x-www-form-urlencoded" || p.ContentType == "multipart/form-data") - .Select(p => p.ToOpenApiMediaType(namingStrategy, collection, version)); + .Select(p => p.ToOpenApiMediaType(namingStrategy, collection, version, useFullName)); if (!contents.Any()) { return parameters; } var @ref = contents.First().Schema.Reference; - var schemas = helper.GetOpenApiSchemas(new[] { element }.ToList(), namingStrategy, collection); + var schemas = helper.GetOpenApiSchemas(new[] { element }.ToList(), namingStrategy, collection, useFullName); var schema = schemas.SingleOrDefault(p => p.Key == @ref.Id); if (schema.IsNullOrDefault()) { diff --git a/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Functions/OpenApiTriggerFunction.cs b/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Functions/OpenApiTriggerFunction.cs index b18bcd95..94981ddb 100644 --- a/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Functions/OpenApiTriggerFunction.cs +++ b/src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Functions/OpenApiTriggerFunction.cs @@ -62,6 +62,7 @@ public async Task<HttpResponseData> RenderSwaggerDocument(HttpRequestData req, s .AddMetadata(this._context.OpenApiConfigurationOptions.Info) .AddServer(request, this._context.HttpSettings.RoutePrefix, this._context.OpenApiConfigurationOptions) .AddNamingStrategy(this._context.NamingStrategy) + .AddFullNameOption(this._context.OpenApiConfigurationOptions.UseFullName) .AddVisitors(this._context.GetVisitorCollection()) .Build(this._context.ApplicationAssembly, this._context.OpenApiConfigurationOptions.OpenApiVersion) .ApplyDocumentFilters(this._context.GetDocumentFilterCollection()) diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IDocument.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IDocument.cs index b5530cf6..b8ae76aa 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IDocument.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IDocument.cs @@ -57,6 +57,13 @@ public interface IDocument /// <returns><see cref="IDocument"/> instance.</returns> IDocument AddVisitors(VisitorCollection collection); + /// <summary> + /// Add the useFullName options + /// </summary> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> + /// <returns>instance</returns> + IDocument AddFullNameOption(bool useFullName = false); + /// <summary> /// Builds OpenAPI document. /// </summary> diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IDocumentHelper.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IDocumentHelper.cs index 4aa7c00b..b10f385d 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IDocumentHelper.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IDocumentHelper.cs @@ -38,17 +38,19 @@ public interface IDocumentHelper /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance to create the JSON schema from .NET Types.</param> /// <param name="collection"><see cref="VisitorCollection"/> instance to process parameters.</param> /// <param name="version">OpenAPI spec version.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns><see cref="OpenApiRequestBody"/> instance.</returns> - OpenApiRequestBody GetOpenApiRequestBody(MethodInfo element, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version = OpenApiVersionType.V2); + OpenApiRequestBody GetOpenApiRequestBody(MethodInfo element, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version = OpenApiVersionType.V2 , bool useFullName = false); /// <summary> /// Gets the <see cref="OpenApiResponses"/> instance. /// </summary> /// <param name="element"><see cref="MethodInfo"/> instance.</param> /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance to create the JSON schema from .NET Types.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns><see cref="OpenApiResponses"/> instance.</returns> [Obsolete("This method is obsolete from 2.0.0. Use GetOpenApiResponses instead", error: true)] - OpenApiResponses GetOpenApiResponseBody(MethodInfo element, NamingStrategy namingStrategy = null); + OpenApiResponses GetOpenApiResponseBody(MethodInfo element, NamingStrategy namingStrategy = null, bool useFullName = default); /// <summary> /// Gets the <see cref="OpenApiResponses"/> instance. @@ -57,8 +59,9 @@ public interface IDocumentHelper /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance to create the JSON schema from .NET Types.</param> /// <param name="collection"><see cref="VisitorCollection"/> instance to process parameters.</param> /// <param name="version">OpenAPI spec version.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns><see cref="OpenApiResponses"/> instance.</returns> - OpenApiResponses GetOpenApiResponses(MethodInfo element, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version = OpenApiVersionType.V2); + OpenApiResponses GetOpenApiResponses(MethodInfo element, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version = OpenApiVersionType.V2, bool useFullName = false); /// <summary> /// Gets the collection of <see cref="OpenApiSchema"/> instances. @@ -66,8 +69,9 @@ public interface IDocumentHelper /// <param name="elements">List of <see cref="MethodInfo"/> instance.</param> /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance to create the JSON schema from .NET Types.</param> /// <param name="collection"><see cref="VisitorCollection"/> instance to add types to schema.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// /// <returns>Collection of <see cref="OpenApiSchema"/> instance.</returns> - Dictionary<string, OpenApiSchema> GetOpenApiSchemas(List<MethodInfo> elements, NamingStrategy namingStrategy, VisitorCollection collection); + Dictionary<string, OpenApiSchema> GetOpenApiSchemas(List<MethodInfo> elements, NamingStrategy namingStrategy, VisitorCollection collection, bool useFullName = false); /// <summary> /// Gets the collection of <see cref="OpenApiSecurityScheme"/> instances. diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IOpenApiConfigurationOptions.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IOpenApiConfigurationOptions.cs index ba35c17d..91c9a33f 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IOpenApiConfigurationOptions.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Abstractions/IOpenApiConfigurationOptions.cs @@ -39,6 +39,11 @@ public interface IOpenApiConfigurationOptions /// Gets or sets the value indicating whether to force the HTTPS protocol or not. /// </summary> bool ForceHttps { get; set; } + + /// <summary> + /// Gets or sets the value indicating whether to use the FullName or not. + /// </summary> + bool UseFullName { get; set; } /// <summary> /// Gets or sets the list of <see cref="IDocumentFilter"/> instances. diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/DefaultOpenApiConfigurationOptions.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/DefaultOpenApiConfigurationOptions.cs index cfc84566..913ba3b4 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/DefaultOpenApiConfigurationOptions.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/DefaultOpenApiConfigurationOptions.cs @@ -25,6 +25,7 @@ public class DefaultOpenApiConfigurationOptions : OpenApiConfigurationOptions private const string ExcludeRequestingHostKey = "OpenApi__ExcludeRequestingHost"; private const string ForceHttpKey = "OpenApi__ForceHttp"; private const string ForceHttpsKey = "OpenApi__ForceHttps"; + private const string FullnameKey = "OpenApi__UseFullNamespace"; /// <inheritdoc /> public override OpenApiInfo Info { get; set; } = new OpenApiInfo() @@ -49,6 +50,9 @@ public class DefaultOpenApiConfigurationOptions : OpenApiConfigurationOptions /// <inheritdoc /> public override bool ForceHttps { get; set; } = IsHttpsForced(); + /// <inheritdoc /> + public override bool UseFullName {get; set; } = UseFullNamespace(); + /// <inheritdoc /> public override List<IDocumentFilter> DocumentFilters { get; set; } = new List<IDocumentFilter>(); @@ -187,6 +191,15 @@ private static bool IsFunctionsRuntimeEnvironmentDevelopment() { var development = Environment.GetEnvironmentVariable(FunctionsRuntimeEnvironmentKey) == "Development"; + return development; + } + /// <summary> + /// check whether to use FullName or not + /// </summary> + /// <returns>Return <c>true</c>if user use Fullname; otherwise return<c>false</c> </returns> + public static bool UseFullNamespace(){ + var development = bool.TryParse(Environment.GetEnvironmentVariable(FullnameKey), out var result) ? result : false; + return development; } } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/OpenApiConfigurationOptions.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/OpenApiConfigurationOptions.cs index 92a74f71..8564dac9 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/OpenApiConfigurationOptions.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/OpenApiConfigurationOptions.cs @@ -34,6 +34,8 @@ public class OpenApiConfigurationOptions : IOpenApiConfigurationOptions /// <inheritdoc /> public virtual List<IDocumentFilter> DocumentFilters { get; set; } = new List<IDocumentFilter>(); + /// <inheritdoc /> + public virtual bool UseFullName {get; set;} /// <inheritdoc /> public virtual IOpenApiHttpTriggerAuthorization Security { get; set; } = new OpenApiHttpTriggerAuthorization(); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/OpenApiSettings.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/OpenApiSettings.cs index 90cb145c..33b79f6a 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/OpenApiSettings.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Configurations/OpenApiSettings.cs @@ -52,6 +52,11 @@ public class OpenApiSettings /// </summary> public virtual bool ForceHttp { get; set; } + /// <summary> + /// Gets or sets the value indicating whether to use the FullName or not. + /// </summary> + public bool UseFullName { get; set; } + /// <summary> /// Gets or sets the value indicating whether to hide the Swagger UI page or not. /// </summary> diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/DocumentHelper.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/DocumentHelper.cs index 70fb2f7a..cdfcc362 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/DocumentHelper.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/DocumentHelper.cs @@ -79,7 +79,7 @@ public List<OpenApiSecurityRequirement> GetOpenApiSecurityRequirement(MethodInfo } /// <inheritdoc /> - public OpenApiRequestBody GetOpenApiRequestBody(MethodInfo element, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version = OpenApiVersionType.V2) + public OpenApiRequestBody GetOpenApiRequestBody(MethodInfo element, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version = OpenApiVersionType.V2, bool useFullName = false) { var attributes = element.GetCustomAttributes<OpenApiRequestBodyAttribute>(inherit: false); if (!attributes.Any()) @@ -88,7 +88,7 @@ public OpenApiRequestBody GetOpenApiRequestBody(MethodInfo element, NamingStrate } var contents = attributes.Where(p => p.Deprecated == false) - .ToDictionary(p => p.ContentType, p => p.ToOpenApiMediaType(namingStrategy, collection, version)); + .ToDictionary(p => p.ContentType, p => p.ToOpenApiMediaType(namingStrategy, collection, version, useFullName)); if (contents.Any()) { @@ -105,17 +105,17 @@ public OpenApiRequestBody GetOpenApiRequestBody(MethodInfo element, NamingStrate /// <inheritdoc /> [Obsolete("This method is obsolete from 2.0.0. Use GetOpenApiResponses instead", error: true)] - public OpenApiResponses GetOpenApiResponseBody(MethodInfo element, NamingStrategy namingStrategy = null) + public OpenApiResponses GetOpenApiResponseBody(MethodInfo element, NamingStrategy namingStrategy = null, bool useFullname = false) { - return this.GetOpenApiResponses(element, namingStrategy, null); + return this.GetOpenApiResponses(element, namingStrategy, null, useFullname:useFullname); } /// <inheritdoc /> - public OpenApiResponses GetOpenApiResponses(MethodInfo element, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version = OpenApiVersionType.V2) + public OpenApiResponses GetOpenApiResponses(MethodInfo element, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version = OpenApiVersionType.V2, bool useFullname = false) { var responsesWithBody = element.GetCustomAttributes<OpenApiResponseWithBodyAttribute>(inherit: false) .Where(p => p.Deprecated == false) - .Select(p => new { StatusCode = p.StatusCode, Response = p.ToOpenApiResponse(namingStrategy, version: version) }); + .Select(p => new { StatusCode = p.StatusCode, Response = p.ToOpenApiResponse(namingStrategy, version: version, useFullName: useFullname) }); var responsesWithoutBody = element.GetCustomAttributes<OpenApiResponseWithoutBodyAttribute>(inherit: false) .Select(p => new { StatusCode = p.StatusCode, Response = p.ToOpenApiResponse(namingStrategy) }); @@ -128,7 +128,7 @@ public OpenApiResponses GetOpenApiResponses(MethodInfo element, NamingStrategy n } /// <inheritdoc /> - public Dictionary<string, OpenApiSchema> GetOpenApiSchemas(List<MethodInfo> elements, NamingStrategy namingStrategy, VisitorCollection collection) + public Dictionary<string, OpenApiSchema> GetOpenApiSchemas(List<MethodInfo> elements, NamingStrategy namingStrategy, VisitorCollection collection, bool useFullName = false) { var requests = elements.SelectMany(p => p.GetCustomAttributes<OpenApiRequestBodyAttribute>(inherit: false)) .Select(p => p.BodyType); @@ -148,7 +148,7 @@ public Dictionary<string, OpenApiSchema> GetOpenApiSchemas(List<MethodInfo> elem var acceptorTypes = new Dictionary<string, Type>(); foreach (var type in types) { - var openApiReferenceId = type.GetOpenApiReferenceId(type.IsOpenApiDictionary(), type.IsOpenApiArray(), namingStrategy); + var openApiReferenceId = type.GetOpenApiReferenceId(type.IsOpenApiDictionary(), type.IsOpenApiArray(), namingStrategy, useFullName); if (!acceptorTypes.ContainsKey(openApiReferenceId)) { acceptorTypes.Add(openApiReferenceId, type); @@ -159,7 +159,7 @@ public Dictionary<string, OpenApiSchema> GetOpenApiSchemas(List<MethodInfo> elem this._acceptor.RootSchemas = rootSchemas; this._acceptor.Schemas = schemas; - this._acceptor.Accept(collection, namingStrategy); + this._acceptor.Accept(collection, namingStrategy, useFullName); var union = schemas.Concat(rootSchemas.Where(p => !schemas.Keys.Contains(p.Key))) .Distinct() diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/DocumentHelperExtensions.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/DocumentHelperExtensions.cs index 332c773a..38745d30 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/DocumentHelperExtensions.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/DocumentHelperExtensions.cs @@ -147,8 +147,9 @@ public static OpenApiOperation GetOpenApiOperation(this IDocumentHelper helper, /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance to create the JSON schema from .NET Types.</param> /// <param name="collection"><see cref="VisitorCollection"/> instance to process parameters.</param> /// <param name="version"><see cref="OpenApiVersionType"/> value.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns>List of <see cref="OpenApiParameter"/> instance.</returns> - public static List<OpenApiParameter> GetOpenApiParameters(this IDocumentHelper helper, MethodInfo element, HttpTriggerAttribute trigger, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version) + public static List<OpenApiParameter> GetOpenApiParameters(this IDocumentHelper helper, MethodInfo element, HttpTriggerAttribute trigger, NamingStrategy namingStrategy, VisitorCollection collection, OpenApiVersionType version, bool useFullName = false) { var parameters = element.GetCustomAttributes<OpenApiParameterAttribute>(inherit: false) .Where(p => p.Deprecated == false) @@ -173,14 +174,14 @@ public static List<OpenApiParameter> GetOpenApiParameters(this IDocumentHelper h var contents = attributes.Where(p => p.Deprecated == false) .Where(p => p.ContentType == "application/x-www-form-urlencoded" || p.ContentType == "multipart/form-data") - .Select(p => p.ToOpenApiMediaType(namingStrategy, collection, version)); + .Select(p => p.ToOpenApiMediaType(namingStrategy, collection, version, useFullName)); if (!contents.Any()) { return parameters; } var @ref = contents.First().Schema.Reference; - var schemas = helper.GetOpenApiSchemas(new[] { element }.ToList(), namingStrategy, collection); + var schemas = helper.GetOpenApiSchemas(new[] { element }.ToList(), namingStrategy, collection, useFullName); var schema = schemas.SingleOrDefault(p => p.Key == @ref.Id); if (schema.IsNullOrDefault()) { diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/OpenApiPayloadAttributeExtensions.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/OpenApiPayloadAttributeExtensions.cs index 0ae2e9e5..da0270de 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/OpenApiPayloadAttributeExtensions.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/OpenApiPayloadAttributeExtensions.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; - using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -24,8 +23,9 @@ public static class OpenApiPayloadAttributeExtensions /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance to create the JSON schema from .NET Types.</param> /// <param name="collection"><see cref="VisitorCollection"/> instance.</param> /// <param name="version">OpenAPI spec version.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns><see cref="OpenApiMediaType"/> instance.</returns> - public static OpenApiMediaType ToOpenApiMediaType<T>(this T attribute, NamingStrategy namingStrategy = null, VisitorCollection collection = null, OpenApiVersionType version = OpenApiVersionType.V2) where T : OpenApiPayloadAttribute + public static OpenApiMediaType ToOpenApiMediaType<T>(this T attribute, NamingStrategy namingStrategy = null, VisitorCollection collection = null, OpenApiVersionType version = OpenApiVersionType.V2, bool useFullName = false) where T : OpenApiPayloadAttribute { attribute.ThrowIfNullOrDefault(); @@ -42,7 +42,7 @@ public static OpenApiMediaType ToOpenApiMediaType<T>(this T attribute, NamingStr var type = attribute.BodyType; // Generate schema based on the type. - var schema = collection.PayloadVisit(type, namingStrategy); + var schema = collection.PayloadVisit(type, namingStrategy, useFullName); // Add deprecated attribute. if (attribute is OpenApiRequestBodyAttribute) @@ -60,7 +60,7 @@ public static OpenApiMediaType ToOpenApiMediaType<T>(this T attribute, NamingStr var reference = new OpenApiReference() { Type = ReferenceType.Schema, - Id = attribute.BodyType.GetOpenApiReferenceId(isDictionary: false, isList: false, namingStrategy) + Id = attribute.BodyType.GetOpenApiReferenceId(isDictionary: false, isList: false, namingStrategy, useFullName) }; schema.Reference = reference; diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/OpenApiResponseWithBodyAttributeExtensions.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/OpenApiResponseWithBodyAttributeExtensions.cs index 94179ca3..94069e33 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/OpenApiResponseWithBodyAttributeExtensions.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/OpenApiResponseWithBodyAttributeExtensions.cs @@ -24,15 +24,16 @@ public static class OpenApiResponseWithBodyAttributeExtensions /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance to create the JSON schema from .NET Types.</param> /// <param name="collection"><see cref="VisitorCollection"/> instance.</param> /// <param name="version">OpenAPI spec version.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns><see cref="OpenApiResponse"/> instance.</returns> - public static OpenApiResponse ToOpenApiResponse(this OpenApiResponseWithBodyAttribute attribute, NamingStrategy namingStrategy = null, VisitorCollection collection = null, OpenApiVersionType version = OpenApiVersionType.V2) + public static OpenApiResponse ToOpenApiResponse(this OpenApiResponseWithBodyAttribute attribute, NamingStrategy namingStrategy = null, VisitorCollection collection = null, OpenApiVersionType version = OpenApiVersionType.V2, bool useFullName = false) { attribute.ThrowIfNullOrDefault(); var description = string.IsNullOrWhiteSpace(attribute.Description) - ? $"Payload of {attribute.BodyType.GetOpenApiDescription()}" + ? $"Payload of {attribute.BodyType.GetOpenApiDescription(useFullName)}" : attribute.Description; - var mediaType = attribute.ToOpenApiMediaType<OpenApiResponseWithBodyAttribute>(namingStrategy, collection, version); + var mediaType = attribute.ToOpenApiMediaType<OpenApiResponseWithBodyAttribute>(namingStrategy, collection, version, useFullName); var content = new Dictionary<string, OpenApiMediaType>() { { attribute.ContentType, mediaType } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/TypeExtensions.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/TypeExtensions.cs index cf2a7b6f..95875b50 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/TypeExtensions.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/TypeExtensions.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; - using Microsoft.OpenApi.Any; using Newtonsoft.Json; @@ -392,8 +391,9 @@ public static bool HasJsonConverterAttribute<T>(this Type type) where T : JsonCo /// <param name="isDictionary">Value indicating whether the type is <see cref="Dictionary{TKey, TValue}"/> or not.</param> /// <param name="isList">Value indicating whether the type is <see cref="List{T}"/> or not.</param> /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns>Returns the OpenAPI reference ID.</returns> - public static string GetOpenApiReferenceId(this Type type, bool isDictionary, bool isList, NamingStrategy namingStrategy = null) + public static string GetOpenApiReferenceId(this Type type, bool isDictionary, bool isList, NamingStrategy namingStrategy = null, bool useFullName = false) { if (namingStrategy.IsNullOrDefault()) { @@ -402,37 +402,38 @@ public static string GetOpenApiReferenceId(this Type type, bool isDictionary, bo if (isDictionary) { - var name = type.Name.EndsWith("[]") ? "Dictionary_" + type.GetOpenApiSubTypeName(namingStrategy) : type.Name.Split('`').First() + "_" + type.GetOpenApiSubTypeName(namingStrategy); + var name = GetTypeName(type, useFullName).EndsWith("[]") ? "Dictionary_" + type.GetOpenApiSubTypeName(namingStrategy) : GetTypeName(type, useFullName).Split('`').First() + "_" + type.GetOpenApiSubTypeName(namingStrategy); return namingStrategy.GetPropertyName(name, hasSpecifiedName: false); } if (isList) { - var name = type.Name.EndsWith("[]") ? "List_" + type.GetOpenApiSubTypeName(namingStrategy) : type.Name.Split('`').First() + "_" + type.GetOpenApiSubTypeName(namingStrategy); + var name = GetTypeName(type, useFullName).EndsWith("[]") ? "List_" + type.GetOpenApiSubTypeName(namingStrategy) : GetTypeName(type, useFullName).Split('`').First() + "_" + type.GetOpenApiSubTypeName(namingStrategy); return namingStrategy.GetPropertyName(name, hasSpecifiedName: false); } if (type.IsGenericType) { - return namingStrategy.GetPropertyName(type.Name.Split('`').First(), false) + "_" + - string.Join("_", type.GenericTypeArguments.Select(a => namingStrategy.GetPropertyName(a.Name, false))); + return namingStrategy.GetPropertyName(GetTypeName(type, useFullName).Split('`').First(), false) + "_" + + string.Join("_", type.GenericTypeArguments.Select(a => namingStrategy.GetPropertyName(a.GetTypeName(useFullName), false))); } - return namingStrategy.GetPropertyName(type.Name, hasSpecifiedName: false); + return namingStrategy.GetPropertyName(GetTypeName(type, useFullName), hasSpecifiedName: false); } /// <summary> /// Gets the OpenAPI root reference ID. /// </summary> /// <param name="type"><see cref="Type"/> instance.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns>Returns the OpenAPI root reference ID.</returns> - public static string GetOpenApiRootReferenceId(this Type type) + public static string GetOpenApiRootReferenceId(this Type type, bool useFullName = false) { if (!type.IsGenericType) { - return type.Name; + return GetTypeName(type, useFullName); } - return type.GetOpenApiGenericRootName(); + return type.GetOpenApiGenericRootName(useFullName); } /// <summary> @@ -460,7 +461,7 @@ public static Type GetUnderlyingType(this Type type) } if (type.IsOpenApiArray()) - { + { underlyingType = type.GetElementType() ?? type.GetGenericArguments()[0]; } @@ -481,8 +482,9 @@ public static Type GetUnderlyingType(this Type type) /// Gets the OpenAPI description from the given <see cref="Type"/>. /// </summary> /// <param name="type"><see cref="Type"/> instance.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns>Returns the OpenAPI description from the given <see cref="Type"/>.</returns> - public static string GetOpenApiDescription(this Type type) + public static string GetOpenApiDescription(this Type type,bool useFullName = false) { if (type.IsOpenApiDictionary()) { @@ -495,26 +497,27 @@ public static string GetOpenApiDescription(this Type type) } if (type.IsGenericType) - { - return $"{type.GetOpenApiGenericRootName()} containing {type.GetOpenApiSubTypeNames()}"; + { + return $"{type.GetOpenApiGenericRootName(useFullName)} containing {type.GetOpenApiSubTypeNames(useFullName)}"; } - return type.Name; + return GetTypeName(type,useFullName); } /// <summary> /// Gets the root name of the given generic type. /// </summary> /// <param name="type"><see cref="Type"/> instance.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns>Returns the root name of the given generic type.</returns> - public static string GetOpenApiGenericRootName(this Type type) + public static string GetOpenApiGenericRootName(this Type type,bool useFullName = false) { if (!type.IsGenericType) { - return type.Name; + return GetTypeName(type,useFullName); } - var name = type.Name.Split(new[] { "`" }, StringSplitOptions.RemoveEmptyEntries).First(); + var name = GetTypeName(type,useFullName).Split(new[] { "`" }, StringSplitOptions.RemoveEmptyEntries).First(); return name; } @@ -524,15 +527,16 @@ public static string GetOpenApiGenericRootName(this Type type) /// </summary> /// <param name="type">Type to check.</param> /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns>Returns the type name applied by <see cref="NamingStrategy"/>.</returns> - public static string GetOpenApiTypeName(this Type type, NamingStrategy namingStrategy = null) + public static string GetOpenApiTypeName(this Type type, NamingStrategy namingStrategy = null, bool useFullName = false) { if (namingStrategy.IsNullOrDefault()) { namingStrategy = new DefaultNamingStrategy(); } - var typeName = type.IsGenericType ? type.GetOpenApiGenericRootName() : type.Name; + var typeName = type.IsGenericType ? type.GetOpenApiGenericRootName(useFullName) : GetTypeName(type,useFullName); var name = namingStrategy.GetPropertyName(typeName, hasSpecifiedName: false); return name; @@ -604,8 +608,9 @@ public static string GetOpenApiSubTypeName(this Type type, NamingStrategy naming /// Gets the list of names of the sub type of the given <see cref="Type"/>. /// </summary> /// <param name="type"><see cref="Type"/> instance.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns>Returns the list of names of the sub type of the given <see cref="Type"/>.</returns> - public static string GetOpenApiSubTypeNames(this Type type) + public static string GetOpenApiSubTypeNames(this Type type, bool useFullName = false) { if (!type.IsGenericType) { @@ -615,15 +620,15 @@ public static string GetOpenApiSubTypeNames(this Type type) var types = type.GetGenericArguments().ToList(); if (types.Count == 1) { - return types[0].GetOpenApiGenericRootName(); + return types[0].GetOpenApiGenericRootName(useFullName); } var names = (string)null; for (var i = 0; i < types.Count - 1; i++) { - names += $"{types[i].GetOpenApiGenericRootName()}, "; + names += $"{types[i].GetOpenApiGenericRootName(useFullName)}, "; } - names += $"and {types[types.Count - 1].GetOpenApiGenericRootName()}"; + names += $"and {types[types.Count - 1].GetOpenApiGenericRootName(useFullName)}"; return names; } @@ -720,8 +725,22 @@ public static bool HasCustomAttribute(this Type type, Type attributeType) } return true; + } + + /// <summary> + /// Checks whether t + /// </summary> + /// <param name="type"></param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> + /// <returns></returns> + public static string GetTypeName(this Type type ,bool useFullName = false){ + + var name = useFullName ? type.FullName : type.Name; + + return name; } + private static bool IsArrayType(this Type type) { var isArrayType = type.Name.Equals("String", StringComparison.InvariantCultureIgnoreCase) == false && @@ -743,10 +762,11 @@ private static bool IsArrayType(this Type type) "KeyValuePair`2", }; - private static bool IsDictionaryType(this Type type) + private static bool IsDictionaryType(this Type type, bool useFullName = false) { + var isDictionaryType = type.IsGenericType && - dictionaries.Any(p => type.Name.Equals(p, StringComparison.InvariantCultureIgnoreCase) == true); + dictionaries.Any(p => GetTypeName(type, useFullName).Equals(p, StringComparison.InvariantCultureIgnoreCase) == true); return isDictionaryType; } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/BaseObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/BaseObjectTypeVisitor.cs index e8dadd22..d1c736af 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/BaseObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/BaseObjectTypeVisitor.cs @@ -3,6 +3,7 @@ using System.Linq; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.OpenApi.Models; using Newtonsoft.Json.Serialization; @@ -29,13 +30,13 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var title = type.Value.IsGenericType - ? namingStrategy.GetPropertyName(type.Value.Name.Split('`').First(), hasSpecifiedName: false) + "_" + + ? namingStrategy.GetPropertyName(type.Value.GetTypeName(useFullName).Split('`').First(), hasSpecifiedName: false) + "_" + string.Join("_", - type.Value.GenericTypeArguments.Select(a => namingStrategy.GetPropertyName(a.Name, false))) - : namingStrategy.GetPropertyName(type.Value.Name, hasSpecifiedName: false); + type.Value.GenericTypeArguments.Select(a => namingStrategy.GetPropertyName(a.GetTypeName(useFullName), false))) + : namingStrategy.GetPropertyName(type.Value.GetTypeName(useFullName), hasSpecifiedName: false); this.Visit(acceptor, name: type.Key, title: title, dataType: "object", dataFormat: null, attributes: attributes); } @@ -48,7 +49,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "object", dataFormat: null); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/BooleanTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/BooleanTypeVisitor.cs index a1e966e1..5befe991 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/BooleanTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/BooleanTypeVisitor.cs @@ -28,7 +28,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "boolean", dataFormat: null, attributes: attributes); } @@ -56,7 +56,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "boolean", dataFormat: null); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ByteArrayTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ByteArrayTypeVisitor.cs index fa390004..0f28ad01 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ByteArrayTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ByteArrayTypeVisitor.cs @@ -28,7 +28,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "string", dataFormat: "binary", attributes: attributes); } @@ -56,7 +56,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "string", dataFormat: "binary"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ByteEnumTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ByteEnumTypeVisitor.cs index 59c916e5..124127f1 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ByteEnumTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ByteEnumTypeVisitor.cs @@ -38,7 +38,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var name = type.Key; @@ -113,7 +113,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { var schema = this.PayloadVisit(dataType: "integer", dataFormat: "int32"); diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeObjectTypeVisitor.cs index 6078df0e..eab1b308 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeObjectTypeVisitor.cs @@ -28,7 +28,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "string", dataFormat: "date-time", attributes: attributes); } @@ -56,7 +56,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "string", dataFormat: "date-time"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeOffsetObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeOffsetObjectTypeVisitor.cs index 88653c52..5bf556bb 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeOffsetObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeOffsetObjectTypeVisitor.cs @@ -28,7 +28,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "string", dataFormat: "date-time", attributes: attributes); } @@ -56,7 +56,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "string", dataFormat: "date-time"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeTypeVisitor.cs index 288aab5f..b9b17d5d 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DateTimeTypeVisitor.cs @@ -28,7 +28,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "string", dataFormat: "date-time", attributes: attributes); } @@ -56,7 +56,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "string", dataFormat: "date-time"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DecimalTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DecimalTypeVisitor.cs index 8394edf2..13e3368a 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DecimalTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DecimalTypeVisitor.cs @@ -28,7 +28,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "number", dataFormat: "double", attributes: attributes); } @@ -56,7 +56,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "number", dataFormat: "double"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DictionaryObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DictionaryObjectTypeVisitor.cs index b2c88898..d51f0290 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DictionaryObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DictionaryObjectTypeVisitor.cs @@ -32,9 +32,9 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes ) { - var name = this.Visit(acceptor, name: type.Key, title: null, dataType: "object", dataFormat: null, attributes: attributes); + var name = this.Visit(acceptor, name: type.Key, title: null, dataType: "object", dataFormat: null,attributes: attributes); if (name.IsNullOrWhiteSpace()) { @@ -51,7 +51,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, var underlyingType = type.Value.GetUnderlyingType(); var types = new Dictionary<string, Type>() { - { underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy), underlyingType } + { underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy, useFullName), underlyingType } }; var schemas = new Dictionary<string, OpenApiSchema>(); @@ -63,7 +63,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, Types = types, RootSchemas = instance.RootSchemas, Schemas = schemas, }; this.visitedTypes.Add(underlyingType, subAcceptor); - subAcceptor.Accept(this.VisitorCollection, namingStrategy); + subAcceptor.Accept(this.VisitorCollection, namingStrategy,useFullName); } else { @@ -81,7 +81,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, var reference = new OpenApiReference() { Type = ReferenceType.Schema, - Id = underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy) + Id = underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy, useFullName) }; properties.Reference = reference; @@ -128,13 +128,13 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { var schema = this.PayloadVisit(dataType: "object", dataFormat: null); // Gets the schema for the underlying type. var underlyingType = type.GetUnderlyingType(); - var properties = this.VisitorCollection.PayloadVisit(underlyingType, namingStrategy); + var properties = this.VisitorCollection.PayloadVisit(underlyingType, namingStrategy, useFullName); // Adds the reference to the schema for the underlying type. if (underlyingType.IsReferentialType()) @@ -142,7 +142,7 @@ public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrat var reference = new OpenApiReference() { Type = ReferenceType.Schema, - Id = underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy) + Id = underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy, useFullName) }; properties.Reference = reference; diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DoubleTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DoubleTypeVisitor.cs index 82837755..c6b11d58 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DoubleTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/DoubleTypeVisitor.cs @@ -28,7 +28,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "number", dataFormat: "double", attributes: attributes); } @@ -56,7 +56,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "number", dataFormat: "double"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ExceptionTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ExceptionTypeVisitor.cs index 8f256e15..c416f514 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ExceptionTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ExceptionTypeVisitor.cs @@ -29,7 +29,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var title = namingStrategy.GetPropertyName(type.Value.Name, hasSpecifiedName: false); this.Visit(acceptor, name: type.Key, title: title, dataType: "object", dataFormat: null, attributes: attributes); @@ -44,7 +44,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "object", dataFormat: null); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/GuidObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/GuidObjectTypeVisitor.cs index ae9e3e97..de28c7a1 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/GuidObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/GuidObjectTypeVisitor.cs @@ -28,7 +28,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "string", dataFormat: "uuid", attributes: attributes); } @@ -56,7 +56,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "string", dataFormat: "uuid"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/IAcceptor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/IAcceptor.cs index 98d3b367..87126fc3 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/IAcceptor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/IAcceptor.cs @@ -14,6 +14,7 @@ public interface IAcceptor /// </summary> /// <param name="collection"><see cref="VisitorCollection"/> instance.</param> /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance.</param> - void Accept(VisitorCollection collection, NamingStrategy namingStrategy); + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> + void Accept(VisitorCollection collection, NamingStrategy namingStrategy, bool useFullName); } } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/IVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/IVisitor.cs index d72c7721..4b06c724 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/IVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/IVisitor.cs @@ -25,8 +25,9 @@ public interface IVisitor /// <param name="acceptor"><see cref="IAcceptor"/> instance.</param> /// <param name="type">Type to check.</param> /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <param name="attributes">List of attribute instances.</param> - void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes); + void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName, params Attribute[] attributes); /// <summary> /// Checks whether the type is navigatable to its sub-type or not. @@ -61,6 +62,7 @@ public interface IVisitor /// </summary> /// <param name="type">Type to check.</param> /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance.</param> - OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy); + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> + OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName); } } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int16EnumTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int16EnumTypeVisitor.cs index 218d1ed5..c7a8d563 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int16EnumTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int16EnumTypeVisitor.cs @@ -37,7 +37,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var name = type.Key; @@ -113,7 +113,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { var schema = this.PayloadVisit(dataType: "integer", dataFormat: "int32"); diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int16TypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int16TypeVisitor.cs index 02f77e44..8987e300 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int16TypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int16TypeVisitor.cs @@ -30,7 +30,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "integer", dataFormat: "int32", attributes: attributes); } @@ -58,7 +58,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "integer", dataFormat: "int32"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int32EnumTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int32EnumTypeVisitor.cs index 0c5913ea..89021263 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int32EnumTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int32EnumTypeVisitor.cs @@ -37,7 +37,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var name = type.Key; @@ -113,7 +113,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { var schema = this.PayloadVisit(dataType: "integer", dataFormat: "int32"); diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int32TypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int32TypeVisitor.cs index acd64924..7026eff2 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int32TypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int32TypeVisitor.cs @@ -30,7 +30,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "integer", dataFormat: "int32", attributes: attributes); } @@ -58,7 +58,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "integer", dataFormat: "int32"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int64EnumTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int64EnumTypeVisitor.cs index 0065be52..49a1f617 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int64EnumTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int64EnumTypeVisitor.cs @@ -37,7 +37,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var name = type.Key; @@ -113,7 +113,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { var schema = this.PayloadVisit(dataType: "integer", dataFormat: "int64"); diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int64TypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int64TypeVisitor.cs index 19b3b1dd..f717194e 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int64TypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/Int64TypeVisitor.cs @@ -30,7 +30,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "integer", dataFormat: "int64", attributes: attributes); } @@ -58,7 +58,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "integer", dataFormat: "int64"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/JObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/JObjectTypeVisitor.cs index bc51f8e3..337112d2 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/JObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/JObjectTypeVisitor.cs @@ -30,7 +30,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var title = namingStrategy.GetPropertyName(type.Value.Name, hasSpecifiedName: false); this.Visit(acceptor, name: type.Key, title: title, dataType: "object", dataFormat: null, attributes: attributes); @@ -51,7 +51,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "object", dataFormat: null); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ListObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ListObjectTypeVisitor.cs index 7d8abbf0..97ea509d 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ListObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ListObjectTypeVisitor.cs @@ -32,7 +32,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var name = this.Visit(acceptor, name: type.Key, title: null, dataType: "array", dataFormat: null, attributes: attributes); @@ -51,7 +51,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, var underlyingType = type.Value.GetUnderlyingType(); var types = new Dictionary<string, Type>() { - { underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy), underlyingType } + { underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy, useFullName), underlyingType } }; var schemas = new Dictionary<string, OpenApiSchema>(); @@ -63,7 +63,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, Types = types, RootSchemas = instance.RootSchemas, Schemas = schemas, }; this.visitedTypes.Add(underlyingType, subAcceptor); - subAcceptor.Accept(this.VisitorCollection, namingStrategy); + subAcceptor.Accept(this.VisitorCollection, namingStrategy,useFullName); } else @@ -82,7 +82,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, var reference = new OpenApiReference() { Type = ReferenceType.Schema, - Id = underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy) + Id = underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy, useFullName) }; items.Reference = reference; @@ -144,13 +144,13 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { var schema = this.PayloadVisit(dataType: "array", dataFormat: null); // Gets the schema for the underlying type. var underlyingType = type.GetUnderlyingType(); - var items = this.VisitorCollection.PayloadVisit(underlyingType, namingStrategy); + var items = this.VisitorCollection.PayloadVisit(underlyingType, namingStrategy, useFullName); // Adds the reference to the schema for the underlying type. if (underlyingType.IsReferentialType()) @@ -158,7 +158,7 @@ public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrat var reference = new OpenApiReference() { Type = ReferenceType.Schema, - Id = underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy) + Id = underlyingType.GetOpenApiReferenceId(underlyingType.IsOpenApiDictionary(), underlyingType.IsOpenApiArray(), namingStrategy, useFullName) }; items.Reference = reference; diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/NullableObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/NullableObjectTypeVisitor.cs index ebf0b723..f7b9a023 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/NullableObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/NullableObjectTypeVisitor.cs @@ -33,7 +33,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var instance = acceptor as OpenApiSchemaAcceptor; if (instance.IsNullOrDefault()) @@ -55,7 +55,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, Schemas = schemas, }; - subAcceptor.Accept(this.VisitorCollection, namingStrategy); + subAcceptor.Accept(this.VisitorCollection, namingStrategy,useFullName); // Adds the schema for the underlying type. var name = subAcceptor.Schemas.First().Key; @@ -114,10 +114,10 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { var underlyingType = type.GetUnderlyingType(); - var schema = this.VisitorCollection.PayloadVisit(underlyingType, namingStrategy); + var schema = this.VisitorCollection.PayloadVisit(underlyingType, namingStrategy,useFullName); schema.Nullable = true; diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ObjectTypeVisitor.cs index 9a1ff8a1..1c867422 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ObjectTypeVisitor.cs @@ -88,13 +88,13 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var title = type.Value.IsGenericType - ? namingStrategy.GetPropertyName(type.Value.Name.Split('`').First(), hasSpecifiedName: false) + "_" + + ? namingStrategy.GetPropertyName(type.Value.GetTypeName(useFullName).Split('`').First(), hasSpecifiedName: false) + "_" + string.Join("_", - type.Value.GenericTypeArguments.Select(a => namingStrategy.GetPropertyName(a.Name, false))) - : namingStrategy.GetPropertyName(type.Value.Name, hasSpecifiedName: false); + type.Value.GenericTypeArguments.Select(a => namingStrategy.GetPropertyName(a.GetTypeName(useFullName), false))) + : namingStrategy.GetPropertyName(type.Value.GetTypeName(useFullName), hasSpecifiedName: false); var name = this.Visit(acceptor, name: type.Key, title: title, dataType: "object", dataFormat: null, attributes: attributes); if (name.IsNullOrWhiteSpace()) @@ -119,13 +119,13 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, .Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>()) .ToDictionary(p => p.GetJsonPropertyName(namingStrategy), p => p); - this.ProcessProperties(instance, name, properties, namingStrategy); + this.ProcessProperties(instance, name, properties, namingStrategy, useFullName); // Adds the reference. var reference = new OpenApiReference() { Type = ReferenceType.Schema, - Id = type.Value.GetOpenApiReferenceId(isDictionary: false, isList: false, namingStrategy) + Id = type.Value.GetOpenApiReferenceId(isDictionary: false, isList: false, namingStrategy, useFullName) }; instance.Schemas[name].Reference = reference; @@ -168,12 +168,12 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "object", dataFormat: null); } - private void ProcessProperties(IOpenApiSchemaAcceptor instance, string schemaName, Dictionary<string, PropertyInfo> properties, NamingStrategy namingStrategy) + private void ProcessProperties(IOpenApiSchemaAcceptor instance, string schemaName, Dictionary<string, PropertyInfo> properties, NamingStrategy namingStrategy, bool useFullName = false) { var schemas = new Dictionary<string, OpenApiSchema>(); @@ -184,7 +184,7 @@ private void ProcessProperties(IOpenApiSchemaAcceptor instance, string schemaNam Schemas = schemas, }; - subAcceptor.Accept(this.VisitorCollection, namingStrategy); + subAcceptor.Accept(this.VisitorCollection, namingStrategy, useFullName); // Add required properties to schema. var jsonPropertyAttributes = properties.Where(p => !p.Value.GetCustomAttribute<JsonPropertyAttribute>(inherit: false).IsNullOrDefault()) diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/OpenApiSchemaAcceptor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/OpenApiSchemaAcceptor.cs index 9b77cd5b..eb771afd 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/OpenApiSchemaAcceptor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/OpenApiSchemaAcceptor.cs @@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Reflection; - using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.OpenApi.Models; @@ -51,7 +50,7 @@ public OpenApiSchemaAcceptor(Dictionary<string, OpenApiSchema> rootSchemas, Dict public Dictionary<string, PropertyInfo> Properties { get; set; } = new Dictionary<string, PropertyInfo>(); /// <inheritdoc /> - public void Accept(VisitorCollection collection, NamingStrategy namingStrategy) + public void Accept(VisitorCollection collection, NamingStrategy namingStrategy, bool useFullName = false) { // Checks the properties only. if (this.Properties.Any()) @@ -74,7 +73,7 @@ public void Accept(VisitorCollection collection, NamingStrategy namingStrategy) } var type = new KeyValuePair<string, Type>(property.Key, property.Value.PropertyType); - visitor.Visit(this, type, namingStrategy, attributes.ToArray()); + visitor.Visit(this, type, namingStrategy, useFullName, attributes.ToArray()); } } @@ -91,7 +90,7 @@ public void Accept(VisitorCollection collection, NamingStrategy namingStrategy) continue; } - visitor.Visit(this, type, namingStrategy); + visitor.Visit(this, type, namingStrategy, useFullName); } } } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/RecursiveObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/RecursiveObjectTypeVisitor.cs index 3d3acb78..e8b0192a 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/RecursiveObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/RecursiveObjectTypeVisitor.cs @@ -78,9 +78,9 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { - var title = namingStrategy.GetPropertyName(type.Value.Name, hasSpecifiedName: false); + var title = namingStrategy.GetPropertyName(type.Value.GetTypeName(useFullName), hasSpecifiedName: false); var name = this.Visit(acceptor, name: type.Key, title: title, dataType: "object", dataFormat: null, attributes: attributes); if (name.IsNullOrWhiteSpace()) @@ -106,7 +106,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, .Where(p => p.PropertyType != type.Value) .ToDictionary(p => p.GetJsonPropertyName(namingStrategy), p => p); - this.ProcessProperties(instance, name, properties, namingStrategy); + this.ProcessProperties(instance, name, properties, namingStrategy, useFullName); // Processes recursive properties var recursiveProperties = type.Value @@ -121,7 +121,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, Reference = new OpenApiReference() { Type = ReferenceType.Schema, - Id = p.Value.PropertyType.GetOpenApiReferenceId(isDictionary: false, isList: false, namingStrategy) + Id = p.Value.PropertyType.GetOpenApiReferenceId(isDictionary: false, isList: false, namingStrategy, useFullName) } }); foreach (var recursiveSchema in recursiveSchemas) @@ -133,7 +133,7 @@ public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, var reference = new OpenApiReference() { Type = ReferenceType.Schema, - Id = type.Value.GetOpenApiReferenceId(isDictionary: false, isList: false, namingStrategy) + Id = type.Value.GetOpenApiReferenceId(isDictionary: false, isList: false, namingStrategy, useFullName) }; instance.Schemas[name].Reference = reference; @@ -174,12 +174,12 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "object", dataFormat: null); } - private void ProcessProperties(IOpenApiSchemaAcceptor instance, string schemaName, Dictionary<string, PropertyInfo> properties, NamingStrategy namingStrategy) + private void ProcessProperties(IOpenApiSchemaAcceptor instance, string schemaName, Dictionary<string, PropertyInfo> properties, NamingStrategy namingStrategy, bool useFullName = false) { var schemas = new Dictionary<string, OpenApiSchema>(); @@ -190,7 +190,7 @@ private void ProcessProperties(IOpenApiSchemaAcceptor instance, string schemaNam Schemas = schemas, }; - subAcceptor.Accept(this.VisitorCollection, namingStrategy); + subAcceptor.Accept(this.VisitorCollection, namingStrategy, useFullName); // Add required properties to schema. var jsonPropertyAttributes = properties.Where(p => !p.Value.GetCustomAttribute<JsonPropertyAttribute>(inherit: false).IsNullOrDefault()) diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/SingleTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/SingleTypeVisitor.cs index 26beb97b..72738640 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/SingleTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/SingleTypeVisitor.cs @@ -28,7 +28,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "number", dataFormat: "float", attributes: attributes); } @@ -56,7 +56,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "number", dataFormat: "float"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/StringEnumTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/StringEnumTypeVisitor.cs index 4e923a88..021ec0e4 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/StringEnumTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/StringEnumTypeVisitor.cs @@ -36,7 +36,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { var name = type.Key; @@ -112,7 +112,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { var schema = this.PayloadVisit(dataType: "string", dataFormat: null); diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/StringTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/StringTypeVisitor.cs index 0c4e6850..69b1bd1c 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/StringTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/StringTypeVisitor.cs @@ -29,7 +29,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "string", dataFormat: null, attributes: attributes); } @@ -57,7 +57,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "string", dataFormat: null); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TimeSpanObjectTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TimeSpanObjectTypeVisitor.cs index f9d66358..bc7cb049 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TimeSpanObjectTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TimeSpanObjectTypeVisitor.cs @@ -39,7 +39,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "string", dataFormat: "timespan", attributes: attributes); } @@ -53,7 +53,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "string", dataFormat: "timespan"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TypeTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TypeTypeVisitor.cs index 6d955321..8b80b26a 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TypeTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TypeTypeVisitor.cs @@ -42,7 +42,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "string", dataFormat: null, attributes: attributes); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TypeVisitor.cs index 593d5324..cc73d5d6 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/TypeVisitor.cs @@ -45,7 +45,7 @@ public virtual bool IsVisitable(Type type) } /// <inheritdoc /> - public virtual void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public virtual void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { return; } @@ -75,7 +75,7 @@ public virtual bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public virtual OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public virtual OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return default; } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt16TypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt16TypeVisitor.cs index 57e430c6..ecc070d2 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt16TypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt16TypeVisitor.cs @@ -30,7 +30,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "integer", dataFormat: "int32", attributes: attributes); } @@ -58,7 +58,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "integer", dataFormat: "int32"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt32TypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt32TypeVisitor.cs index aeee660a..5d788444 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt32TypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt32TypeVisitor.cs @@ -30,7 +30,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "integer", dataFormat: "int32", attributes: attributes); } @@ -58,7 +58,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "integer", dataFormat: "int32"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt64TypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt64TypeVisitor.cs index 0ca7932b..7424d535 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt64TypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UInt64TypeVisitor.cs @@ -30,7 +30,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "integer", dataFormat: "int64", attributes: attributes); } @@ -58,7 +58,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "integer", dataFormat: "int64"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UriTypeVisitor.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UriTypeVisitor.cs index 32ae534d..5b31111e 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UriTypeVisitor.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/UriTypeVisitor.cs @@ -26,7 +26,7 @@ public override bool IsVisitable(Type type) } /// <inheritdoc /> - public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes) + public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, bool useFullName = false, params Attribute[] attributes) { this.Visit(acceptor, name: type.Key, title: null, dataType: "string", dataFormat: "uri", attributes: attributes); } @@ -54,7 +54,7 @@ public override bool IsPayloadVisitable(Type type) } /// <inheritdoc /> - public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public override OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { return this.PayloadVisit(dataType: "string", dataFormat: "uri"); } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/VisitorCollection.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/VisitorCollection.cs index 4299aecc..38fb0463 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/VisitorCollection.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/VisitorCollection.cs @@ -82,8 +82,9 @@ public OpenApiSchema ParameterVisit(Type type, NamingStrategy namingStrategy) /// </summary> /// <param name="type">Type of the payload.</param> /// <param name="namingStrategy"><see cref="NamingStrategy"/> instance.</param> + /// <param name="useFullName">instance to get or set the value indicating whether to use the FullName or not.</param> /// <returns>Returns <see cref="OpenApiSchema"/> instance.</returns> - public OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) + public OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy, bool useFullName = false) { var schema = default(OpenApiSchema); foreach (var visitor in this.Visitors) @@ -93,7 +94,7 @@ public OpenApiSchema PayloadVisit(Type type, NamingStrategy namingStrategy) continue; } - schema = visitor.PayloadVisit(type, namingStrategy); + schema = visitor.PayloadVisit(type, namingStrategy,useFullName); break; } diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/Document.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/Document.cs index 8ecd49cf..085c07d2 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/Document.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/Document.cs @@ -32,6 +32,7 @@ public class Document : IDocument private NamingStrategy _strategy; private VisitorCollection _collection; private IHttpRequestDataObject _req; + private bool _useFullName; /// <summary> /// Initializes a new instance of the <see cref="Document"/> class. @@ -122,6 +123,14 @@ public IDocument AddVisitors(VisitorCollection collection) return this; } + /// <inheritdoc/> + public IDocument AddFullNameOption(bool useFullName = false) + { + this._useFullName = useFullName; + + return this; + } + /// <inheritdoc /> public IDocument Build(string assemblyPath, OpenApiVersionType version = OpenApiVersionType.V2) { @@ -174,9 +183,9 @@ public IDocument Build(Assembly assembly, OpenApiVersionType version = OpenApiVe } operation.Security = this._helper.GetOpenApiSecurityRequirement(method, this._strategy); - operation.Parameters = this._helper.GetOpenApiParameters(method, trigger, this._strategy, this._collection, version); - operation.RequestBody = this._helper.GetOpenApiRequestBody(method, this._strategy, this._collection, version); - operation.Responses = this._helper.GetOpenApiResponses(method, this._strategy, this._collection, version); + operation.Parameters = this._helper.GetOpenApiParameters(method, trigger, this._strategy, this._collection, version, this._useFullName); + operation.RequestBody = this._helper.GetOpenApiRequestBody(method, this._strategy, this._collection, version, this._useFullName); + operation.Responses = this._helper.GetOpenApiResponses(method, this._strategy, this._collection, version, this._useFullName); operations[verb] = operation; item.Operations = operations; @@ -185,7 +194,7 @@ public IDocument Build(Assembly assembly, OpenApiVersionType version = OpenApiVe } this.OpenApiDocument.Paths = paths; - this.OpenApiDocument.Components.Schemas = this._helper.GetOpenApiSchemas(methods, this._strategy, this._collection); + this.OpenApiDocument.Components.Schemas = this._helper.GetOpenApiSchemas(methods, this._strategy, this._collection, this._useFullName); this.OpenApiDocument.Components.SecuritySchemes = this._helper.GetOpenApiSecuritySchemes(methods, this._strategy); // this.OpenApiDocument.SecurityRequirements = this.OpenApiDocument // .Paths diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/OpenApiHttpTriggerContext.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/OpenApiHttpTriggerContext.cs index 43b3a716..e1c617dd 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/OpenApiHttpTriggerContext.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/OpenApiHttpTriggerContext.cs @@ -44,6 +44,7 @@ public class OpenApiHttpTriggerContext : IOpenApiHttpTriggerContext /// <param name="uiOptions"><see cref="IOpenApiCustomUIOptions"/> instance.</param> public OpenApiHttpTriggerContext(IOpenApiConfigurationOptions configOptions = null, IOpenApiCustomUIOptions uiOptions = null) { + this._configOptions = configOptions; this._uiOptions = uiOptions; this.PackageAssembly = this.GetAssembly<ISwaggerUI>(); diff --git a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/OpenApiTriggerFunctions.cs b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/OpenApiTriggerFunctions.cs index a727c5e7..67be5a84 100644 --- a/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/OpenApiTriggerFunctions.cs +++ b/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/OpenApiTriggerFunctions.cs @@ -63,6 +63,7 @@ public static async Task<IActionResult> RenderSwaggerDocument( .AddServer(request, openApiContext.HttpSettings.RoutePrefix, openApiContext.OpenApiConfigurationOptions) .AddNamingStrategy(openApiContext.NamingStrategy) .AddVisitors(openApiContext.GetVisitorCollection()) + .AddFullNameOption(openApiContext.OpenApiConfigurationOptions.UseFullName) .Build(openApiContext.ApplicationAssembly, openApiContext.OpenApiConfigurationOptions.OpenApiVersion) .ApplyDocumentFilters(openApiContext.GetDocumentFilterCollection()) .RenderAsync(openApiContext.GetOpenApiSpecVersion(openApiContext.OpenApiConfigurationOptions.OpenApiVersion), openApiContext.GetOpenApiFormat(extension)) @@ -139,6 +140,7 @@ public static async Task<IActionResult> RenderOpenApiDocument( .AddServer(new HttpRequestObject(req), openApiContext.HttpSettings.RoutePrefix, openApiContext.OpenApiConfigurationOptions) .AddNamingStrategy(openApiContext.NamingStrategy) .AddVisitors(openApiContext.GetVisitorCollection()) + .AddFullNameOption(openApiContext.OpenApiConfigurationOptions.UseFullName) .Build(openApiContext.ApplicationAssembly, openApiContext.GetOpenApiVersionType(version)) .ApplyDocumentFilters(openApiContext.GetDocumentFilterCollection()) .RenderAsync(openApiContext.GetOpenApiSpecVersion(version), openApiContext.GetOpenApiFormat(extension)) diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_ArrayObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_ArrayObject_Tests.cs index da6a5a37..a3fd0fdc 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_ArrayObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_ArrayObject_Tests.cs @@ -44,7 +44,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/get-applicationjson-array", "get", "200", "application/json", "arrayObjectModel")] + [DataRow("/get-applicationjson-array", "get", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -55,7 +55,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("arrayObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -67,15 +67,15 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("arrayObjectModel", "object", "objectValue", "array")] - [DataRow("arrayObjectModel", "object", "booleanValue", "array")] - [DataRow("arrayObjectModel", "object", "stringValue", "array")] - [DataRow("arrayObjectModel", "object", "int32Value", "array")] - [DataRow("arrayObjectModel", "object", "int64Value", "array")] - [DataRow("arrayObjectModel", "object", "floatValue", "array")] - [DataRow("arrayObjectModel", "object", "decimalValue", "array")] - [DataRow("arrayObjectModel", "object", "stringObjectValue", "array")] - [DataRow("arrayObjectModel", "object", "objectArrayValue", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "objectValue", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "booleanValue", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "stringValue", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "int32Value", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "int64Value", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "floatValue", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "decimalValue", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "stringObjectValue", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "objectArrayValue", "array")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string refType, string propertyName, string propertyType) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; @@ -87,13 +87,13 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty( } [DataTestMethod] - [DataRow("arrayObjectModel", "object", "objectValue", "array", "object")] - [DataRow("arrayObjectModel", "object", "booleanValue", "array", "boolean")] - [DataRow("arrayObjectModel", "object", "stringValue", "array", "string")] - [DataRow("arrayObjectModel", "object", "int32Value", "array", "integer")] - [DataRow("arrayObjectModel", "object", "int64Value", "array", "integer")] - [DataRow("arrayObjectModel", "object", "floatValue", "array", "number")] - [DataRow("arrayObjectModel", "object", "decimalValue", "array", "number")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "objectValue", "array", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "booleanValue", "array", "boolean")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "stringValue", "array", "string")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "int32Value", "array", "integer")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "int64Value", "array", "integer")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "floatValue", "array", "number")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "decimalValue", "array", "number")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaPropertyItems(string @ref, string refType, string propertyName, string propertyType, string itemType) { var items = this._doc["components"]["schemas"][@ref]["properties"][propertyName]["items"]; @@ -105,8 +105,8 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaPropertyI } [DataTestMethod] - [DataRow("arrayObjectModel", "object", "stringObjectValue", "array", "stringObjectModel")] - [DataRow("arrayObjectModel", "object", "objectArrayValue", "array", "list_object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "stringObjectValue", "array", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.StringObjectModel")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ArrayObjectModel", "object", "objectArrayValue", "array", "list_object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaPropertyItemReference(string @ref, string refType, string propertyName, string propertyType, string itemRef) { var items = this._doc["components"]["schemas"][@ref]["properties"][propertyName]["items"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_BaseObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_BaseObject_Tests.cs index ec5edbd9..80e6fa1b 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_BaseObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_BaseObject_Tests.cs @@ -45,7 +45,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/get-applicationjson-baseobject", "get", "200", "application/json", "baseObjectModel")] + [DataRow("/get-applicationjson-baseobject", "get", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Not_Return_ReferenceSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -56,8 +56,8 @@ public void Given_OpenApiDocument_Then_It_Should_Not_Return_ReferenceSchema(stri } [DataTestMethod] - [DataRow("baseObjectModel", "baseObjectValue")] - [DataRow("baseSubObjectModel", "baseSubObjectValue")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseObjectModel", "baseObjectValue")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseSubObjectModel", "baseSubObjectValue")] public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Expected_TypeOf_Object(string @ref, string propName) { var schemas = this._doc["components"]["schemas"]; @@ -68,8 +68,8 @@ public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Expected_ } [DataTestMethod] - [DataRow("baseObjectModel", "nonObjectValue")] - [DataRow("baseObjectModel", "subObjectValue")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseObjectModel", "nonObjectValue")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseObjectModel", "subObjectValue")] public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Not_Return_Expected_TypeOf_Object(string @ref, string propName) { var schemas = this._doc["components"]["schemas"]; @@ -80,8 +80,8 @@ public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Not_Return_Expec } [DataTestMethod] - [DataRow("baseObjectModel", "baseObjectList", "array")] - [DataRow("baseObjectModel", "baseObjectDictionary", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseObjectModel", "baseObjectList", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseObjectModel", "baseObjectDictionary", "object")] public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Expected_Type(string @ref, string propName, string listType) { var schemas = this._doc["components"]["schemas"]; @@ -92,8 +92,8 @@ public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Expected_ } [DataTestMethod] - [DataRow("baseObjectModel", "baseObjectList", "items", "object")] - [DataRow("baseObjectModel", "baseObjectDictionary", "additionalProperties", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseObjectModel", "baseObjectList", "items", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseObjectModel", "baseObjectDictionary", "additionalProperties", "object")] public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Expected_SubType(string @ref, string propName, string attrName, string subType) { var schemas = this._doc["components"]["schemas"]; @@ -105,8 +105,8 @@ public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Expected_ } [DataTestMethod] - [DataRow("baseObjectModel", "baseObjectList", "items")] - [DataRow("baseObjectModel", "baseObjectDictionary", "additionalProperties")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseObjectModel", "baseObjectList", "items")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BaseObjectModel", "baseObjectDictionary", "additionalProperties")] public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Null_Title(string @ref, string propName, string attr) { var schemas = this._doc["components"]["schemas"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_DataType_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_DataType_Tests.cs index 6a8fdcbe..73d8d3f6 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_DataType_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_DataType_Tests.cs @@ -44,7 +44,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/get-applicationjson-datatype", "get", "200", "application/json", "dataTypeObjectModel")] + [DataRow("/get-applicationjson-datatype", "get", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -54,7 +54,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent @ref.Value<string>().Should().Be($"#/components/schemas/{reference}"); } [DataTestMethod] - [DataRow("dataTypeObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -66,18 +66,18 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("dataTypeObjectModel", "dateTimeValue1", "string", "date-time", false)] - [DataRow("dataTypeObjectModel", "dateTimeValue2", "string", "date", false)] - [DataRow("dataTypeObjectModel", "dateTimeValue3", "string", "time", false)] - [DataRow("dataTypeObjectModel", "nullableDateTimeValue1", "string", "date-time", true)] - [DataRow("dataTypeObjectModel", "nullableDateTimeValue2", "string", "date", true)] - [DataRow("dataTypeObjectModel", "nullableDateTimeValue3", "string", "time", true)] - [DataRow("dataTypeObjectModel", "dateTimeOffsetValue1", "string", "date-time", false)] - [DataRow("dataTypeObjectModel", "dateTimeOffsetValue2", "string", "date", false)] - [DataRow("dataTypeObjectModel", "dateTimeOffsetValue3", "string", "time", false)] - [DataRow("dataTypeObjectModel", "nullableDateTimeOffsetValue1", "string", "date-time", true)] - [DataRow("dataTypeObjectModel", "nullableDateTimeOffsetValue2", "string", "date", true)] - [DataRow("dataTypeObjectModel", "nullableDateTimeOffsetValue3", "string", "time", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "dateTimeValue1", "string", "date-time", false)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "dateTimeValue2", "string", "date", false)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "dateTimeValue3", "string", "time", false)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "nullableDateTimeValue1", "string", "date-time", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "nullableDateTimeValue2", "string", "date", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "nullableDateTimeValue3", "string", "time", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "dateTimeOffsetValue1", "string", "date-time", false)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "dateTimeOffsetValue2", "string", "date", false)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "dateTimeOffsetValue3", "string", "time", false)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "nullableDateTimeOffsetValue1", "string", "date-time", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "nullableDateTimeOffsetValue2", "string", "date", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DataTypeObjectModel", "nullableDateTimeOffsetValue3", "string", "time", true)] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType, string propertyFormat, bool propertyNullable) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_DictionaryObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_DictionaryObject_Tests.cs index aca1db13..6483328e 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_DictionaryObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_DictionaryObject_Tests.cs @@ -44,7 +44,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/get-applicationjson-dictionaryobject", "get", "200", "application/json", "dictionaryObjectModel")] + [DataRow("/get-applicationjson-dictionaryobject", "get", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -55,10 +55,10 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("dictionaryObjectModel", "object", "objectValue", "object", "object")] - [DataRow("dictionaryObjectModel", "object", "booleanValue", "object", "boolean")] - [DataRow("dictionaryObjectModel", "object", "stringValue", "object", "string")] - [DataRow("dictionaryObjectModel", "object", "int32Value", "object", "integer")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "object", "objectValue", "object", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "object", "booleanValue", "object", "boolean")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "object", "stringValue", "object", "string")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "object", "int32Value", "object", "integer")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType, string propertyName, string propertyType, string itemType) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; @@ -71,14 +71,14 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("dictionaryObjectModel", "objectObjectValue", "object", "objectObjectModel")] - [DataRow("dictionaryObjectModel", "booleanObjectValue", "object", "booleanObjectModel")] - [DataRow("dictionaryObjectModel", "stringObjectValue", "object", "stringObjectModel")] - [DataRow("dictionaryObjectModel", "integerObjectValue", "object", "integerObjectModel")] - [DataRow("dictionaryObjectModel", "objectArrayValue", "object", "list_object")] - [DataRow("dictionaryObjectModel", "booleanArrayValue", "object", "list_boolean")] - [DataRow("dictionaryObjectModel", "stringArrayValue", "object", "list_string")] - [DataRow("dictionaryObjectModel", "int32ArrayValue", "object", "list_int32")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "objectObjectValue", "object", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ObjectObjectModel")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "booleanObjectValue", "object", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BooleanObjectModel")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "stringObjectValue", "object", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.StringObjectModel")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "integerObjectValue", "object", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "objectArrayValue", "object", "list_object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "booleanArrayValue", "object", "list_boolean")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "stringArrayValue", "object", "list_string")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DictionaryObjectModel", "int32ArrayValue", "object", "list_int32")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType, string itemRef) { diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_Exception_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_Exception_Tests.cs index 99b419d8..9100557f 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_Exception_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_Exception_Tests.cs @@ -46,7 +46,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/get-applicationjson-exception", "get", "200", "application/json", "stackOverflowException")] + [DataRow("/get-applicationjson-exception", "get", "200", "application/json", "system.StackOverflowException")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -57,7 +57,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("stackOverflowException", "object")] + [DataRow("system.StackOverflowException", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_GenericAndRecursiveObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_GenericAndRecursiveObject_Tests.cs index 4ee30b5c..a458098d 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_GenericAndRecursiveObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_GenericAndRecursiveObject_Tests.cs @@ -44,7 +44,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/get-applicationjson-genericandrecursive", "get", "200", "application/json", "genericAndRecursiveObjectModel")] + [DataRow("/get-applicationjson-genericandrecursive", "get", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.GenericAndRecursiveObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -55,8 +55,8 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("genericAndRecursiveObjectModel", "object", "listValue", "array")] - [DataRow("genericAndRecursiveObjectModel", "object", "dictionaryValue", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.GenericAndRecursiveObjectModel", "object", "listValue", "array")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.GenericAndRecursiveObjectModel", "object", "dictionaryValue", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_PropertyType(string @ref, string refType, string propertyName, string propertyType) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; @@ -69,8 +69,8 @@ public void Given_OpenApiDocument_Then_It_Should_Return_PropertyType(string @ref } [DataTestMethod] - [DataRow("genericAndRecursiveObjectModel", "object", "listValue", "items", "genericAndRecursiveObjectModel")] - [DataRow("genericAndRecursiveObjectModel", "object", "dictionaryValue", "additionalProperties", "genericAndRecursiveObjectModel")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.GenericAndRecursiveObjectModel", "object", "listValue", "items", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.GenericAndRecursiveObjectModel")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.GenericAndRecursiveObjectModel", "object", "dictionaryValue", "additionalProperties", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.GenericAndRecursiveObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType, string propertyName, string propertyType, string itemReference) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_JObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_JObject_Tests.cs index da2da965..d87b93f4 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_JObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_JObject_Tests.cs @@ -44,7 +44,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/get-applicationjson-jobject", "get", "200", "application/json", "jObjectModel")] + [DataRow("/get-applicationjson-jobject", "get", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.JObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -55,7 +55,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("jObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.JObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -67,9 +67,9 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("jObjectModel", "jObjectValue", "object")] - [DataRow("jObjectModel", "jTokenValue", "object")] - [DataRow("jObjectModel", "jArrayValue", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.JObjectModel", "jObjectValue", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.JObjectModel", "jTokenValue", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.JObjectModel", "jArrayValue", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_JsonProperty_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_JsonProperty_Tests.cs index e965647e..43f6f031 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_JsonProperty_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_JsonProperty_Tests.cs @@ -44,7 +44,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/get-applicationjson-jsonproperty", "get", "200", "application/json", "jsonPropertyObjectModel")] + [DataRow("/get-applicationjson-jsonproperty", "get", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.JsonPropertyObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -55,7 +55,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("jsonPropertyObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.JsonPropertyObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -67,9 +67,9 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("jsonPropertyObjectModel", "object", "Member1", "string", null)] - [DataRow("jsonPropertyObjectModel", "object", "MEMBER2", "integer", "int32")] - [DataRow("jsonPropertyObjectModel", "object", "mEmbER3", "string", "date-time")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.JsonPropertyObjectModel", "object", "Member1", "string", null)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.JsonPropertyObjectModel", "object", "MEMBER2", "integer", "int32")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.JsonPropertyObjectModel", "object", "mEmbER3", "string", "date-time")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string refType, string propertyName, string propertyType, string propertyFormat) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_StringObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_StringObject_Tests.cs index 389201a4..2e9ae479 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_StringObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Get_ApplicationJson_StringObject_Tests.cs @@ -44,7 +44,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/get-applicationjson-string", "get", "200", "application/json", "stringObjectModel")] + [DataRow("/get-applicationjson-string", "get", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.StringObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -55,7 +55,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("stringObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.StringObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -67,7 +67,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("stringObjectModel", "object", "stringValue", "string")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.StringObjectModel", "object", "stringValue", "string")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string refType, string propertyName, string propertyType) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_BooleanObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_BooleanObject_Tests.cs index e19c6307..9f50666b 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_BooleanObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_BooleanObject_Tests.cs @@ -74,7 +74,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-boolean", "post", "200", "application/json", "booleanObjectModel")] + [DataRow("/post-applicationjson-boolean", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BooleanObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -85,7 +85,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("booleanObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BooleanObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -97,7 +97,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("booleanObjectModel", "booleanValue", "boolean")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.BooleanObjectModel", "booleanValue", "boolean")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_ByteArrayObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_ByteArrayObject_Tests.cs index c126da68..98f8a085 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_ByteArrayObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_ByteArrayObject_Tests.cs @@ -75,7 +75,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-bytearray", "post", "200", "application/json", "byteArrayObjectModel")] + [DataRow("/post-applicationjson-bytearray", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ByteArrayObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -86,7 +86,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("byteArrayObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ByteArrayObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -98,7 +98,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("byteArrayObjectModel", "byteArrayValue", "string", "binary")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ByteArrayObjectModel", "byteArrayValue", "string", "binary")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType, string propertyFormat) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_DateTime_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_DateTime_Tests.cs index e4e6b0a9..9ca955e7 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_DateTime_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_DateTime_Tests.cs @@ -76,7 +76,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-datetime", "post", "200", "application/json", "dateTimeObjectModel")] + [DataRow("/post-applicationjson-datetime", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DateTimeObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema_DateTime(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -136,7 +136,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-datetimeoffset", "post", "200", "application/json", "dateTimeObjectModel")] + [DataRow("/post-applicationjson-datetimeoffset", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DateTimeObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema_DateTimeOffset(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -148,7 +148,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent [DataTestMethod] - [DataRow("dateTimeObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DateTimeObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -160,7 +160,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("dateTimeObjectModel", "dateTimeValue", "string", "date-time", "dateTimeOffsetValue", "string", "date-time")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.DateTimeObjectModel", "dateTimeValue", "string", "date-time", "dateTimeOffsetValue", "string", "date-time")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName1, string propertyType1, string propertyFormat1, string propertyName2, string propertyType2, string propertyFormat2) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; @@ -177,4 +177,4 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty( value2.Value<string>("format").Should().Be(propertyFormat2); } } -} \ No newline at end of file +} diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_ExceptionObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_ExceptionObject_Tests.cs index 7ea1effb..d3f6ecdf 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_ExceptionObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_ExceptionObject_Tests.cs @@ -46,7 +46,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationRequestBodyCont } [DataTestMethod] - [DataRow("/post-applicationjson-exception", "post", "application/json", "invalidOperationException")] + [DataRow("/post-applicationjson-exception", "post", "application/json", "system.InvalidOperationException")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationRequestBodyContentReferenceSchema(string path, string operationType, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["requestBody"]["content"]; @@ -75,7 +75,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-exception", "post", "200", "application/json", "exceptionObjectModel")] + [DataRow("/post-applicationjson-exception", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ExceptionObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -86,10 +86,10 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("exceptionObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ExceptionObjectModel", "object")] [DataRow("exception", "object")] - [DataRow("invalidOperationException", "object")] - [DataRow("stackOverflowException", "object")] + [DataRow("system.InvalidOperationException", "object")] + [DataRow("system.StackOverflowException", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -101,9 +101,9 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("exceptionObjectModel", "exceptionValue", "object")] - [DataRow("exceptionObjectModel", "invalidOperationExceptionValue", "object")] - [DataRow("exceptionObjectModel", "stackOverflowExceptionValue", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ExceptionObjectModel", "exceptionValue", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ExceptionObjectModel", "invalidOperationExceptionValue", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.ExceptionObjectModel", "stackOverflowExceptionValue", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_GuidObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_GuidObject_Tests.cs index c0464e9a..12299c08 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_GuidObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_GuidObject_Tests.cs @@ -75,7 +75,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-guid", "post", "200", "application/json", "guidObjectModel")] + [DataRow("/post-applicationjson-guid", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.GuidObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -86,7 +86,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("guidObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.GuidObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -98,7 +98,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("guidObjectModel", "guidValue", "string", "uuid")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.GuidObjectModel", "guidValue", "string", "uuid")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType, string propertyFormat) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_IntegerObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_IntegerObject_Tests.cs index 0684308c..83a4f51c 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_IntegerObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_IntegerObject_Tests.cs @@ -103,12 +103,12 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-int16", "post", "200", "application/json", "integerObjectModel")] - [DataRow("/post-applicationjson-int32", "post", "200", "application/json", "integerObjectModel")] - [DataRow("/post-applicationjson-int64", "post", "200", "application/json", "integerObjectModel")] - [DataRow("/post-applicationjson-uint16", "post", "200", "application/json", "integerObjectModel")] - [DataRow("/post-applicationjson-uint32", "post", "200", "application/json", "integerObjectModel")] - [DataRow("/post-applicationjson-uint64", "post", "200", "application/json", "integerObjectModel")] + [DataRow("/post-applicationjson-int16", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel")] + [DataRow("/post-applicationjson-int32", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel")] + [DataRow("/post-applicationjson-int64", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel")] + [DataRow("/post-applicationjson-uint16", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel")] + [DataRow("/post-applicationjson-uint32", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel")] + [DataRow("/post-applicationjson-uint64", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -119,7 +119,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("integerObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -131,12 +131,12 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("integerObjectModel", "int16Value", "integer", "int32")] - [DataRow("integerObjectModel", "int32Value", "integer", "int32")] - [DataRow("integerObjectModel", "int64Value", "integer", "int64")] - [DataRow("integerObjectModel", "uInt16Value", "integer", "int32")] - [DataRow("integerObjectModel", "uInt32Value", "integer", "int32")] - [DataRow("integerObjectModel", "uInt64Value", "integer", "int64")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel", "int16Value", "integer", "int32")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel", "int32Value", "integer", "int32")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel", "int64Value", "integer", "int64")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel", "uInt16Value", "integer", "int32")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel", "uInt32Value", "integer", "int32")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.IntegerObjectModel", "uInt64Value", "integer", "int64")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType, string propertyFormat) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_NullableObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_NullableObject_Tests.cs index 5cf16903..af72264a 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_NullableObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_NullableObject_Tests.cs @@ -143,18 +143,18 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-nullableboolean", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullableuint16", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullableuint32", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullableuint64", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullableint16", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullableint32", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullableint64", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullablesingle", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullabledouble", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullabledecimal", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullabledatetime", "post", "200", "application/json", "nullableObjectModel")] - [DataRow("/post-applicationjson-nullabledatetimeoffset", "post", "200", "application/json", "nullableObjectModel")] + [DataRow("/post-applicationjson-nullableboolean", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullableuint16", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullableuint32", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullableuint64", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullableint16", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullableint32", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullableint64", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullablesingle", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullabledouble", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullabledecimal", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullabledatetime", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] + [DataRow("/post-applicationjson-nullabledatetimeoffset", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -165,7 +165,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("nullableObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -177,7 +177,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("nullableObjectModel", "booleanValue", "boolean", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "booleanValue", "boolean", true)] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty_Boolean(string @ref, string propertyName, string propertyType, bool nullable) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; @@ -190,17 +190,17 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty_ } [DataTestMethod] - [DataRow("nullableObjectModel", "uInt16Value", "integer", "int32", true)] - [DataRow("nullableObjectModel", "uInt32Value", "integer", "int32", true)] - [DataRow("nullableObjectModel", "uInt64Value", "integer", "int64", true)] - [DataRow("nullableObjectModel", "int16Value", "integer", "int32", true)] - [DataRow("nullableObjectModel", "int32Value", "integer", "int32", true)] - [DataRow("nullableObjectModel", "int64Value", "integer", "int64", true)] - [DataRow("nullableObjectModel", "singleValue", "number", "float", true)] - [DataRow("nullableObjectModel", "doubleValue", "number", "double", true)] - [DataRow("nullableObjectModel", "decimalValue", "number", "double", true)] - [DataRow("nullableObjectModel", "dateTimeValue", "string", "date-time", true)] - [DataRow("nullableObjectModel", "dateTimeOffsetValue", "string", "date-time", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "uInt16Value", "integer", "int32", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "uInt32Value", "integer", "int32", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "uInt64Value", "integer", "int64", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "int16Value", "integer", "int32", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "int32Value", "integer", "int32", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "int64Value", "integer", "int64", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "singleValue", "number", "float", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "doubleValue", "number", "double", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "decimalValue", "number", "double", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "dateTimeValue", "string", "date-time", true)] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NullableObjectModel", "dateTimeOffsetValue", "string", "date-time", true)] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType, string propertyFormat, bool nullable) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_NumberObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_NumberObject_Tests.cs index 06c46998..2aaf440e 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_NumberObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_NumberObject_Tests.cs @@ -85,9 +85,9 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-single", "post", "200", "application/json", "numberObjectModel")] - [DataRow("/post-applicationjson-double", "post", "200", "application/json", "numberObjectModel")] - [DataRow("/post-applicationjson-decimal", "post", "200", "application/json", "numberObjectModel")] + [DataRow("/post-applicationjson-single", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NumberObjectModel")] + [DataRow("/post-applicationjson-double", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NumberObjectModel")] + [DataRow("/post-applicationjson-decimal", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NumberObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -98,7 +98,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("numberObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NumberObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -110,9 +110,9 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("numberObjectModel", "singleValue", "number", "float")] - [DataRow("numberObjectModel", "doubleValue", "number", "double")] - [DataRow("numberObjectModel", "decimalValue", "number", "double")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NumberObjectModel", "singleValue", "number", "float")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NumberObjectModel", "doubleValue", "number", "double")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.NumberObjectModel", "decimalValue", "number", "double")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType, string propertyFormat) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_StringObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_StringObject_Tests.cs index 27285a30..290719bd 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_StringObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_StringObject_Tests.cs @@ -74,7 +74,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-string", "post", "200", "application/json", "stringObjectModel")] + [DataRow("/post-applicationjson-string", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.StringObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -85,7 +85,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("stringObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.StringObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -97,7 +97,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("stringObjectModel", "stringValue", "string")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.StringObjectModel", "stringValue", "string")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_UriObject_Tests.cs b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_UriObject_Tests.cs index 8da2bee4..c3764375 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_UriObject_Tests.cs +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests/Post_ApplicationJson_UriObject_Tests.cs @@ -76,7 +76,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("/post-applicationjson-uri", "post", "200", "application/json", "uriObjectModel")] + [DataRow("/post-applicationjson-uri", "post", "200", "application/json", "microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.UriObjectModel")] public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContentTypeSchema(string path, string operationType, string responseCode, string contentType, string reference) { var content = this._doc["paths"][path][operationType]["responses"][responseCode]["content"]; @@ -87,7 +87,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_OperationResponseContent } [DataTestMethod] - [DataRow("uriObjectModel", "object")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.UriObjectModel", "object")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ref, string refType) { var schemas = this._doc["components"]["schemas"]; @@ -99,7 +99,7 @@ public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchema(string @ } [DataTestMethod] - [DataRow("uriObjectModel", "uriValue", "string", "uri")] + [DataRow("microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp.Models.UriObjectModel", "uriValue", "string", "uri")] public void Given_OpenApiDocument_Then_It_Should_Return_ComponentSchemaProperty(string @ref, string propertyName, string propertyType, string propertyFormat) { var properties = this._doc["components"]["schemas"][@ref]["properties"]; diff --git a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp/local.settings.json b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp/local.settings.json index 8d053494..a671a7a2 100644 --- a/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp/local.settings.json +++ b/test-integration/Microsoft.Azure.WebJobs.Extensions.OpenApi.TestApp/local.settings.json @@ -5,6 +5,7 @@ "FUNCTIONS_WORKER_RUNTIME": "dotnet", "OpenApi__ForceHttps": "true", "OpenApi__Version": "v3", - "OpenApi__HostNames": "https://contoso.com/api,https://fabrikam.com/api" + "OpenApi__HostNames": "https://contoso.com/api,https://fabrikam.com/api", + "OpenApi__UseFullNamespace": "true" } } diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Configurations/DefaultOpenApiConfigurationOptionsTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Configurations/DefaultOpenApiConfigurationOptionsTests.cs index 0471b2bc..d23c8852 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Configurations/DefaultOpenApiConfigurationOptionsTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Configurations/DefaultOpenApiConfigurationOptionsTests.cs @@ -26,6 +26,8 @@ public void Cleanup() Environment.SetEnvironmentVariable("OpenApi__ExcludeRequestingHost", null); Environment.SetEnvironmentVariable("OpenApi__ForceHttp", null); Environment.SetEnvironmentVariable("OpenApi__ForceHttps", null); + Environment.SetEnvironmentVariable("OpenApi__NamingStrategy", "CamelCase"); + Environment.SetEnvironmentVariable("OpenApi__UseFullNamespace", null); } [TestMethod] @@ -282,6 +284,20 @@ public void Given_EnvironmentVariable_When_IsHttpsForced_Invoked_Then_It_Should_ result.Should().Be(expected); } + [DataTestMethod] + [DataRow("true",true)] + [DataRow("false",false)] + [DataRow ("",false)] + [DataRow (null, false)] + public void Given_EnvironmentVariable_When_UseFullNamespace_Invoked_Then_It_Should_Return_Result(string useFullName, bool expected) + { + Environment.SetEnvironmentVariable("OpenApi__UseFullNamespace",useFullName); + + var result = DefaultOpenApiConfigurationOptions.UseFullNamespace(); + + result.Should().Be(expected); + } + [TestMethod] public void Given_Type_When_Instantiated_Then_It_Should_Return_EmptyListOfDocumentFilters() { diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/DocumentHelperTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/DocumentHelperTests.cs index f89246db..0ef2c846 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/DocumentHelperTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/DocumentHelperTests.cs @@ -2,7 +2,7 @@ using System.Linq; using FluentAssertions; - +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -33,12 +33,13 @@ public void GetOpenApiSchemas_Result_Should_Contain_Schema_For_Function_Classes( var namingStrategy = new DefaultNamingStrategy(); var filter = new RouteConstraintFilter(); var acceptor = new OpenApiSchemaAcceptor(); + var options = new OpenApiConfigurationOptions(); var documentHelper = new DocumentHelper(filter, acceptor); var visitorCollection = VisitorCollection.CreateInstance(); var methods = typeof(FakeFunctions).GetMethods().ToList(); - var schemas = documentHelper.GetOpenApiSchemas(methods, namingStrategy, visitorCollection); + var schemas = documentHelper.GetOpenApiSchemas(methods, namingStrategy, visitorCollection, options.UseFullName); schemas.Should().NotBeNull(); schemas.Count.Should().Be(6); @@ -90,13 +91,14 @@ public void GetOpenApiSchemas_Result_Should_Contain_No_Overlapping_OpenApiRefere var namingStrategy = new DefaultNamingStrategy(); var filter = new RouteConstraintFilter(); var acceptor = new OpenApiSchemaAcceptor(); + var options = new OpenApiConfigurationOptions(); var documentHelper = new DocumentHelper(filter, acceptor); var visitorCollection = VisitorCollection.CreateInstance(); var methods = typeof(FakeFunctionsWithOverlappingModel.OverlappingClass1).GetMethods() .Concat(typeof(FakeFunctionsWithOverlappingModel.OverlappingClass2).GetMethods()).ToList(); - var schemas = documentHelper.GetOpenApiSchemas(methods, namingStrategy, visitorCollection); + var schemas = documentHelper.GetOpenApiSchemas(methods, namingStrategy, visitorCollection, options.UseFullName); schemas.Should().NotBeNull(); schemas.Count.Should().Be(1); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/BaseObjectTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/BaseObjectTypeVisitorTests.cs index beb0f11b..ce910535 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/BaseObjectTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/BaseObjectTypeVisitorTests.cs @@ -4,6 +4,7 @@ using FluentAssertions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -18,6 +19,7 @@ public class BaseObjectTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -25,6 +27,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new BaseObjectTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -57,7 +60,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(object)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/BooleanTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/BooleanTypeVisitorTests.cs index e467db11..daccfbb6 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/BooleanTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/BooleanTypeVisitorTests.cs @@ -5,8 +5,10 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Any; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -21,6 +23,7 @@ public class BooleanTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -28,6 +31,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new BooleanTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -77,7 +81,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(bool)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -92,7 +96,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(bool)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -110,7 +114,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(bool)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -128,7 +132,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(bool)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -149,7 +153,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("boolean", null)] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(bool), this._strategy); + var result = this._visitor.PayloadVisit(typeof(bool), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ByteArrayTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ByteArrayTypeVisitorTests.cs index 79773650..506de849 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ByteArrayTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ByteArrayTypeVisitorTests.cs @@ -5,8 +5,10 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Any; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -21,6 +23,7 @@ public class ByteArrayTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -28,6 +31,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new ByteArrayTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -76,7 +80,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(byte[])); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -91,7 +95,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(byte[])); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -108,7 +112,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(byte[])); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -125,7 +129,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(byte[])); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -142,7 +146,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(byte[])); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -163,7 +167,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("string", "binary")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(byte[]), this._strategy); + var result = this._visitor.PayloadVisit(typeof(byte[]), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ByteEnumTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ByteEnumTypeVisitorTests.cs index 466712b6..881bddf8 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ByteEnumTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ByteEnumTypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; @@ -23,6 +24,7 @@ public class ByteEnumTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -30,6 +32,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new ByteEnumTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -80,7 +83,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var type = new KeyValuePair<string, Type>(name, typeof(FakeByteEnum)); var enums = enumType.ToOpenApiByteCollection(); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -104,7 +107,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(FakeByteEnum)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -121,7 +124,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(FakeByteEnum)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -138,7 +141,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(FakeByteEnum)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -155,7 +158,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(FakeByteEnum)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -189,7 +192,7 @@ public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(st { var enums = enumType.ToOpenApiByteCollection(); - var result = this._visitor.PayloadVisit(typeof(FakeByteEnum), this._strategy); + var result = this._visitor.PayloadVisit(typeof(FakeByteEnum), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DateTimeOffsetObjectTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DateTimeOffsetObjectTypeVisitorTests.cs index 370998f7..5c023e2f 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DateTimeOffsetObjectTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DateTimeOffsetObjectTypeVisitorTests.cs @@ -6,8 +6,10 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Any; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -22,6 +24,7 @@ public class DateTimeOffsetObjectTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +32,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new DateTimeOffsetObjectTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -78,7 +82,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(DateTimeOffset)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -96,7 +100,7 @@ public void Given_DataTypeAttribute_When_Visit_Invoked_Then_It_Should_Return_Res var type = new KeyValuePair<string, Type>(name, typeof(DateTimeOffset)); var attribute = new DataTypeAttribute(dataType); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("string"); @@ -111,7 +115,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(DateTimeOffset)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -128,7 +132,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(DateTimeOffset)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -145,7 +149,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(DateTimeOffset)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -162,7 +166,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(DateTimeOffset)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -183,7 +187,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("string", "date-time")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Null(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(DateTimeOffset), this._strategy); + var result = this._visitor.PayloadVisit(typeof(DateTimeOffset), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DateTimeTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DateTimeTypeVisitorTests.cs index f1f144f9..6182bd34 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DateTimeTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DateTimeTypeVisitorTests.cs @@ -6,8 +6,10 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Any; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -22,6 +24,7 @@ public class DateTimeTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +32,8 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new DateTimeTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); + } [DataTestMethod] @@ -78,7 +83,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(DateTime)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -96,7 +101,7 @@ public void Given_DataTypeAttribute_When_Visit_Invoked_Then_It_Should_Return_Res var type = new KeyValuePair<string, Type>(name, typeof(DateTime)); var attribute = new DataTypeAttribute(dataType); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("string"); @@ -111,7 +116,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(DateTime)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -128,7 +133,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(DateTime)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -145,7 +150,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(DateTime)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -162,7 +167,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(DateTime)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -183,7 +188,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("string", "date-time")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Null(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(DateTime), this._strategy); + var result = this._visitor.PayloadVisit(typeof(DateTime), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DecimalTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DecimalTypeVisitorTests.cs index 20f9cf61..00fd22c2 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DecimalTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DecimalTypeVisitorTests.cs @@ -6,8 +6,10 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Any; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -22,6 +24,7 @@ public class DecimalTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +32,8 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new DecimalTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); + } [DataTestMethod] @@ -78,7 +83,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(decimal)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -94,7 +99,7 @@ public void Given_MinLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(decimal)); var attribute = new MinLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("number"); @@ -110,7 +115,7 @@ public void Given_MaxLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(decimal)); var attribute = new MaxLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("number"); @@ -126,7 +131,7 @@ public void Given_RangeAttribute_When_Visit_Invoked_Then_It_Should_Return_Result var type = new KeyValuePair<string, Type>(name, typeof(decimal)); var attribute = new RangeAttribute(min, max); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("number"); @@ -142,7 +147,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(decimal)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -159,7 +164,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(decimal)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -176,7 +181,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(decimal)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -193,7 +198,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(decimal)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -214,7 +219,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("number", "double")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(decimal), this._strategy); + var result = this._visitor.PayloadVisit(typeof(decimal), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DictionaryObjectTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DictionaryObjectTypeVisitorTests.cs index 29615b4a..1e4a6c48 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DictionaryObjectTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DictionaryObjectTypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; @@ -24,6 +25,7 @@ public class DictionaryObjectTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -31,6 +33,7 @@ public void Init() this._visitorCollection = VisitorCollection.CreateInstance(); this._visitor = new DictionaryObjectTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -101,7 +104,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(Type dict var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, dictionaryType); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -127,7 +130,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(Dictionary<string, string>)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -144,7 +147,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(Dictionary<string, string>)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -174,7 +177,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow(typeof(KeyValuePair<string, FakeModel>), "object", null, "object", true, "fakeModel")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(Type dictionaryType, string dataType, string dataFormat, string additionalPropertyType, bool reference, string referenceId) { - var result = this._visitor.PayloadVisit(dictionaryType, this._strategy); + var result = this._visitor.PayloadVisit(dictionaryType, this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); @@ -203,7 +206,7 @@ public void Given_Alias_Type_When_Visit_Invoked_Then_It_Should_Return_All_Sub_Sc var acceptor = new OpenApiSchemaAcceptor(); var key = type.GetOpenApiReferenceId(type.IsOpenApiDictionary(), type.IsOpenApiArray(), this._strategy); - this._visitor.Visit(acceptor, new KeyValuePair<string, Type>(key, type), this._strategy); + this._visitor.Visit(acceptor, new KeyValuePair<string, Type>(key, type), this._strategy, this._options.UseFullName); acceptor.RootSchemas.Count.Should().Be(schemaTypes.Length); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DoubleTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DoubleTypeVisitorTests.cs index 15cb5837..6e5ca074 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DoubleTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/DoubleTypeVisitorTests.cs @@ -6,8 +6,10 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Any; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -22,6 +24,7 @@ public class DoubleTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +32,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new DoubleTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -78,7 +82,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(double)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -94,7 +98,7 @@ public void Given_MinLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(double)); var attribute = new MinLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("number"); @@ -110,7 +114,7 @@ public void Given_MaxLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(double)); var attribute = new MaxLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("number"); @@ -126,7 +130,7 @@ public void Given_RangeAttribute_When_Visit_Invoked_Then_It_Should_Return_Result var type = new KeyValuePair<string, Type>(name, typeof(double)); var attribute = new RangeAttribute(min, max); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("number"); @@ -142,7 +146,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(double)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -159,7 +163,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(double)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -176,7 +180,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(double)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -193,7 +197,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(double)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -214,7 +218,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("number", "double")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(double), this._strategy); + var result = this._visitor.PayloadVisit(typeof(double), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ExceptionTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ExceptionTypeVisitorTests.cs index 2959d9de..1e1124ab 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ExceptionTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ExceptionTypeVisitorTests.cs @@ -5,8 +5,10 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Any; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -21,6 +23,7 @@ public class ExceptionTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -28,6 +31,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new ExceptionTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } @@ -106,7 +110,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(Type list var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, listType); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -121,7 +125,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(List<string>)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -138,7 +142,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(List<string>)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/GuidObjectTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/GuidObjectTypeVisitorTests.cs index 45e7dc66..ef0d045f 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/GuidObjectTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/GuidObjectTypeVisitorTests.cs @@ -5,8 +5,10 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Any; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -21,6 +23,7 @@ public class GuidObjectTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -28,6 +31,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new GuidObjectTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -77,7 +81,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(Guid)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -92,7 +96,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(Guid)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -109,7 +113,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(Guid)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -126,7 +130,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(Guid)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -143,7 +147,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(Guid)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -164,7 +168,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("string", "uuid")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(Guid), this._strategy); + var result = this._visitor.PayloadVisit(typeof(Guid), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int16EnumTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int16EnumTypeVisitorTests.cs index f8155c66..60ebe96d 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int16EnumTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int16EnumTypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; @@ -23,6 +24,7 @@ public class Int16EnumTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -30,6 +32,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new Int16EnumTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -80,7 +83,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var type = new KeyValuePair<string, Type>(name, typeof(FakeShortEnum)); var enums = enumType.ToOpenApiInt16Collection(); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -104,7 +107,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(FakeShortEnum)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -121,7 +124,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(FakeShortEnum)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -138,7 +141,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(FakeShortEnum)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -155,7 +158,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(FakeShortEnum)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -189,7 +192,7 @@ public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(st { var enums = enumType.ToOpenApiInt16Collection(); - var result = this._visitor.PayloadVisit(typeof(FakeShortEnum), this._strategy); + var result = this._visitor.PayloadVisit(typeof(FakeShortEnum), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int16TypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int16TypeVisitorTests.cs index ca6f92fd..0e3761fd 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int16TypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int16TypeVisitorTests.cs @@ -6,8 +6,10 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Any; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -22,6 +24,7 @@ public class Int16TypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +32,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new Int16TypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -78,7 +82,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(short)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -94,7 +98,7 @@ public void Given_MinLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(short)); var attribute = new MinLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -110,7 +114,7 @@ public void Given_MaxLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(short)); var attribute = new MaxLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -126,7 +130,7 @@ public void Given_RangeAttribute_When_Visit_Invoked_Then_It_Should_Return_Result var type = new KeyValuePair<string, Type>(name, typeof(short)); var attribute = new RangeAttribute(min, max); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -142,7 +146,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(short)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -159,7 +163,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(short)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -176,7 +180,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(short)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -193,7 +197,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(short)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -214,7 +218,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("integer", "int32")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(short), this._strategy); + var result = this._visitor.PayloadVisit(typeof(short), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int32EnumTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int32EnumTypeVisitorTests.cs index e9dad54a..a707a9f6 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int32EnumTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int32EnumTypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; @@ -23,6 +24,7 @@ public class Int32EnumTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -30,6 +32,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new Int32EnumTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -80,7 +83,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var type = new KeyValuePair<string, Type>(name, typeof(FakeIntEnum)); var enums = enumType.ToOpenApiInt32Collection(); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -104,7 +107,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(FakeIntEnum)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -121,7 +124,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(FakeIntEnum)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -138,7 +141,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(FakeIntEnum)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -155,7 +158,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(FakeIntEnum)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -189,7 +192,7 @@ public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(st { var enums = enumType.ToOpenApiInt32Collection(); - var result = this._visitor.PayloadVisit(typeof(FakeIntEnum), this._strategy); + var result = this._visitor.PayloadVisit(typeof(FakeIntEnum), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int32TypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int32TypeVisitorTests.cs index b8a7cad7..cdd63b3b 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int32TypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int32TypeVisitorTests.cs @@ -6,8 +6,10 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Any; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -22,6 +24,7 @@ public class Int32TypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +32,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new Int32TypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -78,7 +82,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(int)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -94,7 +98,7 @@ public void Given_MinLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(int)); var attribute = new MinLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -110,7 +114,7 @@ public void Given_MaxLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(int)); var attribute = new MaxLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -126,7 +130,7 @@ public void Given_RangeAttribute_When_Visit_Invoked_Then_It_Should_Return_Result var type = new KeyValuePair<string, Type>(name, typeof(int)); var attribute = new RangeAttribute(min, max); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -142,7 +146,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(int)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -159,7 +163,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(int)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -176,7 +180,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(int)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -193,7 +197,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(int)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -214,7 +218,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("integer", "int32")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(int), this._strategy); + var result = this._visitor.PayloadVisit(typeof(int), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int64EnumTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int64EnumTypeVisitorTests.cs index 53e264bb..fed42af2 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int64EnumTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int64EnumTypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; @@ -23,6 +24,7 @@ public class Int64EnumTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -30,6 +32,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new Int64EnumTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -80,7 +83,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var type = new KeyValuePair<string, Type>(name, typeof(FakeLongEnum)); var enums = enumType.ToOpenApiInt64Collection(); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -104,7 +107,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(FakeLongEnum)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -121,7 +124,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(FakeLongEnum)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -138,7 +141,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(FakeLongEnum)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -155,7 +158,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(FakeLongEnum)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -189,7 +192,7 @@ public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(st { var enums = enumType.ToOpenApiInt64Collection(); - var result = this._visitor.PayloadVisit(typeof(FakeLongEnum), this._strategy); + var result = this._visitor.PayloadVisit(typeof(FakeLongEnum), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int64TypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int64TypeVisitorTests.cs index 0ea55985..53b2dadc 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int64TypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/Int64TypeVisitorTests.cs @@ -14,7 +14,8 @@ using Newtonsoft.Json.Serialization; using System.ComponentModel.DataAnnotations; - +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; + namespace Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Visitors { [TestClass] @@ -23,13 +24,15 @@ public class Int64TypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() { this._visitorCollection = new VisitorCollection(); this._visitor = new Int64TypeVisitor(this._visitorCollection); - this._strategy = new CamelCaseNamingStrategy(); + this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -79,7 +82,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(long)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -95,7 +98,7 @@ public void Given_MinLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(long)); var attribute = new MinLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -111,7 +114,7 @@ public void Given_MaxLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(long)); var attribute = new MaxLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -127,7 +130,7 @@ public void Given_RangeAttribute_When_Visit_Invoked_Then_It_Should_Return_Result var type = new KeyValuePair<string, Type>(name, typeof(long)); var attribute = new RangeAttribute(min, max); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -143,7 +146,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(long)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -160,7 +163,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(long)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -177,7 +180,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(long)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -194,7 +197,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(long)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -215,7 +218,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("integer", "int64")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(long), this._strategy); + var result = this._visitor.PayloadVisit(typeof(long), this._strategy,this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/JObjectTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/JObjectTypeVisitorTests.cs index c4cd7696..6c50123d 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/JObjectTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/JObjectTypeVisitorTests.cs @@ -5,6 +5,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -23,13 +24,15 @@ public class JObjectTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() { this._visitorCollection = new VisitorCollection(); this._visitor = new JObjectTypeVisitor(this._visitorCollection); - this._strategy = new CamelCaseNamingStrategy(); + this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -84,7 +87,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(Type obje var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, objectType); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -99,7 +102,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(JObject)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -116,7 +119,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(JObject)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -138,7 +141,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow(typeof(JToken), "object", null)] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(Type objectType, string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(objectType, this._strategy); + var result = this._visitor.PayloadVisit(objectType, this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ListObjectTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ListObjectTypeVisitorTests.cs index 510fa26b..60d67e26 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ListObjectTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ListObjectTypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; @@ -24,6 +25,7 @@ public class ListObjectTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -31,6 +33,7 @@ public void Init() this._visitorCollection = VisitorCollection.CreateInstance(); this._visitor = new ListObjectTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -116,7 +119,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(Type list var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, listType); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -158,7 +161,7 @@ public void Given_MinLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, listType); var attribute = new MinLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("array"); @@ -189,7 +192,7 @@ public void Given_MaxLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, listType); var attribute = new MaxLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("array"); @@ -204,7 +207,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(List<string>)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -221,7 +224,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(List<string>)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -278,7 +281,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow(typeof(ISet<FakeModel>), "array", null, "object", true, "fakeModel")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(Type listType, string dataType, string dataFormat, string itemType, bool reference, string referenceId) { - var result = this._visitor.PayloadVisit(listType, this._strategy); + var result = this._visitor.PayloadVisit(listType, this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); @@ -309,7 +312,7 @@ public void Given_Alias_Type_When_Visit_Invoked_Then_It_Should_Return_All_Sub_Sc var acceptor = new OpenApiSchemaAcceptor(); var key = type.GetOpenApiReferenceId(type.IsOpenApiDictionary(), type.IsOpenApiArray(), this._strategy); - this._visitor.Visit(acceptor, new KeyValuePair<string, Type>(key, type), this._strategy); + this._visitor.Visit(acceptor, new KeyValuePair<string, Type>(key, type), this._strategy, this._options.UseFullName); acceptor.RootSchemas.Count.Should().Be(schemaTypes.Length); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/NullableObjectTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/NullableObjectTypeVisitorTests.cs index ae9a16de..01bc083d 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/NullableObjectTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/NullableObjectTypeVisitorTests.cs @@ -5,6 +5,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -21,6 +22,7 @@ public class NullableObjectTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -28,6 +30,7 @@ public void Init() this._visitorCollection = VisitorCollection.CreateInstance(); this._visitor = new NullableObjectTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -79,7 +82,7 @@ public void Given_DataTypeAttribute_When_Visit_Invoked_Then_It_Should_Return_Res var type = new KeyValuePair<string, Type>(name, typeof(DateTime?)); var attribute = new DataTypeAttribute(objectType); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -95,7 +98,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(Type obje var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, objectType); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -111,7 +114,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(DateTime?)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -129,7 +132,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, objectType); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -146,7 +149,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(DateTime?)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -170,7 +173,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow(typeof(int?), "integer", "int32", true)] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(Type objectType, string dataType, string dataFormat, bool schemaNullable) { - var result = this._visitor.PayloadVisit(objectType, this._strategy); + var result = this._visitor.PayloadVisit(objectType, this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ObjectTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ObjectTypeVisitorTests.cs index ce0c40c2..c6422edd 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ObjectTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/ObjectTypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; @@ -25,6 +26,7 @@ public class ObjectTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -32,6 +34,7 @@ public void Init() this._visitorCollection = VisitorCollection.CreateInstance(); this._visitor = new ObjectTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -94,7 +97,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(Type obje var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, objectType); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -119,7 +122,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(FakeModel)); var attribute = new OpenApiPropertyAttribute() { Description = description, Nullable = nullable }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -133,7 +136,7 @@ public void Given_ObjectModel_With_NewtonsoftJsonPropertyAttribute_When_Visit_In var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(FakeModel)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas[name].Required.Count.Should().Be(requiredCount); acceptor.Schemas[name].Required.Should().Contain("fakeProperty"); @@ -153,7 +156,7 @@ public void Given_RecursiveModel_With_NewtonsoftJsonPropertyAttribute_When_Visit var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(FakeRecursiveModel)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas[name].Required.Count.Should().Be(requiredCount); acceptor.Schemas[name].Required.Should().Contain("stringValue"); @@ -176,7 +179,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(FakeModel)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -196,7 +199,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow(typeof(FakeModel), "object", null)] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(Type objectType, string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(objectType, this._strategy); + var result = this._visitor.PayloadVisit(objectType, this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); @@ -210,7 +213,7 @@ public void Given_Alias_Type_When_Visit_Invoked_Then_It_Should_Return_All_Sub_Sc var acceptor = new OpenApiSchemaAcceptor(); var key = type.GetOpenApiReferenceId(type.IsOpenApiDictionary(), type.IsOpenApiArray(), this._strategy); - this._visitor.Visit(acceptor, new KeyValuePair<string, Type>(key, type), this._strategy); + this._visitor.Visit(acceptor, new KeyValuePair<string, Type>(key, type), this._strategy, this._options.UseFullName); acceptor.RootSchemas.Count.Should().Be(schemaTypes.Length); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/RecursiveObjectTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/RecursiveObjectTypeVisitorTests.cs index 497b34e5..265ff66a 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/RecursiveObjectTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/RecursiveObjectTypeVisitorTests.cs @@ -5,6 +5,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; @@ -23,6 +24,7 @@ public class RecursiveObjectTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -30,6 +32,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new RecursiveObjectTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -79,7 +82,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(Type obje var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, objectType); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -100,7 +103,7 @@ public void Given_NewtonsoftJsonPropertyAttribute_When_Visit_Invoked_Then_It_Sho var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(FakeRecursiveModel)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas[name].Required.Count.Should().Be(requiredCount); acceptor.Schemas[name].Required.Should().Contain("stringValue"); @@ -116,7 +119,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(FakeRecursiveModel)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -133,7 +136,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(FakeRecursiveModel)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -153,7 +156,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow(typeof(FakeRecursiveModel), "object", null)] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(Type objectType, string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(objectType, this._strategy); + var result = this._visitor.PayloadVisit(objectType, this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/SingleTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/SingleTypeVisitorTests.cs index 6cba900e..66ed0fd3 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/SingleTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/SingleTypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -22,6 +23,7 @@ public class SingleTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +31,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new SingleTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -78,7 +81,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(float)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -94,7 +97,7 @@ public void Given_MinLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(float)); var attribute = new MinLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("number"); @@ -110,7 +113,7 @@ public void Given_MaxLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(float)); var attribute = new MaxLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("number"); @@ -126,7 +129,7 @@ public void Given_RangeAttribute_When_Visit_Invoked_Then_It_Should_Return_Result var type = new KeyValuePair<string, Type>(name, typeof(float)); var attribute = new RangeAttribute(min, max); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("number"); @@ -142,7 +145,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(float)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -159,7 +162,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(float)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -176,7 +179,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(float)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -193,7 +196,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(float)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -214,7 +217,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("number", "float")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(float), this._strategy); + var result = this._visitor.PayloadVisit(typeof(float), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/StringEnumTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/StringEnumTypeVisitorTests.cs index 57bb377e..24ab7987 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/StringEnumTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/StringEnumTypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; @@ -23,6 +24,7 @@ public class StringEnumTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -30,6 +32,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new StringEnumTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -80,7 +83,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var type = new KeyValuePair<string, Type>(name, typeof(FakeStringEnum)); var enums = enumType.ToOpenApiStringCollection(); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -104,7 +107,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(FakeStringEnum)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -121,7 +124,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(FakeStringEnum)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -138,7 +141,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(FakeLongEnum)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -155,7 +158,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(FakeStringEnum)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -189,7 +192,7 @@ public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(st { var enums = enumType.ToOpenApiStringCollection(this._strategy); - var result = this._visitor.PayloadVisit(typeof(FakeStringEnum), this._strategy); + var result = this._visitor.PayloadVisit(typeof(FakeStringEnum), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/StringTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/StringTypeVisitorTests.cs index 9e0904e3..dd8d8b42 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/StringTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/StringTypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -22,6 +23,7 @@ public class StringTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +31,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new StringTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -78,7 +81,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(string)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -94,7 +97,7 @@ public void Given_StringLengthAttribute_When_Visit_Invoked_Then_It_Should_Return var type = new KeyValuePair<string, Type>(name, typeof(DateTime)); var attribute = new StringLengthAttribute(max) { MinimumLength = min}; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("string"); @@ -112,7 +115,7 @@ public void Given_RegularExpressionAttribute_When_Visit_Invoked_Then_It_Should_R var type = new KeyValuePair<string, Type>(name, typeof(DateTime)); var attribute = new RegularExpressionAttribute(pattern); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("string"); @@ -127,7 +130,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(string)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -144,7 +147,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(string)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -165,7 +168,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("string", null)] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(string), this._strategy); + var result = this._visitor.PayloadVisit(typeof(string), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/TimeSpanObjectTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/TimeSpanObjectTypeVisitorTests.cs index e022dcef..a9c85c8e 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/TimeSpanObjectTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/TimeSpanObjectTypeVisitorTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -22,6 +23,7 @@ public class TimeSpanObjectTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +31,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new TimeSpanObjectTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -66,7 +69,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(TimeSpan)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -81,7 +84,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(TimeSpan)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -98,7 +101,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(TimeSpan)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -115,7 +118,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(TimeSpan)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -132,7 +135,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(TimeSpan)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -153,7 +156,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("string", "timespan")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Null(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(TimeSpan), this._strategy); + var result = this._visitor.PayloadVisit(typeof(TimeSpan), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/TypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/TypeVisitorTests.cs index 0690dade..bab1ffaf 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/TypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/TypeVisitorTests.cs @@ -3,6 +3,7 @@ using FluentAssertions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests.Fakes; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; using Microsoft.OpenApi.Models; @@ -18,6 +19,7 @@ public class TypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -25,6 +27,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new FakeTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -90,7 +93,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow(typeof(string), default(OpenApiSchema))] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Null(Type type, OpenApiSchema expected) { - var result = this._visitor.PayloadVisit(type, this._strategy); + var result = this._visitor.PayloadVisit(type, this._strategy, this._options.UseFullName); result.Should().Be(expected); } diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt16TypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt16TypeVisitorTests.cs index 498cf59c..470492a6 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt16TypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt16TypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -22,6 +23,7 @@ public class UInt16TypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +31,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new UInt16TypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -81,7 +84,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(ushort)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -97,7 +100,7 @@ public void Given_MinLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(ushort)); var attribute = new MinLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -113,7 +116,7 @@ public void Given_MaxLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(ushort)); var attribute = new MaxLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -129,7 +132,7 @@ public void Given_RangeAttribute_When_Visit_Invoked_Then_It_Should_Return_Result var type = new KeyValuePair<string, Type>(name, typeof(ushort)); var attribute = new RangeAttribute(min, max); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -145,7 +148,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(ushort)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -162,7 +165,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(ushort)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -179,7 +182,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(ushort)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -196,7 +199,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(ushort)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -217,7 +220,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("integer", "int32")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(ushort), this._strategy); + var result = this._visitor.PayloadVisit(typeof(ushort), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt32TypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt32TypeVisitorTests.cs index 0e4a4f15..9766c241 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt32TypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt32TypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -22,6 +23,7 @@ public class UInt32TypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +31,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new UInt32TypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -81,7 +84,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(uint)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -97,7 +100,7 @@ public void Given_MinLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(uint)); var attribute = new MinLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -113,7 +116,7 @@ public void Given_MaxLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(uint)); var attribute = new MaxLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -129,7 +132,7 @@ public void Given_RangeAttribute_When_Visit_Invoked_Then_It_Should_Return_Result var type = new KeyValuePair<string, Type>(name, typeof(uint)); var attribute = new RangeAttribute(min, max); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -145,7 +148,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(uint)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -162,7 +165,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(uint)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -179,7 +182,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(uint)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -196,7 +199,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(uint)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -217,7 +220,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("integer", "int32")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(uint), this._strategy); + var result = this._visitor.PayloadVisit(typeof(uint), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt64TypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt64TypeVisitorTests.cs index 5495dcdd..d8c4b524 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt64TypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UInt64TypeVisitorTests.cs @@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -22,6 +23,7 @@ public class UInt64TypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -29,6 +31,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new UInt64TypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -81,7 +84,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(ulong)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -97,7 +100,7 @@ public void Given_MinLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(ulong)); var attribute = new MinLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -113,7 +116,7 @@ public void Given_MaxLengthAttribute_When_Visit_Invoked_Then_It_Should_Return_Re var type = new KeyValuePair<string, Type>(name, typeof(ulong)); var attribute = new MaxLengthAttribute(length); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -129,7 +132,7 @@ public void Given_RangeAttribute_When_Visit_Invoked_Then_It_Should_Return_Result var type = new KeyValuePair<string, Type>(name, typeof(ulong)); var attribute = new RangeAttribute(min, max); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be("integer"); @@ -145,7 +148,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(ulong)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -162,7 +165,7 @@ public void Given_OpenApiPropertyAttribute_With_Default_When_Visit_Invoked_Then_ var type = new KeyValuePair<string, Type>(name, typeof(ulong)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Default = @default, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().NotBeNull(); @@ -179,7 +182,7 @@ public void Given_OpenApiPropertyAttribute_Without_Default_When_Visit_Invoked_Th var type = new KeyValuePair<string, Type>(name, typeof(ulong)); var attribute = new OpenApiPropertyAttribute() { Nullable = nullable, Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(nullable); acceptor.Schemas[name].Default.Should().BeNull(); @@ -196,7 +199,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(ulong)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -217,7 +220,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("integer", "int64")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(ulong), this._strategy); + var result = this._visitor.PayloadVisit(typeof(ulong), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat); diff --git a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UriTypeVisitorTests.cs b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UriTypeVisitorTests.cs index 9a6a5d4e..56eb2704 100644 --- a/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UriTypeVisitorTests.cs +++ b/test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Visitors/UriTypeVisitorTests.cs @@ -5,6 +5,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; +using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions; using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors; @@ -21,6 +22,7 @@ public class UriTypeVisitorTests private VisitorCollection _visitorCollection; private IVisitor _visitor; private NamingStrategy _strategy; + private OpenApiConfigurationOptions _options; [TestInitialize] public void Init() @@ -28,6 +30,7 @@ public void Init() this._visitorCollection = new VisitorCollection(); this._visitor = new UriTypeVisitor(this._visitorCollection); this._strategy = new CamelCaseNamingStrategy(); + this._options = new OpenApiConfigurationOptions(); } [DataTestMethod] @@ -77,7 +80,7 @@ public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(string da var acceptor = new OpenApiSchemaAcceptor(); var type = new KeyValuePair<string, Type>(name, typeof(Uri)); - this._visitor.Visit(acceptor, type, this._strategy); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName); acceptor.Schemas.Should().ContainKey(name); acceptor.Schemas[name].Type.Should().Be(dataType); @@ -92,7 +95,7 @@ public void Given_OpenApiPropertyAttribute_When_Visit_Invoked_Then_It_Should_Ret var type = new KeyValuePair<string, Type>(name, typeof(Uri)); var attribute = new OpenApiPropertyAttribute() { Description = description }; - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Nullable.Should().Be(false); acceptor.Schemas[name].Default.Should().BeNull(); @@ -109,7 +112,7 @@ public void Given_OpenApiSchemaVisibilityAttribute_When_Visit_Invoked_Then_It_Sh var type = new KeyValuePair<string, Type>(name, typeof(Uri)); var attribute = new OpenApiSchemaVisibilityAttribute(visibility); - this._visitor.Visit(acceptor, type, this._strategy, attribute); + this._visitor.Visit(acceptor, type, this._strategy, this._options.UseFullName, attribute); acceptor.Schemas[name].Extensions.Should().ContainKey("x-ms-visibility"); acceptor.Schemas[name].Extensions["x-ms-visibility"].Should().BeOfType<OpenApiString>(); @@ -130,7 +133,7 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result( [DataRow("string", "uri")] public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(string dataType, string dataFormat) { - var result = this._visitor.PayloadVisit(typeof(Uri), this._strategy); + var result = this._visitor.PayloadVisit(typeof(Uri), this._strategy, this._options.UseFullName); result.Type.Should().Be(dataType); result.Format.Should().Be(dataFormat);