diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5bdb1b2704..5bfafc6fce 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -24,9 +24,6 @@ updates: - package-ecosystem: nuget directory: "/" groups: - coverlet: - patterns: - - coverlet* Microsoft.OpenApi: patterns: - Microsoft.OpenApi* diff --git a/Directory.Build.props b/Directory.Build.props index 4b891fbba2..d11acd26d5 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -58,7 +58,7 @@ - + true diff --git a/Directory.Packages.props b/Directory.Packages.props index d4cd8fa690..8f3de6c2f3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -2,7 +2,7 @@ - + @@ -23,15 +23,15 @@ - + - + - - - - + + + + diff --git a/perf/Swashbuckle.AspNetCore.Benchmarks/Swashbuckle.AspNetCore.Benchmarks.csproj b/perf/Swashbuckle.AspNetCore.Benchmarks/Swashbuckle.AspNetCore.Benchmarks.csproj index 2a844fa0aa..83881de8e9 100644 --- a/perf/Swashbuckle.AspNetCore.Benchmarks/Swashbuckle.AspNetCore.Benchmarks.csproj +++ b/perf/Swashbuckle.AspNetCore.Benchmarks/Swashbuckle.AspNetCore.Benchmarks.csproj @@ -4,6 +4,9 @@ Exe net8.0 + + + diff --git a/perf/Swashbuckle.AspNetCore.Benchmarks/XmlCommentsBenchmark.cs b/perf/Swashbuckle.AspNetCore.Benchmarks/XmlCommentsBenchmark.cs index 380b55d7bc..51dd048148 100644 --- a/perf/Swashbuckle.AspNetCore.Benchmarks/XmlCommentsBenchmark.cs +++ b/perf/Swashbuckle.AspNetCore.Benchmarks/XmlCommentsBenchmark.cs @@ -101,7 +101,7 @@ public void Setup() { Schema = new() { - Type = "string", + Type = JsonSchemaTypes.String, Description = "schema-level description", }, }; @@ -120,7 +120,7 @@ public void Setup() { Schema = new() { - Type = "string", + Type = JsonSchemaTypes.String, }, }, }, diff --git a/src/Shared/JsonSchemaTypes.cs b/src/Shared/JsonSchemaTypes.cs new file mode 100644 index 0000000000..7285f9e9e1 --- /dev/null +++ b/src/Shared/JsonSchemaTypes.cs @@ -0,0 +1,12 @@ +namespace Swashbuckle.AspNetCore; + +internal static class JsonSchemaTypes +{ + public const string Array = "array"; + public const string Boolean = "boolean"; + public const string Integer = "integer"; + public const string Number = "number"; + public const string Null = "null"; + public const string Object = "object"; + public const string String = "string"; +} diff --git a/src/Swashbuckle.AspNetCore.Annotations/AnnotationsOperationFilter.cs b/src/Swashbuckle.AspNetCore.Annotations/AnnotationsOperationFilter.cs index 1d0e54eb7a..b2a86bf14e 100644 --- a/src/Swashbuckle.AspNetCore.Annotations/AnnotationsOperationFilter.cs +++ b/src/Swashbuckle.AspNetCore.Annotations/AnnotationsOperationFilter.cs @@ -65,9 +65,7 @@ private static void ApplySwaggerOperationAttribute( if (swaggerOperationAttribute.Tags != null) { - operation.Tags = swaggerOperationAttribute.Tags - .Select(tagName => new OpenApiTag { Name = tagName }) - .ToList(); + operation.Tags = [.. swaggerOperationAttribute.Tags.Select(tagName => new OpenApiTag { Name = tagName })]; } } diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/PublicAPI.Shipped.txt index 11f734bd29..516872bbe4 100644 --- a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/PublicAPI.Shipped.txt +++ b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/PublicAPI.Shipped.txt @@ -49,8 +49,6 @@ Swashbuckle.AspNetCore.Annotations.SwaggerRequestBodyAttribute.SwaggerRequestBod Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.ContentTypes.get -> string[] Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.ContentTypes.set -> void -Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.get -> string -Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.set -> void Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.SwaggerResponseAttribute(int statusCode, string description = null, System.Type type = null) -> void Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.SwaggerResponseAttribute(int statusCode, string description = null, System.Type type = null, params string[] contentTypes) -> void Swashbuckle.AspNetCore.Annotations.SwaggerSchemaAttribute diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net6.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net6.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..3b123b7bc6 --- /dev/null +++ b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net6.0/PublicAPI.Shipped.txt @@ -0,0 +1,2 @@ +Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.get -> string +Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.set -> void diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net6.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net8.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net8.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..3b123b7bc6 --- /dev/null +++ b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net8.0/PublicAPI.Shipped.txt @@ -0,0 +1,2 @@ +Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.get -> string +Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.set -> void diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net8.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net9.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net9.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..3b123b7bc6 --- /dev/null +++ b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net9.0/PublicAPI.Shipped.txt @@ -0,0 +1,2 @@ +Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.get -> string +Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.set -> void diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net9.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net9.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..3b123b7bc6 --- /dev/null +++ b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt @@ -0,0 +1,2 @@ +Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.get -> string +Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.set -> void diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Swashbuckle.AspNetCore.Annotations/Swashbuckle.AspNetCore.Annotations.csproj b/src/Swashbuckle.AspNetCore.Annotations/Swashbuckle.AspNetCore.Annotations.csproj index c5ae6716cd..beee7ab35d 100644 --- a/src/Swashbuckle.AspNetCore.Annotations/Swashbuckle.AspNetCore.Annotations.csproj +++ b/src/Swashbuckle.AspNetCore.Annotations/Swashbuckle.AspNetCore.Annotations.csproj @@ -20,5 +20,9 @@ + + + + diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonAllOfValidator.cs b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonAllOfValidator.cs index ff596f9b4a..eb10195aba 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonAllOfValidator.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonAllOfValidator.cs @@ -7,7 +7,7 @@ namespace Swashbuckle.AspNetCore.ApiTesting { public class JsonAllOfValidator(JsonValidator jsonValidator) : IJsonValidator { - private JsonValidator _jsonValidator = jsonValidator; + private readonly JsonValidator _jsonValidator = jsonValidator; public bool CanValidate(OpenApiSchema schema) => schema.AllOf != null && schema.AllOf.Any(); diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonAnyOfValidator.cs b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonAnyOfValidator.cs index 411b4d3f0a..fa70e91f03 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonAnyOfValidator.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonAnyOfValidator.cs @@ -7,7 +7,7 @@ namespace Swashbuckle.AspNetCore.ApiTesting { public class JsonAnyOfValidator(JsonValidator jsonValidator) : IJsonValidator { - private JsonValidator _jsonValidator = jsonValidator; + private readonly JsonValidator _jsonValidator = jsonValidator; public bool CanValidate(OpenApiSchema schema) => schema.AnyOf != null && schema.AnyOf.Any(); diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonArrayValidator.cs b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonArrayValidator.cs index 72978e3b46..c2c92e4ce5 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonArrayValidator.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonArrayValidator.cs @@ -9,7 +9,7 @@ public class JsonArrayValidator(IJsonValidator jsonValidator) : IJsonValidator { private readonly IJsonValidator _jsonValidator = jsonValidator; - public bool CanValidate(OpenApiSchema schema) => schema.Type == "array"; + public bool CanValidate(OpenApiSchema schema) => schema.Type == JsonSchemaTypes.Array; public bool Validate( OpenApiSchema schema, diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonBooleanValidator.cs b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonBooleanValidator.cs index 2277f95357..4400466068 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonBooleanValidator.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonBooleanValidator.cs @@ -6,7 +6,7 @@ namespace Swashbuckle.AspNetCore.ApiTesting { public class JsonBooleanValidator : IJsonValidator { - public bool CanValidate(OpenApiSchema schema) => schema.Type == "boolean"; + public bool CanValidate(OpenApiSchema schema) => schema.Type == JsonSchemaTypes.Boolean; public bool Validate( OpenApiSchema schema, diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonNullValidator.cs b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonNullValidator.cs index 0472225852..a36dbc088a 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonNullValidator.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonNullValidator.cs @@ -6,7 +6,7 @@ namespace Swashbuckle.AspNetCore.ApiTesting { public class JsonNullValidator : IJsonValidator { - public bool CanValidate(OpenApiSchema schema) => schema.Type == "null"; + public bool CanValidate(OpenApiSchema schema) => schema.Type == JsonSchemaTypes.Null; public bool Validate( OpenApiSchema schema, diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonNumberValidator.cs b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonNumberValidator.cs index 85b6151621..27a95d3f3c 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonNumberValidator.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonNumberValidator.cs @@ -7,7 +7,7 @@ namespace Swashbuckle.AspNetCore.ApiTesting { public class JsonNumberValidator : IJsonValidator { - public bool CanValidate(OpenApiSchema schema) => schema.Type == "number"; + public bool CanValidate(OpenApiSchema schema) => schema.Type == JsonSchemaTypes.Number; public bool Validate( OpenApiSchema schema, diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonObjectValidator.cs b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonObjectValidator.cs index 6a7787cd97..69acad62e5 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonObjectValidator.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonObjectValidator.cs @@ -9,7 +9,7 @@ public class JsonObjectValidator(IJsonValidator jsonValidator) : IJsonValidator { private readonly IJsonValidator _jsonValidator = jsonValidator; - public bool CanValidate(OpenApiSchema schema) => schema.Type == "object"; + public bool CanValidate(OpenApiSchema schema) => schema.Type == JsonSchemaTypes.Object; public bool Validate( OpenApiSchema schema, diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonStringValidator.cs b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonStringValidator.cs index 69d1b95f94..9a47d1c7bc 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonStringValidator.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/JsonValidation/JsonStringValidator.cs @@ -8,7 +8,7 @@ namespace Swashbuckle.AspNetCore.ApiTesting { public class JsonStringValidator : IJsonValidator { - public bool CanValidate(OpenApiSchema schema) => schema.Type == "string"; + public bool CanValidate(OpenApiSchema schema) => schema.Type == JsonSchemaTypes.String; public bool Validate( OpenApiSchema schema, diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/OpenApiSchemaExtensions.cs b/src/Swashbuckle.AspNetCore.ApiTesting/OpenApiSchemaExtensions.cs index ecd44e4a6b..317b6d06f5 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/OpenApiSchemaExtensions.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/OpenApiSchemaExtensions.cs @@ -11,37 +11,47 @@ internal static bool TryParse(this OpenApiSchema schema, string stringValue, out { typedValue = null; - if (schema.Type == "integer" && schema.Format == "int64" && long.TryParse(stringValue, out long longValue)) + if (schema.Type == JsonSchemaTypes.Integer && schema.Format == "int64" && long.TryParse(stringValue, out long longValue)) + { typedValue = longValue; - - else if (schema.Type == "integer" && int.TryParse(stringValue, out int intValue)) + } + else if (schema.Type == JsonSchemaTypes.Integer && int.TryParse(stringValue, out int intValue)) + { typedValue = intValue; - - else if (schema.Type == "number" && schema.Format == "double" && double.TryParse(stringValue, out double doubleValue)) + } + else if (schema.Type == JsonSchemaTypes.Number && schema.Format == "double" && double.TryParse(stringValue, out double doubleValue)) + { typedValue = doubleValue; - - else if (schema.Type == "number" && float.TryParse(stringValue, out float floatValue)) + } + else if (schema.Type == JsonSchemaTypes.Number && float.TryParse(stringValue, out float floatValue)) + { typedValue = floatValue; - - else if (schema.Type == "string" && schema.Format == "byte" && byte.TryParse(stringValue, out byte byteValue)) + } + else if (schema.Type == JsonSchemaTypes.String && schema.Format == "byte" && byte.TryParse(stringValue, out byte byteValue)) + { typedValue = byteValue; - - else if (schema.Type == "boolean" && bool.TryParse(stringValue, out bool boolValue)) + } + else if (schema.Type == JsonSchemaTypes.Boolean && bool.TryParse(stringValue, out bool boolValue)) + { typedValue = boolValue; - - else if (schema.Type == "string" && schema.Format == "date" && DateTime.TryParse(stringValue, out DateTime dateValue)) + } + else if (schema.Type == JsonSchemaTypes.String && schema.Format == "date" && DateTime.TryParse(stringValue, out DateTime dateValue)) + { typedValue = dateValue; - - else if (schema.Type == "string" && schema.Format == "date-time" && DateTime.TryParse(stringValue, out DateTime dateTimeValue)) + } + else if (schema.Type == JsonSchemaTypes.String && schema.Format == "date-time" && DateTime.TryParse(stringValue, out DateTime dateTimeValue)) + { typedValue = dateTimeValue; - - else if (schema.Type == "string" && schema.Format == "uuid" && Guid.TryParse(stringValue, out Guid uuidValue)) + } + else if (schema.Type == JsonSchemaTypes.String && schema.Format == "uuid" && Guid.TryParse(stringValue, out Guid uuidValue)) + { typedValue = uuidValue; - - else if (schema.Type == "string") + } + else if (schema.Type == JsonSchemaTypes.String) + { typedValue = stringValue; - - else if (schema.Type == "array") + } + else if (schema.Type == JsonSchemaTypes.Array) { var arrayValue = (schema.Items == null) ? stringValue.Split(',') @@ -59,10 +69,14 @@ internal static bool TryParse(this OpenApiSchema schema, string stringValue, out internal static string TypeIdentifier(this OpenApiSchema schema) { - var idBuilder = new StringBuilder(schema.Type); + var idBuilder = new StringBuilder(); + + idBuilder.Append(schema.Type); - if (schema.Type == "array" && schema.Items != null) + if (schema.Type == JsonSchemaTypes.Array && schema.Items != null) + { idBuilder.Append($"[{schema.Items.Type}]"); + } return idBuilder.ToString(); } diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/RequestValidator.cs b/src/Swashbuckle.AspNetCore.ApiTesting/RequestValidator.cs index a09e1afdf6..bb48f67f1d 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/RequestValidator.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/RequestValidator.cs @@ -59,8 +59,8 @@ private static IEnumerable ExpandParameterSpecs( .Concat(operationSpec.Parameters) .Select(p => { - return p.Reference != null - ? (OpenApiParameter)openApiDocument.ResolveReference(p.Reference) + return p.Reference != null ? + (OpenApiParameter)openApiDocument.ResolveReference(p.Reference) : p; }); } @@ -112,8 +112,8 @@ private static void ValidateParameters( continue; } - var schema = (parameterSpec.Schema.Reference != null) - ? (OpenApiSchema)openApiDocument.ResolveReference(parameterSpec.Schema.Reference) + var schema = (parameterSpec.Schema.Reference != null) ? + (OpenApiSchema)openApiDocument.ResolveReference(parameterSpec.Schema.Reference) : parameterSpec.Schema; if (!schema.TryParse(value, out object typedValue)) @@ -125,8 +125,8 @@ private static void ValidateParameters( private void ValidateContent(OpenApiRequestBody requestBodySpec, OpenApiDocument openApiDocument, HttpContent content) { - requestBodySpec = requestBodySpec.Reference != null - ? (OpenApiRequestBody)openApiDocument.ResolveReference(requestBodySpec.Reference) + requestBodySpec = requestBodySpec.Reference != null ? + (OpenApiRequestBody)openApiDocument.ResolveReference(requestBodySpec.Reference) : requestBodySpec; if (requestBodySpec.Required && content == null) diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/ResponseValidator.cs b/src/Swashbuckle.AspNetCore.ApiTesting/ResponseValidator.cs index ea056f8b52..eb250d74a1 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/ResponseValidator.cs +++ b/src/Swashbuckle.AspNetCore.ApiTesting/ResponseValidator.cs @@ -57,8 +57,8 @@ private static void ValidateHeaders( continue; } - var schema = (headerSpec.Schema.Reference != null) - ? (OpenApiSchema)openApiDocument.ResolveReference(headerSpec.Schema.Reference) + var schema = (headerSpec.Schema.Reference != null) ? + (OpenApiSchema)openApiDocument.ResolveReference(headerSpec.Schema.Reference) : headerSpec.Schema; if (value == null) diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/Swashbuckle.AspNetCore.ApiTesting.csproj b/src/Swashbuckle.AspNetCore.ApiTesting/Swashbuckle.AspNetCore.ApiTesting.csproj index 2ecfdab0ff..8eef778053 100644 --- a/src/Swashbuckle.AspNetCore.ApiTesting/Swashbuckle.AspNetCore.ApiTesting.csproj +++ b/src/Swashbuckle.AspNetCore.ApiTesting/Swashbuckle.AspNetCore.ApiTesting.csproj @@ -37,4 +37,8 @@ + + + + diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/JsonModelFactory.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/JsonModelFactory.cs new file mode 100644 index 0000000000..c7b230400a --- /dev/null +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/JsonModelFactory.cs @@ -0,0 +1,10 @@ +using Microsoft.OpenApi.Any; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Swashbuckle.AspNetCore; + +internal static class JsonModelFactory +{ + public static IOpenApiAny CreateFromJson(string json) + => OpenApiAnyFactory.CreateFromJson(json); +} diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/PublicAPI.Shipped.txt index afccb33a83..ef78297dde 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/PublicAPI.Shipped.txt +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/PublicAPI.Shipped.txt @@ -68,11 +68,8 @@ static Swashbuckle.AspNetCore.SwaggerGen.MemberInfoExtensions.GetInlineAndMetada static Swashbuckle.AspNetCore.SwaggerGen.MemberInfoExtensions.IsDictionaryValueNonNullable(this System.Reflection.MemberInfo memberInfo) -> bool static Swashbuckle.AspNetCore.SwaggerGen.MemberInfoExtensions.IsNonNullableReferenceType(this System.Reflection.MemberInfo memberInfo) -> bool static Swashbuckle.AspNetCore.SwaggerGen.MethodInfoExtensions.GetUnderlyingGenericTypeMethod(this System.Reflection.MethodInfo constructedTypeMethod) -> System.Reflection.MethodInfo -static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json) -> Microsoft.OpenApi.Any.IOpenApiAny -static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json, System.Text.Json.JsonSerializerOptions options) -> Microsoft.OpenApi.Any.IOpenApiAny static Swashbuckle.AspNetCore.SwaggerGen.OpenApiSchemaExtensions.ApplyRouteConstraints(this Microsoft.OpenApi.Models.OpenApiSchema schema, Microsoft.AspNetCore.Mvc.ApiExplorer.ApiParameterRouteInfo routeInfo) -> void static Swashbuckle.AspNetCore.SwaggerGen.OpenApiSchemaExtensions.ApplyValidationAttributes(this Microsoft.OpenApi.Models.OpenApiSchema schema, System.Collections.Generic.IEnumerable customAttributes) -> void -static Swashbuckle.AspNetCore.SwaggerGen.OpenApiSchemaExtensions.ResolveType(this Microsoft.OpenApi.Models.OpenApiSchema schema, Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository schemaRepository) -> string static Swashbuckle.AspNetCore.SwaggerGen.PropertyInfoExtensions.HasAttribute(this System.Reflection.PropertyInfo property) -> bool static Swashbuckle.AspNetCore.SwaggerGen.PropertyInfoExtensions.IsPubliclyReadable(this System.Reflection.PropertyInfo property) -> bool static Swashbuckle.AspNetCore.SwaggerGen.PropertyInfoExtensions.IsPubliclyWritable(this System.Reflection.PropertyInfo property) -> bool @@ -168,7 +165,6 @@ Swashbuckle.AspNetCore.SwaggerGen.JsonSerializerDataContractResolver.IsSupported Swashbuckle.AspNetCore.SwaggerGen.JsonSerializerDataContractResolver.JsonSerializerDataContractResolver(System.Text.Json.JsonSerializerOptions serializerOptions) -> void Swashbuckle.AspNetCore.SwaggerGen.MemberInfoExtensions Swashbuckle.AspNetCore.SwaggerGen.MethodInfoExtensions -Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory Swashbuckle.AspNetCore.SwaggerGen.OpenApiSchemaExtensions Swashbuckle.AspNetCore.SwaggerGen.OperationFilterContext Swashbuckle.AspNetCore.SwaggerGen.OperationFilterContext.ApiDescription.get -> Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescription diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net6.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net6.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..2eb55dad3e --- /dev/null +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net6.0/PublicAPI.Shipped.txt @@ -0,0 +1,2 @@ +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json) -> Microsoft.OpenApi.Any.IOpenApiAny +Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net6.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..429fb2d4d8 --- /dev/null +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json, System.Text.Json.JsonSerializerOptions options) -> Microsoft.OpenApi.Any.IOpenApiAny +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiSchemaExtensions.ResolveType(this Microsoft.OpenApi.Models.OpenApiSchema schema, Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository schemaRepository) -> string diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net8.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net8.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..2eb55dad3e --- /dev/null +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net8.0/PublicAPI.Shipped.txt @@ -0,0 +1,2 @@ +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json) -> Microsoft.OpenApi.Any.IOpenApiAny +Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net8.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..429fb2d4d8 --- /dev/null +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json, System.Text.Json.JsonSerializerOptions options) -> Microsoft.OpenApi.Any.IOpenApiAny +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiSchemaExtensions.ResolveType(this Microsoft.OpenApi.Models.OpenApiSchema schema, Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository schemaRepository) -> string diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net9.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net9.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..2eb55dad3e --- /dev/null +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net9.0/PublicAPI.Shipped.txt @@ -0,0 +1,2 @@ +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json) -> Microsoft.OpenApi.Any.IOpenApiAny +Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net9.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net9.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..429fb2d4d8 --- /dev/null +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/net9.0/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json, System.Text.Json.JsonSerializerOptions options) -> Microsoft.OpenApi.Any.IOpenApiAny +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiSchemaExtensions.ResolveType(this Microsoft.OpenApi.Models.OpenApiSchema schema, Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository schemaRepository) -> string diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..2eb55dad3e --- /dev/null +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt @@ -0,0 +1,2 @@ +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json) -> Microsoft.OpenApi.Any.IOpenApiAny +Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..429fb2d4d8 --- /dev/null +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json, System.Text.Json.JsonSerializerOptions options) -> Microsoft.OpenApi.Any.IOpenApiAny +static Swashbuckle.AspNetCore.SwaggerGen.OpenApiSchemaExtensions.ResolveType(this Microsoft.OpenApi.Models.OpenApiSchema schema, Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository schemaRepository) -> string diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs index 225689fbd4..41106e8bac 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs @@ -97,16 +97,16 @@ public static void ApplyRouteConstraints(this OpenApiSchema schema, ApiParameter ApplyLengthRouteConstraint(schema, lengthRouteConstraint); else if (constraint is FloatRouteConstraint or DecimalRouteConstraint) - schema.Type = "number"; + schema.Type = JsonSchemaTypes.Number; else if (constraint is LongRouteConstraint or IntRouteConstraint) - schema.Type = "integer"; + schema.Type = JsonSchemaTypes.Integer; else if (constraint is GuidRouteConstraint or StringRouteConstraint) - schema.Type = "string"; + schema.Type = JsonSchemaTypes.String; else if (constraint is BoolRouteConstraint) - schema.Type = "boolean"; + schema.Type = JsonSchemaTypes.Boolean; } } @@ -139,7 +139,7 @@ private static void ApplyDataTypeAttribute(OpenApiSchema schema, DataTypeAttribu private static void ApplyMinLengthAttribute(OpenApiSchema schema, MinLengthAttribute minLengthAttribute) { - if (schema.Type == "array") + if (schema.Type == JsonSchemaTypes.Array) schema.MinItems = minLengthAttribute.Length; else schema.MinLength = minLengthAttribute.Length; @@ -147,7 +147,7 @@ private static void ApplyMinLengthAttribute(OpenApiSchema schema, MinLengthAttri private static void ApplyMinLengthRouteConstraint(OpenApiSchema schema, MinLengthRouteConstraint minLengthRouteConstraint) { - if (schema.Type == "array") + if (schema.Type == JsonSchemaTypes.Array) schema.MinItems = minLengthRouteConstraint.MinLength; else schema.MinLength = minLengthRouteConstraint.MinLength; @@ -155,7 +155,7 @@ private static void ApplyMinLengthRouteConstraint(OpenApiSchema schema, MinLengt private static void ApplyMaxLengthAttribute(OpenApiSchema schema, MaxLengthAttribute maxLengthAttribute) { - if (schema.Type == "array") + if (schema.Type == JsonSchemaTypes.Array) schema.MaxItems = maxLengthAttribute.Length; else schema.MaxLength = maxLengthAttribute.Length; @@ -163,7 +163,7 @@ private static void ApplyMaxLengthAttribute(OpenApiSchema schema, MaxLengthAttri private static void ApplyMaxLengthRouteConstraint(OpenApiSchema schema, MaxLengthRouteConstraint maxLengthRouteConstraint) { - if (schema.Type == "array") + if (schema.Type == JsonSchemaTypes.Array) schema.MaxItems = maxLengthRouteConstraint.MaxLength; else schema.MaxLength = maxLengthRouteConstraint.MaxLength; @@ -173,7 +173,7 @@ private static void ApplyMaxLengthRouteConstraint(OpenApiSchema schema, MaxLengt private static void ApplyLengthAttribute(OpenApiSchema schema, LengthAttribute lengthAttribute) { - if (schema.Type == "array") + if (schema.Type == JsonSchemaTypes.Array) { schema.MinItems = lengthAttribute.MinimumLength; schema.MaxItems = lengthAttribute.MaximumLength; diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs index 8e5a39ad42..491ee323bd 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs @@ -3,7 +3,6 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -using System.Globalization; using System.Linq; using System.Reflection; using System.Text.Json; @@ -11,7 +10,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.Extensions.Options; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; namespace Swashbuckle.AspNetCore.SwaggerGen @@ -221,9 +219,7 @@ private OpenApiSchema GeneratePolymorphicSchema( { return new OpenApiSchema { - OneOf = knownTypesDataContracts - .Select(allowedTypeDataContract => GenerateConcreteSchema(allowedTypeDataContract, schemaRepository)) - .ToList() + OneOf = [.. knownTypesDataContracts.Select(allowedTypeDataContract => GenerateConcreteSchema(allowedTypeDataContract, schemaRepository))] }; } @@ -246,7 +242,7 @@ private OpenApiSchema GenerateConcreteSchema(DataContract dataContract, SchemaRe if (dataContract.UnderlyingType.IsAssignableToOneOf(BinaryStringTypes)) { - return new OpenApiSchema { Type = "string", Format = "binary" }; + return new OpenApiSchema { Type = JsonSchemaTypes.String, Format = "binary" }; } Func schemaFactory; @@ -308,7 +304,7 @@ private static OpenApiSchema CreatePrimitiveSchema(DataContract dataContract) { var schema = new OpenApiSchema { - Type = dataContract.DataType.ToString().ToLower(CultureInfo.InvariantCulture), + Type = FromDataType(dataContract.DataType), Format = dataContract.DataFormat }; @@ -319,7 +315,7 @@ private static OpenApiSchema CreatePrimitiveSchema(DataContract dataContract) schema.Enum = dataContract.EnumValues .Select(value => JsonSerializer.Serialize(value)) .Distinct() - .Select(OpenApiAnyFactory.CreateFromJson) + .Select(JsonModelFactory.CreateFromJson) .ToList(); return schema; @@ -332,7 +328,7 @@ private static OpenApiSchema CreatePrimitiveSchema(DataContract dataContract) .Cast() .Select(value => dataContract.JsonConverter(value)) .Distinct() - .Select(valueAsJson => OpenApiAnyFactory.CreateFromJson(valueAsJson)) + .Select(JsonModelFactory.CreateFromJson) .ToList(); } @@ -346,7 +342,7 @@ private OpenApiSchema CreateArraySchema(DataContract dataContract, SchemaReposit return new OpenApiSchema { - Type = "array", + Type = JsonSchemaTypes.Array, Items = GenerateSchema(dataContract.ArrayItemType, schemaRepository), UniqueItems = hasUniqueItems ? (bool?)true : null }; @@ -363,7 +359,7 @@ private OpenApiSchema CreateDictionarySchema(DataContract dataContract, SchemaRe // This is a special case where the set of key values is known (e.g. if the key type is an enum) return new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, Properties = knownKeysProperties, AdditionalPropertiesAllowed = false }; @@ -371,7 +367,7 @@ private OpenApiSchema CreateDictionarySchema(DataContract dataContract, SchemaRe return new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, AdditionalPropertiesAllowed = true, AdditionalProperties = GenerateSchema(dataContract.DictionaryValueType, schemaRepository) }; @@ -381,7 +377,7 @@ private OpenApiSchema CreateObjectSchema(DataContract dataContract, SchemaReposi { var schema = new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, Properties = new Dictionary(), Required = new SortedSet(), AdditionalPropertiesAllowed = false @@ -420,7 +416,7 @@ private OpenApiSchema CreateObjectSchema(DataContract dataContract, SchemaReposi if (TryGetDiscriminatorFor(dataContract, schemaRepository, knownTypesDataContracts, out var discriminator)) { - schema.Properties.Add(discriminator.PropertyName, new OpenApiSchema { Type = "string" }); + schema.Properties.Add(discriminator.PropertyName, new OpenApiSchema { Type = JsonSchemaTypes.String }); schema.Required.Add(discriminator.PropertyName); schema.Discriminator = discriminator; } @@ -557,7 +553,7 @@ private void ApplyFilters( } } - private IOpenApiAny GenerateDefaultValue( + private Microsoft.OpenApi.Any.IOpenApiAny GenerateDefaultValue( DataContract dataContract, Type modelType, object defaultValue) @@ -573,7 +569,10 @@ private IOpenApiAny GenerateDefaultValue( } var defaultAsJson = dataContract.JsonConverter(defaultValue); - return OpenApiAnyFactory.CreateFromJson(defaultAsJson); + return JsonModelFactory.CreateFromJson(defaultAsJson); } + + private static string FromDataType(DataType dataType) + => dataType.ToString().ToLower(System.Globalization.CultureInfo.InvariantCulture); } } diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/OpenApiAnyFactory.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/OpenApiAnyFactory.cs index 5794645ff9..d571b81e57 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/OpenApiAnyFactory.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/OpenApiAnyFactory.cs @@ -78,7 +78,7 @@ private static IOpenApiAny CreateFromJsonElement(JsonElement jsonElement) if (jsonElement.ValueKind == JsonValueKind.Object) return CreateOpenApiObject(jsonElement); - throw new System.ArgumentException($"Unsupported value kind {jsonElement.ValueKind}"); + throw new ArgumentException($"Unsupported value kind {jsonElement.ValueKind}"); } } } diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs index 6f2445d466..7032f2aaae 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs @@ -18,6 +18,8 @@ using Microsoft.AspNetCore.Http.Metadata; #endif +using OpenApiTag = Microsoft.OpenApi.Models.OpenApiTag; + namespace Swashbuckle.AspNetCore.SwaggerGen { public class SwaggerGenerator( @@ -46,7 +48,7 @@ public async Task GetSwaggerAsync( { var (filterContext, swaggerDoc) = GetSwaggerDocumentWithoutPaths(documentName, host, basePath); - swaggerDoc.Paths = await GeneratePathsAsync(filterContext.ApiDescriptions, filterContext.SchemaRepository); + swaggerDoc.Paths = await GeneratePathsAsync(swaggerDoc, filterContext.ApiDescriptions, filterContext.SchemaRepository); swaggerDoc.Components.SecuritySchemes = await GetSecuritySchemesAsync(); // NOTE: Filter processing moved here so they may affect generated security schemes @@ -71,7 +73,7 @@ public OpenApiDocument GetSwagger(string documentName, string host = null, strin { var (filterContext, swaggerDoc) = GetSwaggerDocumentWithoutPaths(documentName, host, basePath); - swaggerDoc.Paths = GeneratePaths(filterContext.ApiDescriptions, filterContext.SchemaRepository); + swaggerDoc.Paths = GeneratePaths(swaggerDoc, filterContext.ApiDescriptions, filterContext.SchemaRepository); swaggerDoc.Components.SecuritySchemes = GetSecuritySchemesAsync().Result; // NOTE: Filter processing moved here so they may affect generated security schemes @@ -188,9 +190,10 @@ private List GenerateServers(string host, string basePath) } private async Task GeneratePathsAsync( + OpenApiDocument document, IEnumerable apiDescriptions, SchemaRepository schemaRepository, - Func, SchemaRepository, Task>> operationsGenerator) + Func, SchemaRepository, Task>> operationsGenerator) { var apiDescriptionsByPath = apiDescriptions .OrderBy(_options.SortKeySelector) @@ -202,26 +205,32 @@ private async Task GeneratePathsAsync( paths.Add($"/{group.Key}", new OpenApiPathItem { - Operations = await operationsGenerator(group, schemaRepository) + Operations = await operationsGenerator(document, group, schemaRepository) }); }; return paths; } - private OpenApiPaths GeneratePaths(IEnumerable apiDescriptions, SchemaRepository schemaRepository) + private OpenApiPaths GeneratePaths( + OpenApiDocument document, + IEnumerable apiDescriptions, + SchemaRepository schemaRepository) { return GeneratePathsAsync( + document, apiDescriptions, schemaRepository, - (group, schemaRepository) => Task.FromResult(GenerateOperations(group, schemaRepository))).Result; + (document, group, schemaRepository) => Task.FromResult(GenerateOperations(document, group, schemaRepository))).Result; } private async Task GeneratePathsAsync( + OpenApiDocument document, IEnumerable apiDescriptions, SchemaRepository schemaRepository) { return await GeneratePathsAsync( + document, apiDescriptions, schemaRepository, GenerateOperationsAsync); @@ -237,6 +246,7 @@ private async Task GeneratePathsAsync( } private Dictionary GenerateOperations( + OpenApiDocument document, IEnumerable apiDescriptions, SchemaRepository schemaRepository) { @@ -245,13 +255,14 @@ private Dictionary GenerateOperations( foreach ((var operationType, var description) in apiDescriptionsByMethod) { - operations.Add(operationType, GenerateOperation(description, schemaRepository)); + operations.Add(operationType, GenerateOperation(document, description, schemaRepository)); } return operations; } private async Task> GenerateOperationsAsync( + OpenApiDocument document, IEnumerable apiDescriptions, SchemaRepository schemaRepository) { @@ -260,7 +271,7 @@ private async Task> GenerateOperatio foreach ((var operationType, var description) in apiDescriptionsByMethod) { - operations.Add(operationType, await GenerateOperationAsync(description, schemaRepository)); + operations.Add(operationType, await GenerateOperationAsync(document, description, schemaRepository)); } return operations; @@ -299,6 +310,7 @@ private async Task> GenerateOperatio } private async Task GenerateOperationAsync( + OpenApiDocument document, ApiDescription apiDescription, SchemaRepository schemaRepository, Func>> parametersGenerator, @@ -316,7 +328,7 @@ private async Task GenerateOperationAsync( { operation ??= new OpenApiOperation { - Tags = GenerateOperationTags(apiDescription), + Tags = GenerateOperationTags(document, apiDescription), OperationId = _options.OperationIdSelector(apiDescription), Parameters = await parametersGenerator(apiDescription, schemaRepository), RequestBody = await bodyGenerator(apiDescription, schemaRepository), @@ -343,9 +355,10 @@ private async Task GenerateOperationAsync( } } - private OpenApiOperation GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository) + private OpenApiOperation GenerateOperation(OpenApiDocument document, ApiDescription apiDescription, SchemaRepository schemaRepository) { return GenerateOperationAsync( + document, apiDescription, schemaRepository, (description, repository) => Task.FromResult(GenerateParameters(description, repository)), @@ -362,10 +375,12 @@ private OpenApiOperation GenerateOperation(ApiDescription apiDescription, Schema } private async Task GenerateOperationAsync( + OpenApiDocument document, ApiDescription apiDescription, SchemaRepository schemaRepository) { return await GenerateOperationAsync( + document, apiDescription, schemaRepository, GenerateParametersAsync, @@ -492,12 +507,8 @@ private async Task GenerateOpenApiOperationFromMetadataAsync(A } #endif - private List GenerateOperationTags(ApiDescription apiDescription) - { - return _options.TagsSelector(apiDescription) - .Select(tagName => new OpenApiTag { Name = tagName }) - .ToList(); - } + private List GenerateOperationTags(OpenApiDocument document, ApiDescription apiDescription) + => [.. _options.TagsSelector(apiDescription).Select(tagName => CreateTag(tagName, document))]; private static async Task> GenerateParametersAsync( ApiDescription apiDescription, @@ -582,7 +593,7 @@ private OpenApiParameter GenerateParameterWithoutFilter( apiParameter.PropertyInfo(), apiParameter.ParameterInfo(), apiParameter.RouteInfo) - : new OpenApiSchema { Type = "string" }; + : new OpenApiSchema { Type = JsonSchemaTypes.String }; var description = schema.Description; if (string.IsNullOrEmpty(description) @@ -853,7 +864,7 @@ private OpenApiSchema GenerateSchemaFromFormParameters( schemaRepository, propertyInfo, formParameter.ParameterInfo()) - : new OpenApiSchema { Type = "string" }; + : new OpenApiSchema { Type = JsonSchemaTypes.String }; if (schema.Reference is null || (formParameter.ModelMetadata?.ModelType is not null && (Nullable.GetUnderlyingType(formParameter.ModelMetadata.ModelType) ?? formParameter.ModelMetadata.ModelType).IsEnum)) @@ -897,7 +908,7 @@ private OpenApiSchema GenerateSchemaFromFormParameters( static OpenApiSchema GenerateSchemaForProperties(Dictionary properties, List requiredPropertyNames) => new() { - Type = "object", + Type = JsonSchemaTypes.Object, Properties = properties, Required = new SortedSet(requiredPropertyNames) }; @@ -1094,5 +1105,8 @@ private static string GenerateDescription(ApiDescription apiDescription) => .Select(s => s.Description) .LastOrDefault(); #endif + + private static OpenApiTag CreateTag(string name, OpenApiDocument _) => + new() { Name = name }; } } diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/Swashbuckle.AspNetCore.SwaggerGen.csproj b/src/Swashbuckle.AspNetCore.SwaggerGen/Swashbuckle.AspNetCore.SwaggerGen.csproj index aa81b0be06..fc19654e3c 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/Swashbuckle.AspNetCore.SwaggerGen.csproj +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/Swashbuckle.AspNetCore.SwaggerGen.csproj @@ -31,5 +31,13 @@ + + + + + + + + diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsExampleHelper.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsExampleHelper.cs index f5aacd2125..c92d60c239 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsExampleHelper.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsExampleHelper.cs @@ -1,27 +1,24 @@ using System.Text.Json; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; namespace Swashbuckle.AspNetCore.SwaggerGen { internal static class XmlCommentsExampleHelper { - public static IOpenApiAny Create( + public static Microsoft.OpenApi.Any.IOpenApiAny Create( SchemaRepository schemaRepository, OpenApiSchema schema, string exampleString) { var isStringType = - schema?.ResolveType(schemaRepository) == "string" && + schema?.ResolveType(schemaRepository) == JsonSchemaTypes.String && !string.Equals(exampleString, "null"); var exampleAsJson = isStringType - ? JsonSerializer.Serialize(exampleString) - : exampleString; + ? JsonSerializer.Serialize(exampleString) + : exampleString; - var example = OpenApiAnyFactory.CreateFromJson(exampleAsJson); - - return example; + return JsonModelFactory.CreateFromJson(exampleAsJson); } } } diff --git a/test/Swashbuckle.AspNetCore.Annotations.Test/AnnotationsOperationFilterTests.cs b/test/Swashbuckle.AspNetCore.Annotations.Test/AnnotationsOperationFilterTests.cs index 58e73b06a7..9cb7bfd7b7 100644 --- a/test/Swashbuckle.AspNetCore.Annotations.Test/AnnotationsOperationFilterTests.cs +++ b/test/Swashbuckle.AspNetCore.Annotations.Test/AnnotationsOperationFilterTests.cs @@ -89,9 +89,9 @@ public void Apply_EnrichesResponseMetadata_IfActionDecoratedWithSwaggerResponseC var jsonContent = response1.Content.First(); var xmlContent = response1.Content.Last(); Assert.Equal("application/json", jsonContent.Key); - Assert.Equal("string", jsonContent.Value.Schema.Type); + Assert.Equal(JsonSchemaTypes.String, jsonContent.Value.Schema.Type); Assert.Equal("application/xml", xmlContent.Key); - Assert.Equal("string", xmlContent.Value.Schema.Type); + Assert.Equal(JsonSchemaTypes.String, xmlContent.Value.Schema.Type); } [Fact] diff --git a/test/Swashbuckle.AspNetCore.Annotations.Test/Fixtures/VendorExtensionsOperationFilter.cs b/test/Swashbuckle.AspNetCore.Annotations.Test/Fixtures/VendorExtensionsOperationFilter.cs index c0dd11207c..5675d2f82b 100644 --- a/test/Swashbuckle.AspNetCore.Annotations.Test/Fixtures/VendorExtensionsOperationFilter.cs +++ b/test/Swashbuckle.AspNetCore.Annotations.Test/Fixtures/VendorExtensionsOperationFilter.cs @@ -6,9 +6,9 @@ namespace Swashbuckle.AspNetCore.Annotations.Test { public class VendorExtensionsOperationFilter : IOperationFilter { - public void Apply(OpenApiOperation operation, OperationFilterContext contex) + public void Apply(OpenApiOperation operation, OperationFilterContext context) { operation.Extensions.Add("X-property1", new OpenApiString("value")); } } -} \ No newline at end of file +} diff --git a/test/Swashbuckle.AspNetCore.Annotations.Test/Swashbuckle.AspNetCore.Annotations.Test.csproj b/test/Swashbuckle.AspNetCore.Annotations.Test/Swashbuckle.AspNetCore.Annotations.Test.csproj index 633f05fd2b..83c5f8c654 100644 --- a/test/Swashbuckle.AspNetCore.Annotations.Test/Swashbuckle.AspNetCore.Annotations.Test.csproj +++ b/test/Swashbuckle.AspNetCore.Annotations.Test/Swashbuckle.AspNetCore.Annotations.Test.csproj @@ -4,6 +4,10 @@ net9.0;net8.0 + + + + diff --git a/test/Swashbuckle.AspNetCore.ApiTesting.Test/JsonValidatorTests.cs b/test/Swashbuckle.AspNetCore.ApiTesting.Test/JsonValidatorTests.cs index 024928cad4..fe906e05a9 100644 --- a/test/Swashbuckle.AspNetCore.ApiTesting.Test/JsonValidatorTests.cs +++ b/test/Swashbuckle.AspNetCore.ApiTesting.Test/JsonValidatorTests.cs @@ -4,25 +4,33 @@ using Newtonsoft.Json.Linq; using Xunit; +using JsonSchemaType = string; + namespace Swashbuckle.AspNetCore.ApiTesting.Test { public class JsonValidatorTests { + public static TheoryData Validate_ReturnsError_IfInstanceNotOfExpectedTypeData => + new() + { + { JsonSchemaTypes.Null, "{}", false, "Path: . Instance is not of type 'null'" }, + { JsonSchemaTypes.Null, "null", true, null }, + { JsonSchemaTypes.Boolean, "'foobar'", false, "Path: . Instance is not of type 'boolean'" }, + { JsonSchemaTypes.Boolean, "true", true, null }, + { JsonSchemaTypes.Object, "'foobar'", false, "Path: . Instance is not of type 'object'" }, + { JsonSchemaTypes.Object, "{}", true, null }, + { JsonSchemaTypes.Array, "'foobar'", false, "Path: . Instance is not of type 'array'" }, + { JsonSchemaTypes.Array, "[]", true, null }, + { JsonSchemaTypes.Number, "'foobar'", false, "Path: . Instance is not of type 'number'" }, + { JsonSchemaTypes.Number, "1", true, null }, + { JsonSchemaTypes.String, "{}", false, "Path: . Instance is not of type 'string'" }, + { JsonSchemaTypes.String, "'foobar'", true, null }, + }; + [Theory] - [InlineData("null", "{}", false, "Path: . Instance is not of type 'null'")] - [InlineData("null", "null", true, null)] - [InlineData("boolean", "'foobar'", false, "Path: . Instance is not of type 'boolean'")] - [InlineData("boolean", "true", true, null)] - [InlineData("object", "'foobar'", false, "Path: . Instance is not of type 'object'")] - [InlineData("object", "{}", true, null)] - [InlineData("array", "'foobar'", false, "Path: . Instance is not of type 'array'")] - [InlineData("array", "[]", true, null)] - [InlineData("number", "'foobar'", false, "Path: . Instance is not of type 'number'")] - [InlineData("number", "1", true, null)] - [InlineData("string", "{}", false, "Path: . Instance is not of type 'string'")] - [InlineData("string", "'foobar'", true, null)] + [MemberData(nameof(Validate_ReturnsError_IfInstanceNotOfExpectedTypeData))] public void Validate_ReturnsError_IfInstanceNotOfExpectedType( - string schemaType, + JsonSchemaType schemaType, string instanceText, bool expectedReturnValue, string expectedErrorMessage) @@ -49,7 +57,7 @@ public void Validate_ReturnsError_IfNumberNotEvenlyDivisibleByMultipleOf( bool expectedReturnValue, string expectedErrorMessage) { - var openApiSchema = new OpenApiSchema { Type = "number", MultipleOf = schemaMultipleOf }; + var openApiSchema = new OpenApiSchema { Type = JsonSchemaTypes.Number, MultipleOf = schemaMultipleOf }; var instance = JToken.Parse(instanceText); var returnValue = Subject().Validate( @@ -71,7 +79,7 @@ public void Validate_ReturnsError_IfNumberGreaterThanMaximum( bool expectedReturnValue, string expectedErrorMessage) { - var openApiSchema = new OpenApiSchema { Type = "number", Maximum = schemaMaximum }; + var openApiSchema = new OpenApiSchema { Type = JsonSchemaTypes.Number, Maximum = schemaMaximum }; var instance = JToken.Parse(instanceText); var returnValue = Subject().Validate( @@ -95,7 +103,7 @@ public void Validate_ReturnsError_IfNumberGreaterThanOrEqualToMaximumAndExclusiv { var openApiSchema = new OpenApiSchema { - Type = "number", + Type = JsonSchemaTypes.Number, Maximum = schemaMaximum, ExclusiveMaximum = true }; @@ -120,7 +128,7 @@ public void Validate_ReturnsError_IfNumberLessThanMinimum( bool expectedReturnValue, string expectedErrorMessage) { - var openApiSchema = new OpenApiSchema { Type = "number", Minimum = schemaMinimum }; + var openApiSchema = new OpenApiSchema { Type = JsonSchemaTypes.Number, Minimum = schemaMinimum }; var instance = JToken.Parse(instanceText); var returnValue = Subject().Validate( @@ -144,7 +152,7 @@ public void Validate_ReturnsError_IfNumberLessThanOrEqualToMinimumAndExclusiveMi { var openApiSchema = new OpenApiSchema { - Type = "number", + Type = JsonSchemaTypes.Number, Minimum = schemaMinimum, ExclusiveMinimum = true }; @@ -171,7 +179,7 @@ public void Validate_ReturnsError_IfStringLengthGreaterThanMaxLength( { var openApiSchema = new OpenApiSchema { - Type = "string", + Type = JsonSchemaTypes.String, MaxLength = schemaMaxLength }; var instance = JToken.Parse(instanceText); @@ -197,7 +205,7 @@ public void Validate_ReturnsError_IfStringLengthLessThanMinLength( { var openApiSchema = new OpenApiSchema { - Type = "string", + Type = JsonSchemaTypes.String, MinLength = schemaMinLength }; var instance = JToken.Parse(instanceText); @@ -223,7 +231,7 @@ public void Validate_ReturnsError_IfStringDoesNotMatchPattern( { var openApiSchema = new OpenApiSchema { - Type = "string", + Type = JsonSchemaTypes.String, Pattern = schemaPattern }; var instance = JToken.Parse(instanceText); @@ -238,19 +246,25 @@ public void Validate_ReturnsError_IfStringDoesNotMatchPattern( Assert.Equal(expectedErrorMessage, errorMessages.FirstOrDefault()); } + public static TheoryData Validate_ReturnsError_IfArrayItemDoesNotMatchItemsSchemaData => + new() + { + { JsonSchemaTypes.Boolean, "[ true, 'foo' ]", false, "Path: [1]. Instance is not of type 'boolean'" }, + { JsonSchemaTypes.Number, "[ 123, 'foo' ]", false, "Path: [1]. Instance is not of type 'number'" }, + { JsonSchemaTypes.Boolean, "[ true, false ]", true, null }, + }; + [Theory] - [InlineData("boolean", "[ true, 'foo' ]", false, "Path: [1]. Instance is not of type 'boolean'")] - [InlineData("number", "[ 123, 'foo' ]", false, "Path: [1]. Instance is not of type 'number'")] - [InlineData("boolean", "[ true, false ]", true, null)] + [MemberData(nameof(Validate_ReturnsError_IfArrayItemDoesNotMatchItemsSchemaData))] public void Validate_ReturnsError_IfArrayItemDoesNotMatchItemsSchema( - string itemsSchemaType, + JsonSchemaType itemsSchemaType, string instanceText, bool expectedReturnValue, string expectedErrorMessage) { var openApiSchema = new OpenApiSchema { - Type = "array", + Type = JsonSchemaTypes.Array, Items = new OpenApiSchema { Type = itemsSchemaType } }; var instance = JToken.Parse(instanceText); @@ -276,7 +290,7 @@ public void Validate_ReturnsError_IfArraySizeGreaterThanMaxItems( { var openApiSchema = new OpenApiSchema { - Type = "array", + Type = JsonSchemaTypes.Array, MaxItems = schemaMaxItems }; var instance = JToken.Parse(instanceText); @@ -302,7 +316,7 @@ public void Validate_ReturnsError_IfArraySizeLessThanMinItems( { var openApiSchema = new OpenApiSchema { - Type = "array", + Type = JsonSchemaTypes.Array, MinItems = schemaMinItems }; var instance = JToken.Parse(instanceText); @@ -327,7 +341,7 @@ public void Validate_ReturnsError_IfArrayDoesNotContainUniqueItemsAndUniqueItems { var openApiSchema = new OpenApiSchema { - Type = "array", + Type = JsonSchemaTypes.Array, UniqueItems = true }; var instance = JToken.Parse(instanceText); @@ -353,7 +367,7 @@ public void Validate_ReturnsError_IfNumberOfPropertiesGreaterThanMaxProperties( { var openApiSchema = new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, MaxProperties = schemaMaxProperties }; var instance = JToken.Parse(instanceText); @@ -379,7 +393,7 @@ public void Validate_ReturnsError_IfNumberOfPropertiesLessThanMinProperties( { var openApiSchema = new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, MinProperties = schemaMinProperties }; var instance = JToken.Parse(instanceText); @@ -405,7 +419,7 @@ public void Validate_ReturnsError_IfRequiredPropertyNotPresent( { var openApiSchema = new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, Required = new SortedSet(schemaRequired) }; var instance = JToken.Parse(instanceText); @@ -420,19 +434,25 @@ public void Validate_ReturnsError_IfRequiredPropertyNotPresent( Assert.Equal(expectedErrorMessage, errorMessages.FirstOrDefault()); } + public static TheoryData Validate_ReturnsError_IfKnownPropertyDoesNotMatchPropertySchemaData => + new() + { + { JsonSchemaTypes.Number, "{ \"id\": \"foo\" }", false, "Path: id. Instance is not of type 'number'" }, + { JsonSchemaTypes.String, "{ \"id\": 123 }", false, "Path: id. Instance is not of type 'string'" }, + { JsonSchemaTypes.Number, "{ \"id\": 123 }", true, null }, + }; + [Theory] - [InlineData("number", "{ \"id\": \"foo\" }", false, "Path: id. Instance is not of type 'number'")] - [InlineData("string", "{ \"id\": 123 }", false, "Path: id. Instance is not of type 'string'")] - [InlineData("number", "{ \"id\": 123 }", true, null)] + [MemberData(nameof(Validate_ReturnsError_IfKnownPropertyDoesNotMatchPropertySchemaData))] public void Validate_ReturnsError_IfKnownPropertyDoesNotMatchPropertySchema( - string propertySchemaType, + JsonSchemaType propertySchemaType, string instanceText, bool expectedReturnValue, string expectedErrorMessage) { var openApiSchema = new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, Properties = new Dictionary { [ "id" ] = new OpenApiSchema { Type = propertySchemaType } @@ -450,19 +470,25 @@ public void Validate_ReturnsError_IfKnownPropertyDoesNotMatchPropertySchema( Assert.Equal(expectedErrorMessage, errorMessages.FirstOrDefault()); } + public static TheoryData Validate_ReturnsError_IfAdditionalPropertyDoesNotMatchAdditionalPropertiesSchemaData => + new() + { + { JsonSchemaTypes.Number, "{ \"id\": \"foo\" }", false, "Path: id. Instance is not of type 'number'" }, + { JsonSchemaTypes.String, "{ \"name\": 123 }", false, "Path: name. Instance is not of type 'string'" }, + { JsonSchemaTypes.Number, "{ \"description\": 123 }", true, null }, + }; + [Theory] - [InlineData("number", "{ \"id\": \"foo\" }", false, "Path: id. Instance is not of type 'number'")] - [InlineData("string", "{ \"name\": 123 }", false, "Path: name. Instance is not of type 'string'")] - [InlineData("number", "{ \"description\": 123 }", true, null)] + [MemberData(nameof(Validate_ReturnsError_IfAdditionalPropertyDoesNotMatchAdditionalPropertiesSchemaData))] public void Validate_ReturnsError_IfAdditionalPropertyDoesNotMatchAdditionalPropertiesSchema( - string additionalPropertiesType, + JsonSchemaType additionalPropertiesType, string instanceText, bool expectedReturnValue, string expectedErrorMessage) { var openApiSchema = new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, AdditionalProperties = new OpenApiSchema { Type = additionalPropertiesType } }; var instance = JToken.Parse(instanceText); @@ -488,7 +514,7 @@ public void Validate_ReturnsError_IfAdditionalPropertiesPresentAndAdditionalProp { var openApiSchema = new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, AdditionalPropertiesAllowed = additionalPropertiesAllowed }; var instance = JToken.Parse(instanceText); @@ -515,9 +541,9 @@ public void Validate_ReturnsError_IfInstanceDoesNotMatchAllSchemasSpecifiedByAll { AllOf = [ - new OpenApiSchema { Type = "object", Required = new SortedSet { "p1" } }, - new OpenApiSchema { Type = "object", Required = new SortedSet { "p2" } }, - new OpenApiSchema { Type = "object", Required = new SortedSet { "p3" } } + new OpenApiSchema { Type = JsonSchemaTypes.Object, Required = new SortedSet { "p1" } }, + new OpenApiSchema { Type = JsonSchemaTypes.Object, Required = new SortedSet { "p2" } }, + new OpenApiSchema { Type = JsonSchemaTypes.Object, Required = new SortedSet { "p3" } } ] }; var instance = JToken.Parse(instanceText); @@ -544,9 +570,9 @@ public void Validate_ReturnsError_IfInstanceDoesNotMatchAnySchemaSpecifiedByAnyO { AnyOf = [ - new OpenApiSchema { Type = "object", Required = new SortedSet { "p1" } }, - new OpenApiSchema { Type = "object", Required = new SortedSet { "p2" } }, - new OpenApiSchema { Type = "object", Required = new SortedSet { "p3" } } + new OpenApiSchema { Type = JsonSchemaTypes.Object, Required = new SortedSet { "p1" } }, + new OpenApiSchema { Type = JsonSchemaTypes.Object, Required = new SortedSet { "p2" } }, + new OpenApiSchema { Type = JsonSchemaTypes.Object, Required = new SortedSet { "p3" } } ] }; var instance = JToken.Parse(instanceText); @@ -574,9 +600,9 @@ public void Validate_ReturnsError_IfInstanceDoesNotMatchExactlyOneSchemaSpecifie { OneOf = [ - new OpenApiSchema { Type = "object", Required = new SortedSet { "p1" } }, - new OpenApiSchema { Type = "object", Required = new SortedSet { "p2" } }, - new OpenApiSchema { Type = "object", Required = new SortedSet { "p3" } } + new OpenApiSchema { Type = JsonSchemaTypes.Object, Required = new SortedSet { "p1" } }, + new OpenApiSchema { Type = JsonSchemaTypes.Object, Required = new SortedSet { "p2" } }, + new OpenApiSchema { Type = JsonSchemaTypes.Object, Required = new SortedSet { "p3" } } ] }; var instance = JToken.Parse(instanceText); @@ -608,7 +634,7 @@ public void Validate_SupportsReferencedSchemas_IfDefinedInProvidedOpenApiDocumen { Schemas = new Dictionary { - ["ref"] = new OpenApiSchema { Type = "number" } + ["ref"] = new OpenApiSchema { Type = JsonSchemaTypes.Number } } } }; diff --git a/test/Swashbuckle.AspNetCore.ApiTesting.Test/RequestValidatorTests.cs b/test/Swashbuckle.AspNetCore.ApiTesting.Test/RequestValidatorTests.cs index 10da34b01c..cfd76bf41c 100644 --- a/test/Swashbuckle.AspNetCore.ApiTesting.Test/RequestValidatorTests.cs +++ b/test/Swashbuckle.AspNetCore.ApiTesting.Test/RequestValidatorTests.cs @@ -5,6 +5,8 @@ using Microsoft.OpenApi.Models; using Xunit; +using JsonSchemaType = string; + namespace Swashbuckle.AspNetCore.ApiTesting.Test { public class RequestValidatorTests @@ -69,7 +71,7 @@ public void Validate_ThrowsException_IfRequiredQueryParameterIsNotPresent( { Name = "param", In = ParameterLocation.Query, - Schema = new OpenApiSchema { Type = "string" }, + Schema = new OpenApiSchema { Type = JsonSchemaTypes.String }, Required = true } } @@ -103,7 +105,7 @@ public void Validate_ThrowsException_IfRequiredHeaderParameterIsNotPresent( { Name = "test-header", In = ParameterLocation.Header, - Schema = new OpenApiSchema { Type = "string" }, + Schema = new OpenApiSchema { Type = JsonSchemaTypes.String }, Required = true } } @@ -123,16 +125,20 @@ public void Validate_ThrowsException_IfRequiredHeaderParameterIsNotPresent( Assert.Equal(expectedErrorMessage, exception?.Message); } + public static TheoryData PathParameterTypeMismatchData => new() + { + { "/api/products/foo", JsonSchemaTypes.Boolean, "Parameter 'param' is not of type 'boolean'" }, + { "/api/products/foo", JsonSchemaTypes.Number, "Parameter 'param' is not of type 'number'" }, + { "/api/products/true", JsonSchemaTypes.Boolean, null }, + { "/api/products/1", JsonSchemaTypes.Number, null }, + { "/api/products/foo", JsonSchemaTypes.String, null } + }; [Theory] - [InlineData("/api/products/foo", "boolean", "Parameter 'param' is not of type 'boolean'")] - [InlineData("/api/products/foo", "number", "Parameter 'param' is not of type 'number'")] - [InlineData("/api/products/true", "boolean", null)] - [InlineData("/api/products/1", "number", null)] - [InlineData("/api/products/foo", "string", null)] + [MemberData(nameof(PathParameterTypeMismatchData))] public void Validate_ThrowsException_IfPathParameterIsNotOfSpecifiedType( string uriString, - string specifiedType, + JsonSchemaType specifiedType, string expectedErrorMessage) { var openApiDocument = DocumentWithOperation("/api/products/{param}", OperationType.Get, new OpenApiOperation @@ -161,19 +167,25 @@ public void Validate_ThrowsException_IfPathParameterIsNotOfSpecifiedType( Assert.Equal(expectedErrorMessage, exception?.Message); } +#nullable enable + public static TheoryData QueryParameterTypeMismatchData => new() + { + { "/api/products?param=foo", JsonSchemaTypes.Boolean, null, "Parameter 'param' is not of type 'boolean'" }, + { "/api/products?param=foo", JsonSchemaTypes.Number, null, "Parameter 'param' is not of type 'number'" }, + { "/api/products?param=true", JsonSchemaTypes.Boolean, null, null }, + { "/api/products?param=1", JsonSchemaTypes.Number, null, null }, + { "/api/products?param=foo", JsonSchemaTypes.String, null, null }, + { "/api/products?param=1¶m=2", JsonSchemaTypes.Array, JsonSchemaTypes.Number, null }, + { "/api/products?param=1¶m=foo", JsonSchemaTypes.Array, JsonSchemaTypes.Number, "Parameter 'param' is not of type 'array[number]'" }, + }; + [Theory] - [InlineData("/api/products?param=foo", "boolean", null, "Parameter 'param' is not of type 'boolean'")] - [InlineData("/api/products?param=foo", "number", null, "Parameter 'param' is not of type 'number'")] - [InlineData("/api/products?param=1¶m=foo", "array", "number", "Parameter 'param' is not of type 'array[number]'")] - [InlineData("/api/products?param=true", "boolean", null, null)] - [InlineData("/api/products?param=1", "number", null, null)] - [InlineData("/api/products?param=foo", "string", null, null)] - [InlineData("/api/products?param=1¶m=2", "array", "number", null)] + [MemberData(nameof(QueryParameterTypeMismatchData))] public void Validate_ThrowsException_IfQueryParameterIsNotOfSpecifiedType( string path, - string specifiedType, - string specifiedItemsType, - string expectedErrorMessage) + JsonSchemaType specifiedType, + JsonSchemaType? specifiedItemsType, + string? expectedErrorMessage) { var openApiDocument = DocumentWithOperation("/api/products", OperationType.Get, new OpenApiOperation { @@ -205,19 +217,24 @@ public void Validate_ThrowsException_IfQueryParameterIsNotOfSpecifiedType( Assert.Equal(expectedErrorMessage, exception?.Message); } + public static TheoryData HeaderParameterTypeMismatchData => new() + { + { "foo", JsonSchemaTypes.Boolean, null, "Parameter 'test-header' is not of type 'boolean'" }, + { "foo", JsonSchemaTypes.Number, null, "Parameter 'test-header' is not of type 'number'" }, + { "true", JsonSchemaTypes.Boolean, null, null }, + { "1", JsonSchemaTypes.Number, null, null }, + { "foo", JsonSchemaTypes.String, null, null }, + { "1,2", JsonSchemaTypes.Array, JsonSchemaTypes.Number, null }, + { "1,foo", JsonSchemaTypes.Array, JsonSchemaTypes.Number, "Parameter 'test-header' is not of type 'array[number]'" }, + }; + [Theory] - [InlineData("foo", "boolean", null, "Parameter 'test-header' is not of type 'boolean'")] - [InlineData("foo", "number", null, "Parameter 'test-header' is not of type 'number'")] - [InlineData("1,foo", "array", "number", "Parameter 'test-header' is not of type 'array[number]'")] - [InlineData("true", "boolean", null, null)] - [InlineData("1", "number", null, null)] - [InlineData("foo", "string", null, null)] - [InlineData("1,2", "array", "number", null)] + [MemberData(nameof(HeaderParameterTypeMismatchData))] public void Validate_ThrowsException_IfHeaderParameterIsNotOfSpecifiedType( string parameterValue, - string specifiedType, - string specifiedItemsType, - string expectedErrorMessage) + JsonSchemaType specifiedType, + JsonSchemaType? specifiedItemsType, + string? expectedErrorMessage) { var openApiDocument = DocumentWithOperation("/api/products", OperationType.Get, new OpenApiOperation { @@ -249,6 +266,7 @@ public void Validate_ThrowsException_IfHeaderParameterIsNotOfSpecifiedType( Assert.Equal(expectedErrorMessage, exception?.Message); } +#nullable restore [Theory] [InlineData(null, "Required content is not present")] @@ -304,7 +322,7 @@ public void Validate_ThrowsException_IfContentMediaTypeIsNotSpecified( { RequestUri = new Uri("/api/products", UriKind.Relative), Method = HttpMethod.Post, - Content = new StringContent("{\"foo\":\"bar\"}", Encoding.UTF8, mediaType) + Content = new StringContent("{\"foo\":\"bar\"}", Encoding.UTF8, mediaType) }; var exception = Record.Exception(() => @@ -332,7 +350,7 @@ public void Validate_DelegatesContentValidationToInjectedContentValidators( { Schema = new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, Required = new SortedSet { "prop1", "prop2" } } } @@ -343,7 +361,7 @@ public void Validate_DelegatesContentValidationToInjectedContentValidators( { RequestUri = new Uri("/api/products", UriKind.Relative), Method = HttpMethod.Post, - Content = new StringContent(jsonString, Encoding.UTF8, "application/json") + Content = new StringContent(jsonString, Encoding.UTF8, "application/json") }; var exception = Record.Exception(() => diff --git a/test/Swashbuckle.AspNetCore.ApiTesting.Test/ResponseValidatorTests.cs b/test/Swashbuckle.AspNetCore.ApiTesting.Test/ResponseValidatorTests.cs index acfe0249d0..50efa39d41 100644 --- a/test/Swashbuckle.AspNetCore.ApiTesting.Test/ResponseValidatorTests.cs +++ b/test/Swashbuckle.AspNetCore.ApiTesting.Test/ResponseValidatorTests.cs @@ -5,6 +5,8 @@ using Microsoft.OpenApi.Models; using Xunit; +using JsonSchemaType = string; + namespace Swashbuckle.AspNetCore.ApiTesting.Test { public class ResponseValidatorTests @@ -74,19 +76,25 @@ public void Validate_ThrowsException_IfRequiredHeaderIsNotPresent( Assert.Equal(expectedErrorMessage, exception?.Message); } +#nullable enable + public static TheoryData HeaderTypeValidationData => new() + { + { "foo", JsonSchemaTypes.Boolean, null, "Header 'test-header' is not of type 'boolean'" }, + { "foo", JsonSchemaTypes.Number, null, "Header 'test-header' is not of type 'number'" }, + { "true", JsonSchemaTypes.Boolean, null, null }, + { "1", JsonSchemaTypes.Number, null, null }, + { "foo", JsonSchemaTypes.String, null, null }, + { "1,2", JsonSchemaTypes.Array, JsonSchemaTypes.Number, null }, + { "1,foo", JsonSchemaTypes.Array, JsonSchemaTypes.Number, "Header 'test-header' is not of type 'array[number]'" }, + }; + [Theory] - [InlineData("foo", "boolean", null, "Header 'test-header' is not of type 'boolean'")] - [InlineData("foo", "number", null, "Header 'test-header' is not of type 'number'")] - [InlineData("1,foo", "array", "number", "Header 'test-header' is not of type 'array[number]'")] - [InlineData("true", "boolean", null, null)] - [InlineData("1", "number", null, null)] - [InlineData("foo", "string", null, null)] - [InlineData("1,2", "array", "number", null)] + [MemberData(nameof(HeaderTypeValidationData))] public void Validate_ThrowsException_IfHeaderIsNotOfSpecifiedType( string headerValue, - string specifiedType, - string specifiedItemsType, - string expectedErrorMessage) + JsonSchemaType specifiedType, + JsonSchemaType? specifiedItemsType, + string? expectedErrorMessage) { var openApiDocument = DocumentWithOperation("/api/products", OperationType.Post, new OpenApiOperation { @@ -101,7 +109,7 @@ public void Validate_ThrowsException_IfHeaderIsNotOfSpecifiedType( Schema = new OpenApiSchema { Type = specifiedType, - Items = (specifiedItemsType != null) ? new OpenApiSchema { Type = specifiedItemsType } : null + Items = specifiedItemsType != null ? new OpenApiSchema { Type = specifiedItemsType } : null } } } @@ -121,6 +129,7 @@ public void Validate_ThrowsException_IfHeaderIsNotOfSpecifiedType( Assert.Equal(expectedErrorMessage, exception?.Message); } +#nullable restore [Theory] [InlineData(null, "Expected content is not present")] @@ -207,7 +216,7 @@ public void Validate_DelegatesContentValidationToInjectedContentValidators( { Schema = new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, Required = new SortedSet { "prop1", "prop2" } } } @@ -217,7 +226,7 @@ public void Validate_DelegatesContentValidationToInjectedContentValidators( }); var response = new HttpResponseMessage { - Content = new StringContent(jsonString, Encoding.UTF8, "application/json") + Content = new StringContent(jsonString, Encoding.UTF8, "application/json") }; var exception = Record.Exception(() => diff --git a/test/Swashbuckle.AspNetCore.ApiTesting.Test/Swashbuckle.AspNetCore.ApiTesting.Test.csproj b/test/Swashbuckle.AspNetCore.ApiTesting.Test/Swashbuckle.AspNetCore.ApiTesting.Test.csproj index 4e75f9981a..6ab653daf8 100644 --- a/test/Swashbuckle.AspNetCore.ApiTesting.Test/Swashbuckle.AspNetCore.ApiTesting.Test.csproj +++ b/test/Swashbuckle.AspNetCore.ApiTesting.Test/Swashbuckle.AspNetCore.ApiTesting.Test.csproj @@ -4,6 +4,10 @@ net9.0;net8.0 + + + + diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/DocumentProviderTests.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/DocumentProviderTests.cs index df18d9f05b..82ea48e277 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/DocumentProviderTests.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/DocumentProviderTests.cs @@ -3,7 +3,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Extensions.ApiDescriptions; -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.Swagger; using Xunit; @@ -53,7 +53,7 @@ public async Task DocumentProvider_ExposesGeneratedSwagger(Type startupType, str } stream.Position = 0L; - new OpenApiStreamReader().Read(stream, out var diagnostic); + var (_, diagnostic) = await OpenApiDocumentLoader.LoadWithDiagnosticsAsync(stream); Assert.NotNull(diagnostic); Assert.Empty(diagnostic.Errors); } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/OpenApiDocumentLoader.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/OpenApiDocumentLoader.cs new file mode 100644 index 0000000000..1489a5134b --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/OpenApiDocumentLoader.cs @@ -0,0 +1,23 @@ +using System.IO; +using System.Threading.Tasks; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Readers; + +namespace Swashbuckle.AspNetCore; + +internal static class OpenApiDocumentLoader +{ + public static async Task LoadAsync(Stream stream) + { + var reader = new OpenApiStreamReader(); + var document = reader.Read(stream, out OpenApiDiagnostic diagnostic); + return await Task.FromResult(document); + } + + public static async Task<(OpenApiDocument Document, OpenApiDiagnostic Diagnostic)> LoadWithDiagnosticsAsync(Stream stream) + { + var reader = new OpenApiStreamReader(); + var document = reader.Read(stream, out OpenApiDiagnostic diagnostic); + return await Task.FromResult((document, diagnostic)); + } +} diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerIntegrationTests.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerIntegrationTests.cs index 37c066ac83..9191b2c2b1 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerIntegrationTests.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerIntegrationTests.cs @@ -4,16 +4,13 @@ using System.Net.Http; using System.Reflection; #if NET8_0_OR_GREATER -using System.Net.Http.Json; #endif using System.Text; using System.Text.Json; using System.Threading.Tasks; +using Microsoft.OpenApi.Any; using Xunit; using ReDocApp = ReDoc; -using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Readers; -using Microsoft.OpenApi.Any; namespace Swashbuckle.AspNetCore.IntegrationTests { @@ -93,11 +90,11 @@ public async Task SwaggerEndpoint_ReturnsCorrectPriceExample_ForDifferentCulture CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; try { - var openApiDocument = new OpenApiStreamReader().Read(contentStream, out OpenApiDiagnostic diagnostic); - var example = openApiDocument.Components.Schemas["Product"].Example as OpenApiObject; - var price = (example["price"] as OpenApiDouble); - Assert.NotNull(price); - Assert.Equal(14.37, price.Value); + var openApiDocument = await OpenApiDocumentLoader.LoadAsync(contentStream); + var example = openApiDocument.Components.Schemas["Product"].Example; + var exampleObject = Assert.IsType(example); + double price = Assert.IsType(exampleObject["price"]).Value; + Assert.Equal(14.37, price); } finally { @@ -214,7 +211,8 @@ private static async Task AssertValidSwaggerJson(HttpClient client, string swagg Assert.True(swaggerResponse.IsSuccessStatusCode, $"IsSuccessStatusCode is false. Response: '{await swaggerResponse.Content.ReadAsStringAsync()}'"); using var contentStream = await swaggerResponse.Content.ReadAsStreamAsync(); - new OpenApiStreamReader().Read(contentStream, out OpenApiDiagnostic diagnostic); + var (_, diagnostic) = await OpenApiDocumentLoader.LoadWithDiagnosticsAsync(contentStream); + Assert.NotNull(diagnostic); Assert.Empty(diagnostic.Errors); } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq.DotNet9_0.verified.txt new file mode 100644 index 0000000000..a53ff05609 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq.DotNet9_0.verified.txt @@ -0,0 +1,54 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "CliExampleWithFactory", + "version": "1.0" + }, + "servers": [ + { + "url": "http://localhost:57556/" + } + ], + "paths": { + "/products": { + "get": { + "tags": [ + "Products" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Product": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "description": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=Basic.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=Basic.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=Basic.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=Basic.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_DotNet6_startupType=Basic.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=Basic.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt similarity index 99% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_DotNet6_startupType=Basic.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=Basic.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt index 360844ea55..32e5af36f3 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_DotNet6_startupType=Basic.Startup_swaggerRequestUri=v1.verified.txt +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=Basic.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -1283,8 +1283,7 @@ "parameters": [ { "name": "id", - "in": "path", - "required": true, + "in": "query", "schema": { "type": "integer", "format": "int32" @@ -1292,7 +1291,8 @@ }, { "name": "id", - "in": "query", + "in": "path", + "required": true, "schema": { "type": "integer", "format": "int32" @@ -1654,8 +1654,7 @@ "type": "string" } }, - "nullable": true, - "readOnly": true + "nullable": true } }, "additionalProperties": { } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CliExample.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CliExample.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CliExample.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CliExample.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CliExample.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CliExample.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..9d9eceda44 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CliExample.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,54 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "CliExample", + "version": "1.0" + }, + "servers": [ + { + "url": "http://localhost:51071" + } + ], + "paths": { + "/products": { + "get": { + "tags": [ + "Products" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Product": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "description": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ConfigFromFile.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ConfigFromFile.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ConfigFromFile.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ConfigFromFile.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ConfigFromFile.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ConfigFromFile.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..bc3d0e0d91 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ConfigFromFile.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,68 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "ConfigFromFile", + "version": "1.0" + }, + "paths": { + "/api/Products": { + "get": { + "tags": [ + "Products" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Product": { + "type": "object", + "properties": { + "foo": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + }, + "nullable": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomDocumentSerializer.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomDocumentSerializer.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomDocumentSerializer.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomDocumentSerializer.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomDocumentSerializer.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomDocumentSerializer.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..fb35c79785 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomDocumentSerializer.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,3 @@ +{ + "swagger": "DocumentSerializerTest3.0" +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIConfig.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIConfig.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIConfig.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIConfig.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIConfig.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIConfig.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..5b6aea9c44 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIConfig.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,49 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "CustomUIConfig", + "version": "1.0" + }, + "paths": { + "/products": { + "get": { + "tags": [ + "Products" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Product": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "description": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIIndex.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIIndex.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIIndex.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIIndex.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIIndex.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIIndex.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..cf5e337d2c --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIIndex.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,49 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "CustomUIIndex", + "version": "1.0" + }, + "paths": { + "/products": { + "get": { + "tags": [ + "Products" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Product": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "description": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=GenericControllers.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=GenericControllers.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=GenericControllers.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=GenericControllers.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=GenericControllers.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=GenericControllers.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..825a647384 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=GenericControllers.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,583 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Test API", + "version": "1" + }, + "paths": { + "/{tenantId}/orders": { + "post": { + "tags": [ + "Orders" + ], + "summary": "Creates a resource", + "parameters": [ + { + "name": "tenantId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The resource", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "text/plain": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "application/json": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "text/json": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Orders" + ], + "summary": "Delete by Ids", + "parameters": [ + { + "name": "tenantId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "deleting Ids", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Order" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Order" + } + } + }, + "application/*+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Order" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Deleted", + "content": { + "text/plain": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "application/json": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "text/json": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + }, + "404": { + "description": "Failed" + } + } + } + }, + "/{tenantId}/orders/DeleteById": { + "delete": { + "tags": [ + "Orders" + ], + "summary": "Delete by Id", + "parameters": [ + { + "name": "tenantId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "deleting Id", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Deleted", + "content": { + "text/plain": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "application/json": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "text/json": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + }, + "404": { + "description": "Failed" + } + } + } + }, + "/{tenantId}/orders/Delete/List": { + "delete": { + "tags": [ + "Orders" + ], + "summary": "Delete by Id List", + "parameters": [ + { + "name": "tenantId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "deleting Ids", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Order" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Order" + } + } + }, + "application/*+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Order" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Deleted", + "content": { + "text/plain": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "application/json": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "text/json": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + }, + "404": { + "description": "Failed" + } + } + } + }, + "/{tenantId}/products": { + "post": { + "tags": [ + "Products" + ], + "summary": "Creates a resource", + "parameters": [ + { + "name": "tenantId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The resource", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "text/plain": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "application/json": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "text/json": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Products" + ], + "summary": "Delete by Ids", + "parameters": [ + { + "name": "tenantId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "deleting Ids", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "application/*+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Deleted", + "content": { + "text/plain": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "application/json": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "text/json": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + }, + "404": { + "description": "Failed" + } + } + } + }, + "/{tenantId}/products/DeleteById": { + "delete": { + "tags": [ + "Products" + ], + "summary": "Delete by Id", + "parameters": [ + { + "name": "tenantId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "deleting Id", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Deleted", + "content": { + "text/plain": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "application/json": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "text/json": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + }, + "404": { + "description": "Failed" + } + } + } + }, + "/{tenantId}/products/Delete/List": { + "delete": { + "tags": [ + "Products" + ], + "summary": "Delete by Id List", + "parameters": [ + { + "name": "tenantId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "deleting Ids", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "application/*+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Deleted", + "content": { + "text/plain": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "application/json": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "text/json": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + }, + "404": { + "description": "Failed" + } + } + } + } + }, + "components": { + "schemas": { + "Order": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "subtotal": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "Product": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "description": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=1.0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=1.0.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=1.0.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=1.0.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=1.0.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=1.0.DotNet9_0.verified.txt new file mode 100644 index 0000000000..7ff2150aad --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=1.0.DotNet9_0.verified.txt @@ -0,0 +1,75 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Sample API 1.0", + "version": "1.0" + }, + "paths": { + "/Products": { + "get": { + "tags": [ + "Products" + ], + "parameters": [ + { + "name": "api-version", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Product": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "description": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=2.0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=2.0.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=2.0.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=2.0.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=2.0.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=2.0.DotNet9_0.verified.txt new file mode 100644 index 0000000000..292ba3ced1 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=MultipleVersions.Startup_swaggerRequestUri=2.0.DotNet9_0.verified.txt @@ -0,0 +1,215 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Sample API 2.0", + "version": "2.0" + }, + "paths": { + "/Products": { + "post": { + "tags": [ + "Products" + ], + "parameters": [ + { + "name": "api-version", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "application/json": { + "schema": { + "type": "integer", + "format": "int32" + } + }, + "text/json": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + } + } + }, + "get": { + "tags": [ + "Products" + ], + "parameters": [ + { + "name": "api-version", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } + } + } + } + } + }, + "/Products/{id}": { + "put": { + "tags": [ + "Products" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "api-version", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + }, + "delete": { + "tags": [ + "Products" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "api-version", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "Product": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "description": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=NSwagClientExample.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=NSwagClientExample.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=NSwagClientExample.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=NSwagClientExample.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_DotNet6_startupType=NSwagClientExample.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=NSwagClientExample.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt similarity index 62% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_DotNet6_startupType=NSwagClientExample.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=NSwagClientExample.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt index 26bbe84ab9..7671c6817e 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_DotNet6_startupType=NSwagClientExample.Startup_swaggerRequestUri=v1.verified.txt +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=NSwagClientExample.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -117,6 +117,68 @@ } } } + }, + "/SystemTextJsonAnimals": { + "post": { + "tags": [ + "SystemTextJsonAnimals" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/SystemTextJsonAnimal" + }, + { + "$ref": "#/components/schemas/SystemTextJsonCat" + }, + { + "$ref": "#/components/schemas/SystemTextJsonDog" + } + ] + } + }, + "text/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/SystemTextJsonAnimal" + }, + { + "$ref": "#/components/schemas/SystemTextJsonCat" + }, + { + "$ref": "#/components/schemas/SystemTextJsonDog" + } + ] + } + }, + "application/*+json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/SystemTextJsonAnimal" + }, + { + "$ref": "#/components/schemas/SystemTextJsonCat" + }, + { + "$ref": "#/components/schemas/SystemTextJsonDog" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } } }, "components": { @@ -219,6 +281,60 @@ "additionalProperties": false } ] + }, + "SystemTextJsonAnimal": { + "required": [ + "animalType" + ], + "type": "object", + "properties": { + "animalType": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "animalType", + "mapping": { + "Cat": "#/components/schemas/SystemTextJsonCat", + "Dog": "#/components/schemas/SystemTextJsonDog" + } + } + }, + "SystemTextJsonCat": { + "allOf": [ + { + "$ref": "#/components/schemas/SystemTextJsonAnimal" + }, + { + "type": "object", + "properties": { + "catSpecificProperty": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + ] + }, + "SystemTextJsonDog": { + "allOf": [ + { + "$ref": "#/components/schemas/SystemTextJsonAnimal" + }, + { + "type": "object", + "properties": { + "dogSpecificProperty": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + ] } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=OAuth2Integration.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=OAuth2Integration.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=OAuth2Integration.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=OAuth2Integration.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=OAuth2Integration.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=OAuth2Integration.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..7dccefdcbf --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=OAuth2Integration.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,247 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Test API V1", + "version": "v1" + }, + "servers": [ + { + "url": "/resource-server" + } + ], + "paths": { + "/products": { + "get": { + "tags": [ + "Products" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + } + }, + "security": [ + { + "oauth2": [ + "readAccess" + ] + } + ] + }, + "post": { + "tags": [ + "Products" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + } + }, + "responses": { + "200": { + "description": "OK" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + } + }, + "security": [ + { + "oauth2": [ + "writeAccess" + ] + } + ] + } + }, + "/products/{id}": { + "get": { + "tags": [ + "Products" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/Product" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + } + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + } + }, + "security": [ + { + "oauth2": [ + "readAccess" + ] + } + ] + }, + "delete": { + "tags": [ + "Products" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "401": { + "description": "Unauthorized" + }, + "403": { + "description": "Forbidden" + } + }, + "security": [ + { + "oauth2": [ + "writeAccess" + ] + } + ] + } + } + }, + "components": { + "schemas": { + "Product": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32", + "readOnly": true + }, + "serialNo": { + "type": "string", + "nullable": true + }, + "status": { + "$ref": "#/components/schemas/ProductStatus" + } + }, + "additionalProperties": false + }, + "ProductStatus": { + "enum": [ + 0, + 1 + ], + "type": "integer", + "format": "int32" + } + }, + "securitySchemes": { + "oauth2": { + "type": "oauth2", + "flows": { + "authorizationCode": { + "authorizationUrl": "/auth-server/connect/authorize", + "tokenUrl": "/auth-server/connect/token", + "scopes": { + "readAccess": "Access read operations", + "writeAccess": "Access write operations" + } + } + } + } + } + }, + "security": [ + { + "oauth2": [ + "readAccess", + "writeAccess" + ] + } + ] +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ReDoc.Startup_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ReDoc.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ReDoc.Startup_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ReDoc.Startup_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ReDoc.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ReDoc.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..27a5d6cfb0 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ReDoc.Startup_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,188 @@ +{ + "swagger": "2.0", + "info": { + "title": "ReDoc", + "version": "1.0" + }, + "paths": { + "/products": { + "post": { + "tags": [ + "Products" + ], + "consumes": [ + "application/json", + "text/json", + "application/*+json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Product" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "format": "int32", + "type": "integer" + } + } + } + }, + "get": { + "tags": [ + "Products" + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Product" + } + } + } + } + } + }, + "/products/{id}": { + "get": { + "tags": [ + "Products" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Product" + } + } + } + }, + "put": { + "tags": [ + "Products" + ], + "consumes": [ + "application/json", + "text/json", + "application/*+json" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "type": "integer", + "format": "int32" + }, + { + "in": "body", + "name": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Product" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + }, + "patch": { + "tags": [ + "Products" + ], + "consumes": [ + "application/json", + "text/json", + "application/*+json" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "type": "integer", + "format": "int32" + }, + { + "in": "body", + "name": "body", + "required": true, + "schema": { + "type": "object", + "additionalProperties": { } + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + }, + "delete": { + "tags": [ + "Products" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "definitions": { + "Product": { + "type": "object", + "properties": { + "id": { + "format": "int32", + "type": "integer" + }, + "description": { + "type": "string" + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=TestFirst.Startup_swaggerRequestUri=v1-generated.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=TestFirst.Startup_swaggerRequestUri=v1-generated.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=TestFirst.Startup_swaggerRequestUri=v1-generated.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=TestFirst.Startup_swaggerRequestUri=v1-generated.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=TestFirst.Startup_swaggerRequestUri=v1-generated.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=TestFirst.Startup_swaggerRequestUri=v1-generated.DotNet9_0.verified.txt new file mode 100644 index 0000000000..d484e89bc5 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=TestFirst.Startup_swaggerRequestUri=v1-generated.DotNet9_0.verified.txt @@ -0,0 +1,55 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Test-first Example API (Generated)", + "version": "v1" + }, + "paths": { + "/api/users": { + "post": { + "tags": [ + "Users" + ], + "operationId": "CreateUser", + "requestBody": { + "content": { + "application/json": { + "schema": { + "required": [ + "email", + "password" + ], + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + } + } + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "User created", + "headers": { + "Location": { + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "Invalid request" + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup_entryPointType=MinimalApp.Program_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=MinimalApp.Program_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup_entryPointType=MinimalApp.Program_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=MinimalApp.Program_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=MinimalApp.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=MinimalApp.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..2d32d11ab8 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=MinimalApp.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,74 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "MinimalApp", + "version": "v1" + }, + "paths": { + "/WeatherForecast": { + "get": { + "tags": [ + "WeatherForecast" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WeatherForecast" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WeatherForecast" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WeatherForecast" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "WeatherForecast": { + "type": "object", + "properties": { + "date": { + "type": "string", + "format": "date-time" + }, + "temperatureC": { + "type": "integer", + "format": "int32" + }, + "temperatureF": { + "type": "integer", + "format": "int32", + "readOnly": true + }, + "summary": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup_entryPointType=MvcWithNullable.Program_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=MvcWithNullable.Program_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup_entryPointType=MvcWithNullable.Program_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=MvcWithNullable.Program_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=MvcWithNullable.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=MvcWithNullable.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..37cdf55df7 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=MvcWithNullable.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,52 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "MvcWithNullable", + "version": "1.0" + }, + "paths": { + "/api/Enum": { + "get": { + "tags": [ + "Enum" + ], + "parameters": [ + { + "name": "logLevel", + "in": "query", + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/LogLevel" + } + ], + "default": 4 + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "LogLevel": { + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "type": "integer", + "format": "int32" + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup_entryPointType=TopLevelSwaggerDoc.Program_swaggerRequestUri=.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=TopLevelSwaggerDoc.Program_swaggerRequestUri=.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup_entryPointType=TopLevelSwaggerDoc.Program_swaggerRequestUri=.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=TopLevelSwaggerDoc.Program_swaggerRequestUri=.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=TopLevelSwaggerDoc.Program_swaggerRequestUri=.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=TopLevelSwaggerDoc.Program_swaggerRequestUri=.DotNet9_0.verified.txt new file mode 100644 index 0000000000..a8341b1285 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=TopLevelSwaggerDoc.Program_swaggerRequestUri=.DotNet9_0.verified.txt @@ -0,0 +1,9 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Test API", + "version": "1" + }, + "paths": { }, + "components": { } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup_entryPointType=WebApi.Aot.Program_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=WebApi.Aot.Program_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup_entryPointType=WebApi.Aot.Program_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=WebApi.Aot.Program_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=WebApi.Aot.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=WebApi.Aot.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt new file mode 100644 index 0000000000..6d8fa87df9 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=WebApi.Aot.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt @@ -0,0 +1,82 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Native AoT API V1", + "description": "A sample API for testing Swashbuckle with native AoT", + "termsOfService": "http://tempuri.org/terms", + "version": "v1" + }, + "paths": { + "/todos": { + "get": { + "tags": [ + "WebApi.Aot" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Todo" + } + } + } + } + } + } + } + }, + "/todos/{id}": { + "get": { + "tags": [ + "WebApi.Aot" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "Todo": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "title": { + "type": "string", + "nullable": true + }, + "dueBy": { + "type": "string", + "format": "date", + "nullable": true + }, + "isComplete": { + "type": "boolean" + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup_entryPointType=WebApi.Program_swaggerRequestUri=v1.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=WebApi.Program_swaggerRequestUri=v1.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup_entryPointType=WebApi.Program_swaggerRequestUri=v1.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=WebApi.Program_swaggerRequestUri=v1.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.TypesAreRenderedCorrectly.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=WebApi.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.TypesAreRenderedCorrectly.verified.txt rename to test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.Swagger_IsValidJson_No_Startup_entryPointType=WebApi.Program_swaggerRequestUri=v1.DotNet9_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.TypesAreRenderedCorrectly.DotNet8_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.TypesAreRenderedCorrectly.DotNet8_0.verified.txt new file mode 100644 index 0000000000..84b7b56421 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.TypesAreRenderedCorrectly.DotNet8_0.verified.txt @@ -0,0 +1,1101 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "WebApi", + "version": "v1" + }, + "paths": { + "/annotations/fruit/{id}": { + "post": { + "tags": [ + "Annotations" + ], + "summary": "CreateFruit", + "description": "Create a fruit", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The id of the fruit that will be created", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "Description for Body", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Fruit" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Description for response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Fruit" + } + } + } + } + } + } + }, + "/annotations/singleForm": { + "post": { + "tags": [ + "Annotations" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/PersonAnnotated" + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/PersonAnnotated" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/annotations/multipleForms": { + "post": { + "tags": [ + "Annotations" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PersonAnnotated" + }, + { + "$ref": "#/components/schemas/AddressAnnotated" + } + ] + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PersonAnnotated" + }, + { + "$ref": "#/components/schemas/AddressAnnotated" + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/annotations/IFromFileAndString": { + "post": { + "tags": [ + "Annotations" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "file", + "tags" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "description": "Description for File", + "format": "binary" + }, + "tags": { + "type": "string" + } + } + }, + "encoding": { + "file": { + "style": "form" + }, + "tags": { + "style": "form" + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/annotations/IFromFileAndEnum": { + "post": { + "tags": [ + "Annotations" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "dateTimeKind", + "file" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + }, + "dateTimeKind": { + "$ref": "#/components/schemas/DateTimeKind" + } + } + }, + "encoding": { + "file": { + "style": "form" + }, + "dateTimeKind": { + "style": "form" + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/annotations/IFromObjectAndString": { + "post": { + "tags": [ + "Annotations" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PersonAnnotated" + }, + { + "required": [ + "tags" + ], + "type": "object", + "properties": { + "tags": { + "type": "string" + } + } + } + ] + }, + "encoding": { + "tags": { + "style": "form" + } + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PersonAnnotated" + }, + { + "required": [ + "tags" + ], + "type": "object", + "properties": { + "tags": { + "type": "string" + } + } + } + ] + }, + "encoding": { + "tags": { + "style": "form" + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/annotations/AsParameters": { + "get": { + "tags": [ + "Annotations" + ], + "parameters": [ + { + "name": "paramOne", + "in": "query", + "description": "Description", + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "paramTwo", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "paramThree", + "in": "query", + "schema": { + "type": "string", + "format": "date-time" + } + }, + { + "name": "paramFour", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "date-time" + } + }, + { + "name": "paramFive", + "in": "query", + "schema": { + "type": "string", + "format": "date" + } + }, + { + "name": "paramSix", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "date" + } + }, + { + "name": "paramSeven", + "in": "query", + "schema": { + "type": "string", + "format": "time" + } + }, + { + "name": "paramEight", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "time" + } + }, + { + "name": "paramNine", + "in": "query", + "schema": { + "$ref": "#/components/schemas/DateTimeKind" + } + }, + { + "name": "paramTen", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/DateTimeKind" + } + }, + { + "name": "paramEleven", + "in": "query", + "schema": { + "type": "number", + "format": "double" + } + }, + { + "name": "paramTwelve", + "in": "query", + "required": true, + "schema": { + "type": "number", + "format": "double" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AsParametersRecord" + } + } + } + } + } + } + }, + "/TypeWithTryParse/{tryParse}": { + "get": { + "tags": [ + "WebApi" + ], + "parameters": [ + { + "name": "tryParse", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/weatherforecast": { + "get": { + "tags": [ + "WithOpenApi" + ], + "operationId": "GetWeatherForecast", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WeatherForecast" + } + } + } + } + } + } + } + }, + "/WithOpenApi/multipleForms": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/Person" + }, + { + "$ref": "#/components/schemas/Address" + } + ] + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/Person" + }, + { + "$ref": "#/components/schemas/Address" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromFile": { + "post": { + "tags": [ + "WithOpenApi" + ], + "parameters": [ + { + "name": "queryParameter", + "in": "query", + "description": "queryParameter Description", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "file" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + } + } + }, + "encoding": { + "file": { + "style": "form" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromFileCollection": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "collection" + ], + "type": "object", + "properties": { + "collection": { + "type": "array", + "items": { + "type": "string", + "format": "binary" + } + } + } + }, + "encoding": { + "collection": { + "style": "form" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromBody": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationCustomExchangeRatesDto" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromFileAndString": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "file", + "tags" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + }, + "tags": { + "type": "string" + } + } + }, + "encoding": { + "file": { + "style": "form" + }, + "tags": { + "style": "form" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromFileAndEnum": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "dateTimeKind", + "file" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + }, + "dateTimeKind": { + "$ref": "#/components/schemas/DateTimeKind" + } + } + }, + "encoding": { + "file": { + "style": "form" + }, + "dateTimeKind": { + "style": "form" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromObjectAndString": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/Person" + }, + { + "required": [ + "tags" + ], + "type": "object", + "properties": { + "tags": { + "type": "string" + } + } + } + ] + }, + "encoding": { + "tags": { + "style": "form" + } + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/Person" + }, + { + "required": [ + "tags" + ], + "type": "object", + "properties": { + "tags": { + "type": "string" + } + } + } + ] + }, + "encoding": { + "tags": { + "style": "form" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/XmlComments/Car/{id}": { + "get": { + "tags": [ + "Xml" + ], + "summary": "Returns a specific product", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The product id", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + }, + "example": 111 + } + ], + "responses": { + "200": { + "description": "A Product Id", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Address": { + "type": "object", + "properties": { + "street": { + "type": "string", + "nullable": true + }, + "city": { + "type": "string", + "nullable": true + }, + "state": { + "type": "string", + "nullable": true + }, + "zipCode": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "AddressAnnotated": { + "type": "object", + "properties": { + "street": { + "type": "string", + "description": "Description for Street", + "nullable": true + }, + "city": { + "type": "string", + "nullable": true + }, + "state": { + "type": "string", + "nullable": true + }, + "zipCode": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "AsParametersRecord": { + "type": "object", + "properties": { + "paramOne": { + "type": "string", + "format": "uuid", + "nullable": true + }, + "paramTwo": { + "type": "string", + "format": "uuid" + }, + "paramThree": { + "type": "string", + "format": "date-time", + "nullable": true + }, + "paramFour": { + "type": "string", + "format": "date-time" + }, + "paramFive": { + "type": "string", + "format": "date", + "nullable": true + }, + "paramSix": { + "type": "string", + "format": "date" + }, + "paramSeven": { + "type": "string", + "format": "time", + "nullable": true + }, + "paramEight": { + "type": "string", + "format": "time" + }, + "paramNine": { + "$ref": "#/components/schemas/DateTimeKind" + }, + "paramTen": { + "$ref": "#/components/schemas/DateTimeKind" + }, + "paramEleven": { + "type": "number", + "format": "double", + "nullable": true + }, + "paramTwelve": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "CurrenciesRate": { + "required": [ + "currencyFrom", + "currencyTo" + ], + "type": "object", + "properties": { + "currencyFrom": { + "type": "string", + "description": "Currency From", + "nullable": true + }, + "currencyTo": { + "type": "string", + "nullable": true + }, + "rate": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "DateTimeKind": { + "enum": [ + 0, + 1, + 2 + ], + "type": "integer", + "format": "int32" + }, + "Fruit": { + "type": "object", + "properties": { + "name": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false, + "description": "Description for Schema" + }, + "OrganizationCustomExchangeRatesDto": { + "required": [ + "currenciesRates" + ], + "type": "object", + "properties": { + "currenciesRates": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CurrenciesRate" + }, + "nullable": true + }, + "isUpdated": { + "type": "boolean", + "readOnly": true + } + }, + "additionalProperties": false + }, + "Person": { + "type": "object", + "properties": { + "firstName": { + "type": "string", + "nullable": true + }, + "lastName": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "PersonAnnotated": { + "type": "object", + "properties": { + "firstName": { + "type": "string", + "description": "Description for FirstName", + "nullable": true + }, + "lastName": { + "type": "string", + "description": "Description for LastName", + "nullable": true + } + }, + "additionalProperties": false + }, + "Product": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "Uniquely identifies the product", + "format": "int32" + }, + "description": { + "type": "string", + "description": "Describes the product", + "nullable": true + } + }, + "additionalProperties": false, + "description": "Represents a product" + }, + "WeatherForecast": { + "type": "object", + "properties": { + "date": { + "type": "string", + "format": "date" + }, + "temperatureC": { + "type": "integer", + "format": "int32" + }, + "summary": { + "type": "string", + "nullable": true + }, + "temperatureF": { + "type": "integer", + "format": "int32", + "readOnly": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.TypesAreRenderedCorrectly.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.TypesAreRenderedCorrectly.DotNet9_0.verified.txt new file mode 100644 index 0000000000..84b7b56421 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.TypesAreRenderedCorrectly.DotNet9_0.verified.txt @@ -0,0 +1,1101 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "WebApi", + "version": "v1" + }, + "paths": { + "/annotations/fruit/{id}": { + "post": { + "tags": [ + "Annotations" + ], + "summary": "CreateFruit", + "description": "Create a fruit", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The id of the fruit that will be created", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "Description for Body", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Fruit" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Description for response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Fruit" + } + } + } + } + } + } + }, + "/annotations/singleForm": { + "post": { + "tags": [ + "Annotations" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/PersonAnnotated" + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/PersonAnnotated" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/annotations/multipleForms": { + "post": { + "tags": [ + "Annotations" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PersonAnnotated" + }, + { + "$ref": "#/components/schemas/AddressAnnotated" + } + ] + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PersonAnnotated" + }, + { + "$ref": "#/components/schemas/AddressAnnotated" + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/annotations/IFromFileAndString": { + "post": { + "tags": [ + "Annotations" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "file", + "tags" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "description": "Description for File", + "format": "binary" + }, + "tags": { + "type": "string" + } + } + }, + "encoding": { + "file": { + "style": "form" + }, + "tags": { + "style": "form" + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/annotations/IFromFileAndEnum": { + "post": { + "tags": [ + "Annotations" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "dateTimeKind", + "file" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + }, + "dateTimeKind": { + "$ref": "#/components/schemas/DateTimeKind" + } + } + }, + "encoding": { + "file": { + "style": "form" + }, + "dateTimeKind": { + "style": "form" + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/annotations/IFromObjectAndString": { + "post": { + "tags": [ + "Annotations" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PersonAnnotated" + }, + { + "required": [ + "tags" + ], + "type": "object", + "properties": { + "tags": { + "type": "string" + } + } + } + ] + }, + "encoding": { + "tags": { + "style": "form" + } + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PersonAnnotated" + }, + { + "required": [ + "tags" + ], + "type": "object", + "properties": { + "tags": { + "type": "string" + } + } + } + ] + }, + "encoding": { + "tags": { + "style": "form" + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/annotations/AsParameters": { + "get": { + "tags": [ + "Annotations" + ], + "parameters": [ + { + "name": "paramOne", + "in": "query", + "description": "Description", + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "paramTwo", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "paramThree", + "in": "query", + "schema": { + "type": "string", + "format": "date-time" + } + }, + { + "name": "paramFour", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "date-time" + } + }, + { + "name": "paramFive", + "in": "query", + "schema": { + "type": "string", + "format": "date" + } + }, + { + "name": "paramSix", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "date" + } + }, + { + "name": "paramSeven", + "in": "query", + "schema": { + "type": "string", + "format": "time" + } + }, + { + "name": "paramEight", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "time" + } + }, + { + "name": "paramNine", + "in": "query", + "schema": { + "$ref": "#/components/schemas/DateTimeKind" + } + }, + { + "name": "paramTen", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/DateTimeKind" + } + }, + { + "name": "paramEleven", + "in": "query", + "schema": { + "type": "number", + "format": "double" + } + }, + { + "name": "paramTwelve", + "in": "query", + "required": true, + "schema": { + "type": "number", + "format": "double" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AsParametersRecord" + } + } + } + } + } + } + }, + "/TypeWithTryParse/{tryParse}": { + "get": { + "tags": [ + "WebApi" + ], + "parameters": [ + { + "name": "tryParse", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/weatherforecast": { + "get": { + "tags": [ + "WithOpenApi" + ], + "operationId": "GetWeatherForecast", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WeatherForecast" + } + } + } + } + } + } + } + }, + "/WithOpenApi/multipleForms": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/Person" + }, + { + "$ref": "#/components/schemas/Address" + } + ] + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/Person" + }, + { + "$ref": "#/components/schemas/Address" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromFile": { + "post": { + "tags": [ + "WithOpenApi" + ], + "parameters": [ + { + "name": "queryParameter", + "in": "query", + "description": "queryParameter Description", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "file" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + } + } + }, + "encoding": { + "file": { + "style": "form" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromFileCollection": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "collection" + ], + "type": "object", + "properties": { + "collection": { + "type": "array", + "items": { + "type": "string", + "format": "binary" + } + } + } + }, + "encoding": { + "collection": { + "style": "form" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromBody": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationCustomExchangeRatesDto" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromFileAndString": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "file", + "tags" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + }, + "tags": { + "type": "string" + } + } + }, + "encoding": { + "file": { + "style": "form" + }, + "tags": { + "style": "form" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromFileAndEnum": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "dateTimeKind", + "file" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + }, + "dateTimeKind": { + "$ref": "#/components/schemas/DateTimeKind" + } + } + }, + "encoding": { + "file": { + "style": "form" + }, + "dateTimeKind": { + "style": "form" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/WithOpenApi/IFromObjectAndString": { + "post": { + "tags": [ + "WithOpenApi" + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/Person" + }, + { + "required": [ + "tags" + ], + "type": "object", + "properties": { + "tags": { + "type": "string" + } + } + } + ] + }, + "encoding": { + "tags": { + "style": "form" + } + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/Person" + }, + { + "required": [ + "tags" + ], + "type": "object", + "properties": { + "tags": { + "type": "string" + } + } + } + ] + }, + "encoding": { + "tags": { + "style": "form" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/XmlComments/Car/{id}": { + "get": { + "tags": [ + "Xml" + ], + "summary": "Returns a specific product", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The product id", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + }, + "example": 111 + } + ], + "responses": { + "200": { + "description": "A Product Id", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Address": { + "type": "object", + "properties": { + "street": { + "type": "string", + "nullable": true + }, + "city": { + "type": "string", + "nullable": true + }, + "state": { + "type": "string", + "nullable": true + }, + "zipCode": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "AddressAnnotated": { + "type": "object", + "properties": { + "street": { + "type": "string", + "description": "Description for Street", + "nullable": true + }, + "city": { + "type": "string", + "nullable": true + }, + "state": { + "type": "string", + "nullable": true + }, + "zipCode": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "AsParametersRecord": { + "type": "object", + "properties": { + "paramOne": { + "type": "string", + "format": "uuid", + "nullable": true + }, + "paramTwo": { + "type": "string", + "format": "uuid" + }, + "paramThree": { + "type": "string", + "format": "date-time", + "nullable": true + }, + "paramFour": { + "type": "string", + "format": "date-time" + }, + "paramFive": { + "type": "string", + "format": "date", + "nullable": true + }, + "paramSix": { + "type": "string", + "format": "date" + }, + "paramSeven": { + "type": "string", + "format": "time", + "nullable": true + }, + "paramEight": { + "type": "string", + "format": "time" + }, + "paramNine": { + "$ref": "#/components/schemas/DateTimeKind" + }, + "paramTen": { + "$ref": "#/components/schemas/DateTimeKind" + }, + "paramEleven": { + "type": "number", + "format": "double", + "nullable": true + }, + "paramTwelve": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "CurrenciesRate": { + "required": [ + "currencyFrom", + "currencyTo" + ], + "type": "object", + "properties": { + "currencyFrom": { + "type": "string", + "description": "Currency From", + "nullable": true + }, + "currencyTo": { + "type": "string", + "nullable": true + }, + "rate": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "DateTimeKind": { + "enum": [ + 0, + 1, + 2 + ], + "type": "integer", + "format": "int32" + }, + "Fruit": { + "type": "object", + "properties": { + "name": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false, + "description": "Description for Schema" + }, + "OrganizationCustomExchangeRatesDto": { + "required": [ + "currenciesRates" + ], + "type": "object", + "properties": { + "currenciesRates": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CurrenciesRate" + }, + "nullable": true + }, + "isUpdated": { + "type": "boolean", + "readOnly": true + } + }, + "additionalProperties": false + }, + "Person": { + "type": "object", + "properties": { + "firstName": { + "type": "string", + "nullable": true + }, + "lastName": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "PersonAnnotated": { + "type": "object", + "properties": { + "firstName": { + "type": "string", + "description": "Description for FirstName", + "nullable": true + }, + "lastName": { + "type": "string", + "description": "Description for LastName", + "nullable": true + } + }, + "additionalProperties": false + }, + "Product": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "Uniquely identifies the product", + "format": "int32" + }, + "description": { + "type": "string", + "description": "Describes the product", + "nullable": true + } + }, + "additionalProperties": false, + "description": "Represents a product" + }, + "WeatherForecast": { + "type": "object", + "properties": { + "date": { + "type": "string", + "format": "date" + }, + "temperatureC": { + "type": "integer", + "format": "int32" + }, + "summary": { + "type": "string", + "nullable": true + }, + "temperatureF": { + "type": "integer", + "format": "int32", + "readOnly": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.cs index 9490399a60..d0e022b835 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerVerifyIntegrationTest.cs @@ -12,10 +12,8 @@ namespace Swashbuckle.AspNetCore.IntegrationTests public partial class SwaggerVerifyIntegrationTest { [Theory] -#if !NET6_0 [InlineData(typeof(Basic.Startup), "/swagger/v1/swagger.json")] [InlineData(typeof(NSwagClientExample.Startup), "/swagger/v1/swagger.json")] -#endif [InlineData(typeof(CliExample.Startup), "/swagger/v1/swagger_net8.0.json")] [InlineData(typeof(ConfigFromFile.Startup), "/swagger/v1/swagger.json")] [InlineData(typeof(CustomDocumentSerializer.Startup), "/swagger/v1/swagger.json")] @@ -38,7 +36,8 @@ public async Task SwaggerEndpoint_ReturnsValidSwaggerJson( var swagger = await swaggerResponse.Content.ReadAsStringAsync(); await Verifier.Verify(NormalizeLineBreaks(swagger)) - .UseParameters(startupType, GetVersion(swaggerRequestUri)); + .UseParameters(startupType, GetVersion(swaggerRequestUri)) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -52,43 +51,27 @@ public async Task SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq() using var swaggerResponse = await client.GetAsync(swaggerRequestUri); var swagger = await swaggerResponse.Content.ReadAsStringAsync(); - await Verifier.Verify(swagger).UseParameters(startupType, GetVersion(swaggerRequestUri)); + await Verifier.Verify(swagger) + .UseParameters(startupType, GetVersion(swaggerRequestUri)) + .UniqueForTargetFrameworkAndVersion(); } -#if NET6_0 - [Theory] - [InlineData(typeof(Basic.Startup), "/swagger/v1/swagger.json")] - [InlineData(typeof(NSwagClientExample.Startup), "/swagger/v1/swagger.json")] - public async Task SwaggerEndpoint_ReturnsValidSwaggerJson_DotNet6( - Type startupType, - string swaggerRequestUri) - { - var testSite = new TestSite(startupType); - using var client = testSite.BuildClient(); - - using var swaggerResponse = await client.GetAsync(swaggerRequestUri); - var swagger = await swaggerResponse.Content.ReadAsStringAsync(); - await Verifier.Verify(swagger).UseParameters(startupType, GetVersion(swaggerRequestUri)); - } -#endif - [Theory] [InlineData(typeof(MinimalApp.Program), "/swagger/v1/swagger.json")] [InlineData(typeof(TopLevelSwaggerDoc.Program), "/swagger/v1.json")] -#if NET8_0_OR_GREATER [InlineData(typeof(MvcWithNullable.Program), "/swagger/v1/swagger.json")] [InlineData(typeof(WebApi.Program), "/swagger/v1/swagger.json")] [InlineData(typeof(WebApi.Aot.Program), "/swagger/v1/swagger.json")] -#endif - public async Task SwaggerEndpoint_ReturnsValidSwaggerJson_Without_Startup( + public async Task Swagger_IsValidJson_No_Startup( Type entryPointType, string swaggerRequestUri) { var swaggerResponse = await SwaggerEndpointReturnsValidSwaggerJson(entryPointType, swaggerRequestUri); - await Verifier.Verify(swaggerResponse).UseParameters(entryPointType, GetVersion(swaggerRequestUri)); + await Verifier.Verify(swaggerResponse) + .UseParameters(entryPointType, GetVersion(swaggerRequestUri)) + .UniqueForTargetFrameworkAndVersion(); } -#if NET8_0_OR_GREATER [Fact] public async Task TypesAreRenderedCorrectly() { @@ -96,9 +79,9 @@ public async Task TypesAreRenderedCorrectly() using var client = application.CreateDefaultClient(); var swaggerResponse = await SwaggerResponse(client, "/swagger/v1/swagger.json"); - await Verifier.Verify(swaggerResponse); + await Verifier.Verify(swaggerResponse) + .UniqueForTargetFrameworkAndVersion(); } -#endif private static async Task SwaggerEndpointReturnsValidSwaggerJson(Type entryPointType, string swaggerRequestUri) { @@ -122,14 +105,10 @@ private static string NormalizeLineBreaks(string swagger) } private static string GetVersion(string swaggerUi) => -#if NET6_0 - Regex.Match(swaggerUi, "/\\w+/([\\w+\\d+.-]+)/").Groups[1].Value; -#else VersionRegex().Match(swaggerUi).Groups[1].Value; [GeneratedRegex("/\\w+/([\\w+\\d+.-]+)/")] private static partial Regex VersionRegex(); -#endif [GeneratedRegex(@"(? - - + + - - + + diff --git a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Fixtures/RecursiveCallSchemaFilter.cs b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Fixtures/RecursiveCallSchemaFilter.cs index 2af5fd5e2d..a761a2f11e 100644 --- a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Fixtures/RecursiveCallSchemaFilter.cs +++ b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Fixtures/RecursiveCallSchemaFilter.cs @@ -7,7 +7,7 @@ public class RecursiveCallSchemaFilter : ISchemaFilter { public void Apply(OpenApiSchema model, SchemaFilterContext context) { - if (model.Type == "object") + if (model.Type == JsonSchemaTypes.Object) { model.Properties.Add("Self", context.SchemaGenerator.GenerateSchema(context.Type, context.SchemaRepository)); } diff --git a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs index fd20157b85..cab00bed63 100644 --- a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs +++ b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs @@ -17,6 +17,8 @@ using Swashbuckle.AspNetCore.TestSupport; using Xunit; +using JsonSchemaType = string; + namespace Swashbuckle.AspNetCore.Newtonsoft.Test { public class NewtonsoftSchemaGeneratorTests @@ -29,49 +31,54 @@ public void GenerateSchema_GeneratesFileSchema_BinaryStringResultType(Type type) { var schema = Subject().GenerateSchema(type, new SchemaRepository()); - Assert.Equal("string", schema.Type); + Assert.Equal(JsonSchemaTypes.String, schema.Type); Assert.Equal("binary", schema.Format); } - [Theory] - [InlineData(typeof(bool), "boolean", null)] - [InlineData(typeof(byte), "integer", "int32")] - [InlineData(typeof(sbyte), "integer", "int32")] - [InlineData(typeof(short), "integer", "int32")] - [InlineData(typeof(ushort), "integer", "int32")] - [InlineData(typeof(int), "integer", "int32")] - [InlineData(typeof(uint), "integer", "int32")] - [InlineData(typeof(long), "integer", "int64")] - [InlineData(typeof(ulong), "integer", "int64")] - [InlineData(typeof(float), "number", "float")] - [InlineData(typeof(double), "number", "double")] - [InlineData(typeof(decimal), "number", "double")] - [InlineData(typeof(string), "string", null)] - [InlineData(typeof(char), "string", null)] - [InlineData(typeof(byte[]), "string", "byte")] - [InlineData(typeof(DateTime), "string", "date-time")] - [InlineData(typeof(DateTimeOffset), "string", "date-time")] - [InlineData(typeof(TimeSpan), "string", "date-span")] - [InlineData(typeof(Guid), "string", "uuid")] - [InlineData(typeof(Uri), "string", "uri")] - [InlineData(typeof(Version), "string", null)] - [InlineData(typeof(DateOnly), "string", "date")] - [InlineData(typeof(TimeOnly), "string", "time")] - [InlineData(typeof(bool?), "boolean", null)] - [InlineData(typeof(int?), "integer", "int32")] - [InlineData(typeof(DateTime?), "string", "date-time")] - [InlineData(typeof(Guid?), "string", "uuid")] - [InlineData(typeof(DateOnly?), "string", "date")] - [InlineData(typeof(TimeOnly?), "string", "time")] + public static TheoryData PrimitiveTypeData => new() + { + { typeof(bool), JsonSchemaTypes.Boolean, null }, + { typeof(byte), JsonSchemaTypes.Integer, "int32" }, + { typeof(sbyte), JsonSchemaTypes.Integer, "int32" }, + { typeof(short), JsonSchemaTypes.Integer, "int32" }, + { typeof(ushort), JsonSchemaTypes.Integer, "int32" }, + { typeof(int), JsonSchemaTypes.Integer, "int32" }, + { typeof(uint), JsonSchemaTypes.Integer, "int32" }, + { typeof(long), JsonSchemaTypes.Integer, "int64" }, + { typeof(ulong), JsonSchemaTypes.Integer, "int64" }, + { typeof(float), JsonSchemaTypes.Number, "float" }, + { typeof(double), JsonSchemaTypes.Number, "double" }, + { typeof(decimal), JsonSchemaTypes.Number, "double" }, + { typeof(string), JsonSchemaTypes.String, null }, + { typeof(char), JsonSchemaTypes.String, null }, + { typeof(byte[]), JsonSchemaTypes.String, "byte" }, + { typeof(DateTime), JsonSchemaTypes.String, "date-time" }, + { typeof(DateTimeOffset), JsonSchemaTypes.String, "date-time" }, + { typeof(TimeSpan), JsonSchemaTypes.String, "date-span" }, + { typeof(Guid), JsonSchemaTypes.String, "uuid" }, + { typeof(Uri), JsonSchemaTypes.String, "uri" }, + { typeof(Version), JsonSchemaTypes.String, null }, + { typeof(DateOnly), JsonSchemaTypes.String, "date" }, + { typeof(TimeOnly), JsonSchemaTypes.String, "time" }, + { typeof(bool?), JsonSchemaTypes.Boolean, null }, + { typeof(int?), JsonSchemaTypes.Integer, "int32" }, + { typeof(DateTime?), JsonSchemaTypes.String, "date-time" }, + { typeof(Guid?), JsonSchemaTypes.String, "uuid" }, + { typeof(DateOnly?), JsonSchemaTypes.String, "date" }, + { typeof(TimeOnly?), JsonSchemaTypes.String, "time" }, #if NET7_0_OR_GREATER - [InlineData(typeof(Int128), "integer", "int128")] - [InlineData(typeof(Int128?), "integer", "int128")] - [InlineData(typeof(UInt128), "integer", "int128")] - [InlineData(typeof(UInt128?), "integer", "int128")] + { typeof(Int128), JsonSchemaTypes.Integer, "int128" }, + { typeof(Int128?), JsonSchemaTypes.Integer, "int128" }, + { typeof(UInt128), JsonSchemaTypes.Integer, "int128" }, + { typeof(UInt128?), JsonSchemaTypes.Integer, "int128" }, #endif + }; + + [Theory] + [MemberData(nameof(PrimitiveTypeData))] public void GenerateSchema_GeneratesPrimitiveSchema_IfPrimitiveOrNullablePrimitiveType( Type type, - string expectedSchemaType, + JsonSchemaType expectedSchemaType, string expectedFormat) { var schema = Subject().GenerateSchema(type, new SchemaRepository()); @@ -80,14 +87,19 @@ public void GenerateSchema_GeneratesPrimitiveSchema_IfPrimitiveOrNullablePrimiti Assert.Equal(expectedFormat, schema.Format); } + public static TheoryData GenerateSchema_GeneratesReferencedEnumSchema_IfEnumType_Data => new() + { + { typeof(IntEnum), JsonSchemaTypes.Integer, "int32", 3 }, + { typeof(LongEnum), JsonSchemaTypes.Integer, "int64", 3 }, + { typeof(IntEnum?), JsonSchemaTypes.Integer, "int32", 3 }, + { typeof(LongEnum?), JsonSchemaTypes.Integer, "int64", 3 }, + }; + [Theory] - [InlineData(typeof(IntEnum), "integer", "int32", 3)] - [InlineData(typeof(LongEnum), "integer", "int64", 3)] - [InlineData(typeof(IntEnum?), "integer", "int32", 3)] - [InlineData(typeof(LongEnum?), "integer", "int64", 3)] + [MemberData(nameof(GenerateSchema_GeneratesReferencedEnumSchema_IfEnumType_Data))] public void GenerateSchema_GeneratesReferencedEnumSchema_IfEnumOrNullableEnumType( Type type, - string expectedSchemaType, + JsonSchemaType expectedSchemaType, string expectedFormat, int expectedEnumCount) { @@ -116,29 +128,36 @@ public void GenerateSchema_DedupsEnumValues_IfEnumTypeHasDuplicateValues() Assert.Equal(enumType.GetEnumValues().Cast().Distinct().Count(), schema.Enum.Count); } +#nullable enable + public static TheoryData GenerateSchema_GeneratesDictionarySchema_IfDictionaryType_Data => new() + { + { typeof(IDictionary), JsonSchemaTypes.Integer }, + { typeof(IReadOnlyDictionary), JsonSchemaTypes.Boolean }, + { typeof(IDictionary), null }, + { typeof(ExpandoObject), null }, + }; + [Theory] - [InlineData(typeof(IDictionary), "integer")] - [InlineData(typeof(IReadOnlyDictionary), "boolean")] - [InlineData(typeof(IDictionary), null)] - [InlineData(typeof(ExpandoObject), null)] + [MemberData(nameof(GenerateSchema_GeneratesDictionarySchema_IfDictionaryType_Data))] public void GenerateSchema_GeneratesDictionarySchema_IfDictionaryType( Type type, - string expectedAdditionalPropertiesType) + JsonSchemaType? expectedAdditionalPropertiesType) { var schema = Subject().GenerateSchema(type, new SchemaRepository()); - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.True(schema.AdditionalPropertiesAllowed); Assert.NotNull(schema.AdditionalProperties); Assert.Equal(expectedAdditionalPropertiesType, schema.AdditionalProperties.Type); } +#nullable restore [Fact] public void GenerateSchema_GeneratesObjectSchema_IfDictionaryTypeHasEnumKey() { var schema = Subject().GenerateSchema(typeof(IDictionary), new SchemaRepository()); - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.Equal(["Value2", "Value4", "Value8"], schema.Properties.Keys); } @@ -151,30 +170,37 @@ public void GenerateSchema_GeneratesReferencedDictionarySchema_IfDictionaryTypeI Assert.NotNull(referenceSchema.Reference); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.True(schema.AdditionalPropertiesAllowed); Assert.NotNull(schema.AdditionalProperties); Assert.Equal(schema.AdditionalProperties.Reference.Id, referenceSchema.Reference.Id); // ref to self } +#nullable enable + public static TheoryData EnumerableTypesData => new() + { + { typeof(int[]), JsonSchemaTypes.Integer, "int32" }, + { typeof(IEnumerable), JsonSchemaTypes.String, null }, + { typeof(DateTime?[]), JsonSchemaTypes.String, "date-time" }, + { typeof(int[][]), JsonSchemaTypes.Array, null }, + { typeof(IList), null, null } + }; + [Theory] - [InlineData(typeof(int[]), "integer", "int32")] - [InlineData(typeof(IEnumerable), "string", null)] - [InlineData(typeof(DateTime?[]), "string", "date-time")] - [InlineData(typeof(int[][]), "array", null)] - [InlineData(typeof(IList), null, null)] + [MemberData(nameof(EnumerableTypesData))] public void GenerateSchema_GeneratesArraySchema_IfEnumerableType( Type type, - string expectedItemsType, - string expectedItemsFormat) + JsonSchemaType? expectedItemsType, + string? expectedItemsFormat) { var schema = Subject().GenerateSchema(type, new SchemaRepository()); - Assert.Equal("array", schema.Type); + Assert.Equal(JsonSchemaTypes.Array, schema.Type); Assert.NotNull(schema.Items); Assert.Equal(expectedItemsType, schema.Items.Type); Assert.Equal(expectedItemsFormat, schema.Items.Format); } +#nullable restore [Theory] [InlineData(typeof(ISet))] @@ -184,7 +210,7 @@ public void GenerateSchema_SetsUniqueItems_IfEnumerableTypeIsSetOrKeyedCollectio { var schema = Subject().GenerateSchema(type, new SchemaRepository()); - Assert.Equal("array", schema.Type); + Assert.Equal(JsonSchemaTypes.Array, schema.Type); Assert.True(schema.UniqueItems); } @@ -197,7 +223,7 @@ public void GenerateSchema_GeneratesReferencedArraySchema_IfEnumerableTypeIsSelf Assert.NotNull(referenceSchema.Reference); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("array", schema.Type); + Assert.Equal(JsonSchemaTypes.Array, schema.Type); Assert.Equal(schema.Items.Reference.Id, referenceSchema.Reference.Id); // ref to self } @@ -218,7 +244,7 @@ public void GenerateSchema_GeneratesReferencedObjectSchema_IfComplexType( Assert.NotNull(referenceSchema.Reference); Assert.Equal(expectedSchemaId, referenceSchema.Reference.Id); var schema = schemaRepository.Schemas[expectedSchemaId]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.Equal(expectedProperties, schema.Properties.Keys); Assert.False(schema.AdditionalPropertiesAllowed); } @@ -231,7 +257,7 @@ public void GenerateSchema_IncludesInheritedProperties_IfComplexTypeIsDerived() var referenceSchema = Subject().GenerateSchema(typeof(SubType1), schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.Equal(["Property1", "BaseProperty"], schema.Properties.Keys); } @@ -243,7 +269,7 @@ public void GenerateSchema_ExcludesIndexerProperties_IfComplexTypeIsIndexed() var referenceSchema = Subject().GenerateSchema(typeof(IndexedType), schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.Equal(["Property1"], schema.Properties.Keys); } @@ -274,8 +300,8 @@ public void GenerateSchema_SetsNullableFlag_IfPropertyIsReferenceOrNullableType( [InlineData(typeof(TypeWithDefaultAttributes), nameof(TypeWithDefaultAttributes.StringWithDefault), "\"foobar\"")] [InlineData(typeof(TypeWithDefaultAttributes), nameof(TypeWithDefaultAttributes.IntArrayWithDefault), "[\n 1,\n 2,\n 3\n]")] [InlineData(typeof(TypeWithDefaultAttributes), nameof(TypeWithDefaultAttributes.StringArrayWithDefault), "[\n \"foo\",\n \"bar\"\n]")] - [InlineData(typeof(TypeWithDefaultAttributes), nameof(TypeWithDefaultAttributes.NullableIntWithDefaultNullValue), "null")] [InlineData(typeof(TypeWithDefaultAttributes), nameof(TypeWithDefaultAttributes.NullableIntWithDefaultValue), "2147483647")] + [InlineData(typeof(TypeWithDefaultAttributes), nameof(TypeWithDefaultAttributes.NullableIntWithDefaultNullValue), "null")] [UseInvariantCulture] public void GenerateSchema_SetsDefault_IfPropertyHasDefaultValueAttribute( Type declaringType, @@ -288,8 +314,7 @@ public void GenerateSchema_SetsDefault_IfPropertyHasDefaultValueAttribute( var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; var propertySchema = schema.Properties[propertyName]; - Assert.NotNull(propertySchema.Default); - Assert.Equal(expectedDefaultAsJson, propertySchema.Default.ToJson()); + Assert.Equal(expectedDefaultAsJson, propertySchema.Default?.ToJson()); } [Fact] @@ -326,7 +351,7 @@ public void GenerateSchema_SetsValidationProperties_IfComplexTypeHasValidationAt Assert.Equal(true, schema.Properties["IntWithExclusiveRange"].ExclusiveMinimum); Assert.Equal(true, schema.Properties["IntWithExclusiveRange"].ExclusiveMaximum); Assert.Equal("byte", schema.Properties["StringWithBase64"].Format); - Assert.Equal("string", schema.Properties["StringWithBase64"].Type); + Assert.Equal(JsonSchemaTypes.String, schema.Properties["StringWithBase64"].Type); #endif Assert.Null(schema.Properties["IntWithRange"].ExclusiveMinimum); Assert.Null(schema.Properties["IntWithRange"].ExclusiveMaximum); @@ -381,11 +406,11 @@ public void GenerateSchema_SupportsOption_CustomTypeMappings( Type type) { var subject = Subject( - configureGenerator: c => c.CustomTypeMappings.Add(mappingType, () => new OpenApiSchema { Type = "string" }) + configureGenerator: c => c.CustomTypeMappings.Add(mappingType, () => new OpenApiSchema { Type = JsonSchemaTypes.String }) ); var schema = subject.GenerateSchema(type, new SchemaRepository()); - Assert.Equal("string", schema.Type); + Assert.Equal(JsonSchemaTypes.String, schema.Type); Assert.Empty(schema.Properties); } @@ -457,7 +482,7 @@ public void GenerateSchema_SupportsOption_UseAllOfForInheritance() Assert.Equal(["Property1"], subSchema.Properties.Keys); // The base type schema var baseTypeSchema = schemaRepository.Schemas[baseSchema.Reference.Id]; - Assert.Equal("object", baseTypeSchema.Type); + Assert.Equal(JsonSchemaTypes.Object, baseTypeSchema.Type); Assert.Equal(["BaseProperty"], baseTypeSchema.Properties.Keys); } @@ -514,12 +539,12 @@ public void GenerateSchema_SupportsOption_UseAllOfForPolymorphism() // The base type schema Assert.NotNull(schema.OneOf[0].Reference); var baseSchema = schemaRepository.Schemas[schema.OneOf[0].Reference.Id]; - Assert.Equal("object", baseSchema.Type); + Assert.Equal(JsonSchemaTypes.Object, baseSchema.Type); Assert.Equal(["BaseProperty"], baseSchema.Properties.Keys); // The first sub type schema Assert.NotNull(schema.OneOf[1].Reference); var subType1Schema = schemaRepository.Schemas[schema.OneOf[1].Reference.Id]; - Assert.Equal("object", subType1Schema.Type); + Assert.Equal(JsonSchemaTypes.Object, subType1Schema.Type); Assert.NotNull(subType1Schema.AllOf); var allOf = Assert.Single(subType1Schema.AllOf); Assert.NotNull(allOf.Reference); @@ -528,7 +553,7 @@ public void GenerateSchema_SupportsOption_UseAllOfForPolymorphism() // The second sub type schema Assert.NotNull(schema.OneOf[2].Reference); var subType2Schema = schemaRepository.Schemas[schema.OneOf[2].Reference.Id]; - Assert.Equal("object", subType2Schema.Type); + Assert.Equal(JsonSchemaTypes.Object, subType2Schema.Type); Assert.NotNull(subType2Schema.AllOf); allOf = Assert.Single(subType2Schema.AllOf); Assert.NotNull(allOf.Reference); @@ -560,7 +585,7 @@ public void GenerateSchema_SupportsOption_UseInlineDefinitionsForEnums() var schema = subject.GenerateSchema(typeof(IntEnum), new SchemaRepository()); - Assert.Equal("integer", schema.Type); + Assert.Equal(JsonSchemaTypes.Integer, schema.Type); Assert.NotNull(schema.Enum); } @@ -572,7 +597,7 @@ public void GenerateSchema_HandlesTypesWithNestedTypes() var referenceSchema = Subject().GenerateSchema(typeof(ContainingType), schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.Equal("NestedType", schema.Properties["Property1"].Reference.Id); } @@ -585,7 +610,7 @@ public void GenerateSchema_HandlesSquareArray() Assert.NotNull(referenceSchema.Items); Assert.NotNull(referenceSchema.Items.Type); - Assert.Equal("string", referenceSchema.Items.Type); + Assert.Equal(JsonSchemaTypes.String, referenceSchema.Items.Type); } [Fact] @@ -596,8 +621,8 @@ public void GenerateSchema_HandlesTypesWithOverriddenProperties() var referenceSchema = Subject().GenerateSchema(typeof(TypeWithOverriddenProperty), schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("object", schema.Type); - Assert.Equal("string", schema.Properties["Property1"].Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); + Assert.Equal(JsonSchemaTypes.String, schema.Properties["Property1"].Type); } [Fact] @@ -649,7 +674,7 @@ public void GenerateSchema_HonorsSerializerSetting_StringEnumConverter( var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; var propertySchema = schema.Properties[nameof(TypeWithDefaultAttributeOnEnum.EnumWithDefault)]; - Assert.Equal("string", propertySchema.Type); + Assert.Equal(JsonSchemaTypes.String, propertySchema.Type); Assert.Equal(expectedEnumAsJson, propertySchema.Enum.Select(openApiAny => openApiAny.ToJson())); Assert.Equal(expectedDefaultAsJson, propertySchema.Default.ToJson()); } @@ -736,7 +761,7 @@ public void GenerateSchema_HonorsSerializerAttribute_StringEnumConverter() var referenceSchema = Subject().GenerateSchema(typeof(JsonConverterAnnotatedEnum), schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("string", schema.Type); + Assert.Equal(JsonSchemaTypes.String, schema.Type); Assert.Equal(["\"Value1\"", "\"Value2\"", "\"X-foo\""], schema.Enum.Select(openApiAny => openApiAny.ToJson())); } diff --git a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Swashbuckle.AspNetCore.Newtonsoft.Test.csproj b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Swashbuckle.AspNetCore.Newtonsoft.Test.csproj index faa5492841..b49d136426 100644 --- a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Swashbuckle.AspNetCore.Newtonsoft.Test.csproj +++ b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Swashbuckle.AspNetCore.Newtonsoft.Test.csproj @@ -4,6 +4,10 @@ net9.0;net8.0 + + + + diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/RecursiveCallSchemaFilter.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/RecursiveCallSchemaFilter.cs index ba9a6a871a..e14591edae 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/RecursiveCallSchemaFilter.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/RecursiveCallSchemaFilter.cs @@ -6,7 +6,7 @@ public class RecursiveCallSchemaFilter : ISchemaFilter { public void Apply(OpenApiSchema model, SchemaFilterContext context) { - if (model.Type == "object") + if (model.Type == JsonSchemaTypes.Object) { model.Properties.Add("Self", context.SchemaGenerator.GenerateSchema(context.Type, context.SchemaRepository)); } diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs index 8ff212a8d5..b65e263a16 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs @@ -20,6 +20,8 @@ using Swashbuckle.AspNetCore.TestSupport; using Xunit; +using JsonSchemaType = string; + namespace Swashbuckle.AspNetCore.SwaggerGen.Test { public class JsonSerializerSchemaGeneratorTests @@ -33,49 +35,54 @@ public void GenerateSchema_GeneratesFileSchema_BinaryStringResultType(Type type) { var schema = Subject().GenerateSchema(type, new SchemaRepository()); - Assert.Equal("string", schema.Type); + Assert.Equal(JsonSchemaTypes.String, schema.Type); Assert.Equal("binary", schema.Format); } - [Theory] - [InlineData(typeof(bool), "boolean", null)] - [InlineData(typeof(byte), "integer", "int32")] - [InlineData(typeof(sbyte), "integer", "int32")] - [InlineData(typeof(short), "integer", "int32")] - [InlineData(typeof(ushort), "integer", "int32")] - [InlineData(typeof(int), "integer", "int32")] - [InlineData(typeof(uint), "integer", "int32")] - [InlineData(typeof(long), "integer", "int64")] - [InlineData(typeof(ulong), "integer", "int64")] - [InlineData(typeof(float), "number", "float")] - [InlineData(typeof(double), "number", "double")] - [InlineData(typeof(decimal), "number", "double")] - [InlineData(typeof(string), "string", null)] - [InlineData(typeof(char), "string", null)] - [InlineData(typeof(byte[]), "string", "byte")] - [InlineData(typeof(DateTime), "string", "date-time")] - [InlineData(typeof(DateTimeOffset), "string", "date-time")] - [InlineData(typeof(TimeSpan), "string", "date-span")] - [InlineData(typeof(Guid), "string", "uuid")] - [InlineData(typeof(Uri), "string", "uri")] - [InlineData(typeof(Version), "string", null)] - [InlineData(typeof(DateOnly), "string", "date")] - [InlineData(typeof(TimeOnly), "string", "time")] - [InlineData(typeof(bool?), "boolean", null)] - [InlineData(typeof(int?), "integer", "int32")] - [InlineData(typeof(DateTime?), "string", "date-time")] - [InlineData(typeof(Guid?), "string", "uuid")] - [InlineData(typeof(DateOnly?), "string", "date")] - [InlineData(typeof(TimeOnly?), "string", "time")] + public static TheoryData PrimitiveTypeData => new() + { + { typeof(bool), JsonSchemaTypes.Boolean, null }, + { typeof(byte), JsonSchemaTypes.Integer, "int32" }, + { typeof(sbyte), JsonSchemaTypes.Integer, "int32" }, + { typeof(short), JsonSchemaTypes.Integer, "int32" }, + { typeof(ushort), JsonSchemaTypes.Integer, "int32" }, + { typeof(int), JsonSchemaTypes.Integer, "int32" }, + { typeof(uint), JsonSchemaTypes.Integer, "int32" }, + { typeof(long), JsonSchemaTypes.Integer, "int64" }, + { typeof(ulong), JsonSchemaTypes.Integer, "int64" }, + { typeof(float), JsonSchemaTypes.Number, "float" }, + { typeof(double), JsonSchemaTypes.Number, "double" }, + { typeof(decimal), JsonSchemaTypes.Number, "double" }, + { typeof(string), JsonSchemaTypes.String, null }, + { typeof(char), JsonSchemaTypes.String, null }, + { typeof(byte[]), JsonSchemaTypes.String, "byte" }, + { typeof(DateTime), JsonSchemaTypes.String, "date-time" }, + { typeof(DateTimeOffset), JsonSchemaTypes.String, "date-time" }, + { typeof(TimeSpan), JsonSchemaTypes.String, "date-span" }, + { typeof(Guid), JsonSchemaTypes.String, "uuid" }, + { typeof(Uri), JsonSchemaTypes.String, "uri" }, + { typeof(Version), JsonSchemaTypes.String, null }, + { typeof(DateOnly), JsonSchemaTypes.String, "date" }, + { typeof(TimeOnly), JsonSchemaTypes.String, "time" }, + { typeof(bool?), JsonSchemaTypes.Boolean, null }, + { typeof(int?), JsonSchemaTypes.Integer, "int32" }, + { typeof(DateTime?), JsonSchemaTypes.String, "date-time" }, + { typeof(Guid?), JsonSchemaTypes.String, "uuid" }, + { typeof(DateOnly?), JsonSchemaTypes.String, "date" }, + { typeof(TimeOnly?), JsonSchemaTypes.String, "time" }, #if NET7_0_OR_GREATER - [InlineData(typeof(Int128), "integer", "int128")] - [InlineData(typeof(Int128?), "integer", "int128")] - [InlineData(typeof(UInt128), "integer", "int128")] - [InlineData(typeof(UInt128?), "integer", "int128")] + { typeof(Int128), JsonSchemaTypes.Integer, "int128" }, + { typeof(Int128?), JsonSchemaTypes.Integer, "int128" }, + { typeof(UInt128), JsonSchemaTypes.Integer, "int128" }, + { typeof(UInt128?), JsonSchemaTypes.Integer, "int128" }, #endif + }; + + [Theory] + [MemberData(nameof(PrimitiveTypeData))] public void GenerateSchema_GeneratesPrimitiveSchema_IfPrimitiveOrNullablePrimitiveType( Type type, - string expectedSchemaType, + JsonSchemaType expectedSchemaType, string expectedFormat) { var schema = Subject().GenerateSchema(type, new SchemaRepository()); @@ -100,7 +107,7 @@ public void GenerateSchema_GeneratesReferencedEnumSchema_IfEnumOrNullableEnumTyp Assert.NotNull(referenceSchema.Reference); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("integer", schema.Type); + Assert.Equal(JsonSchemaTypes.Integer, schema.Type); Assert.Equal(expectedFormat, schema.Format); Assert.NotNull(schema.Enum); Assert.Equal(expectedEnumAsJson, schema.Enum.Select(openApiAny => openApiAny.ToJson())); @@ -119,19 +126,24 @@ public void GenerateSchema_DedupsEnumValues_IfEnumTypeHasDuplicateValues() Assert.Equal(enumType.GetEnumValues().Cast().Distinct().Count(), schema.Enum.Count); } + public static TheoryData CollectionTypeData => new() + { + { typeof(IDictionary), JsonSchemaTypes.Integer }, + { typeof(IDictionary), JsonSchemaTypes.Integer }, + { typeof(IReadOnlyDictionary), JsonSchemaTypes.Boolean }, + { typeof(IDictionary), null }, + { typeof(ExpandoObject), null }, + }; + [Theory] - [InlineData(typeof(IDictionary), "integer")] - [InlineData(typeof(IDictionary), "integer")] - [InlineData(typeof(IReadOnlyDictionary), "boolean")] - [InlineData(typeof(IDictionary), null)] - [InlineData(typeof(ExpandoObject), null)] + [MemberData(nameof(CollectionTypeData))] public void GenerateSchema_GeneratesDictionarySchema_IfDictionaryType( Type type, - string expectedAdditionalPropertiesType) + JsonSchemaType expectedAdditionalPropertiesType) { var schema = Subject().GenerateSchema(type, new SchemaRepository()); - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.True(schema.AdditionalPropertiesAllowed); Assert.NotNull(schema.AdditionalProperties); Assert.Equal(expectedAdditionalPropertiesType, schema.AdditionalProperties.Type); @@ -146,26 +158,31 @@ public void GenerateSchema_GeneratesReferencedDictionarySchema_IfDictionaryTypeI Assert.NotNull(referenceSchema.Reference); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.True(schema.AdditionalPropertiesAllowed); Assert.NotNull(schema.AdditionalProperties); Assert.Equal(schema.AdditionalProperties.Reference.Id, referenceSchema.Reference.Id); // ref to self } + public static TheoryData EnumerableTypeData => new() + { + { typeof(int[]), JsonSchemaTypes.Integer, "int32" }, + { typeof(IEnumerable), JsonSchemaTypes.String, null }, + { typeof(DateTime?[]), JsonSchemaTypes.String, "date-time" }, + { typeof(int[][]), JsonSchemaTypes.Array, null }, + { typeof(IList), null, null }, + }; + [Theory] - [InlineData(typeof(int[]), "integer", "int32")] - [InlineData(typeof(IEnumerable), "string", null)] - [InlineData(typeof(DateTime?[]), "string", "date-time")] - [InlineData(typeof(int[][]), "array", null)] - [InlineData(typeof(IList), null, null)] + [MemberData(nameof(EnumerableTypeData))] public void GenerateSchema_GeneratesArraySchema_IfEnumerableType( Type type, - string expectedItemsType, + JsonSchemaType expectedItemsType, string expectedItemsFormat) { var schema = Subject().GenerateSchema(type, new SchemaRepository()); - Assert.Equal("array", schema.Type); + Assert.Equal(JsonSchemaTypes.Array, schema.Type); Assert.NotNull(schema.Items); Assert.Equal(expectedItemsType, schema.Items.Type); Assert.Equal(expectedItemsFormat, schema.Items.Format); @@ -179,7 +196,7 @@ public void GenerateSchema_SetsUniqueItems_IfEnumerableTypeIsSetOrKeyedCollectio { var schema = Subject().GenerateSchema(type, new SchemaRepository()); - Assert.Equal("array", schema.Type); + Assert.Equal(JsonSchemaTypes.Array, schema.Type); Assert.True(schema.UniqueItems); } @@ -192,7 +209,7 @@ public void GenerateSchema_GeneratesReferencedArraySchema_IfEnumerableTypeIsSelf Assert.NotNull(referenceSchema.Reference); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("array", schema.Type); + Assert.Equal(JsonSchemaTypes.Array, schema.Type); Assert.Equal(schema.Items.Reference.Id, referenceSchema.Reference.Id); // ref to self } @@ -213,7 +230,7 @@ public void GenerateSchema_GeneratesReferencedObjectSchema_IfComplexType( Assert.NotNull(referenceSchema.Reference); Assert.Equal(expectedSchemaId, referenceSchema.Reference.Id); var schema = schemaRepository.Schemas[expectedSchemaId]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.Equal(expectedProperties, schema.Properties.Keys); Assert.False(schema.AdditionalPropertiesAllowed); } @@ -226,7 +243,7 @@ public void GenerateSchema_IncludesInheritedProperties_IfComplexTypeIsDerived() var referenceSchema = Subject().GenerateSchema(typeof(SubType1), schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.Equal(["BaseProperty", "Property1"], schema.Properties.Keys); } @@ -244,7 +261,7 @@ public void GenerateSchema_IncludesInheritedProperties_IfTypeIsAnInterfaceHierar var referenceSchema = Subject().GenerateSchema(type, schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.Equal(expectedPropertyNames.OrderBy(n => n), schema.Properties.Keys.OrderBy(k => k)); } @@ -256,7 +273,7 @@ public void GenerateSchema_KeepMostDerivedType_IfTypeIsAnInterface() var referenceSchema = Subject().GenerateSchema(typeof(INewBaseInterface), schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("integer", schema.Properties["BaseProperty"].Type); + Assert.Equal(JsonSchemaTypes.Integer, schema.Properties["BaseProperty"].Type); } [Fact] @@ -267,7 +284,7 @@ public void GenerateSchema_ExcludesIndexerProperties_IfComplexTypeIsIndexed() var referenceSchema = Subject().GenerateSchema(typeof(IndexedType), schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.Equal(["Property1"], schema.Properties.Keys); } @@ -350,7 +367,7 @@ public void GenerateSchema_SetsValidationProperties_IfComplexTypeHasValidationAt Assert.Equal(true, schema.Properties["IntWithExclusiveRange"].ExclusiveMinimum); Assert.Equal(true, schema.Properties["IntWithExclusiveRange"].ExclusiveMaximum); Assert.Equal("byte", schema.Properties["StringWithBase64"].Format); - Assert.Equal("string", schema.Properties["StringWithBase64"].Type); + Assert.Equal(JsonSchemaTypes.String, schema.Properties["StringWithBase64"].Type); #endif Assert.Null(schema.Properties["IntWithRange"].ExclusiveMinimum); Assert.Null(schema.Properties["IntWithRange"].ExclusiveMaximum); @@ -490,11 +507,11 @@ public void GenerateSchema_SupportsOption_CustomTypeMappings( Type type) { var subject = Subject( - configureGenerator: c => c.CustomTypeMappings.Add(mappingType, () => new OpenApiSchema { Type = "string" }) + configureGenerator: c => c.CustomTypeMappings.Add(mappingType, () => new OpenApiSchema { Type = JsonSchemaTypes.String }) ); var schema = subject.GenerateSchema(type, new SchemaRepository()); - Assert.Equal("string", schema.Type); + Assert.Equal(JsonSchemaTypes.String, schema.Type); Assert.Empty(schema.Properties); } @@ -514,6 +531,7 @@ public void GenerateSchema_SupportsOption_SchemaFilters(Type type) var definitionSchema = schema.Reference == null ? schema : schemaRepository.Schemas[schema.Reference.Id]; Assert.Contains("X-foo", definitionSchema.Extensions.Keys); + Assert.Equal("v1", ((OpenApiString)definitionSchema.Extensions["X-docName"]).Value); } @@ -565,7 +583,7 @@ public void GenerateSchema_SupportsOption_UseAllOfForInheritance() Assert.Equal(["Property1"], subSchema.Properties.Keys); // The base type schema var baseTypeSchema = schemaRepository.Schemas[baseSchema.Reference.Id]; - Assert.Equal("object", baseTypeSchema.Type); + Assert.Equal(JsonSchemaTypes.Object, baseTypeSchema.Type); Assert.Equal(["BaseProperty"], baseTypeSchema.Properties.Keys); } @@ -645,12 +663,12 @@ public void GenerateSchema_SupportsOption_UseAllOfForPolymorphism() // The base type schema Assert.NotNull(schema.OneOf[0].Reference); var baseSchema = schemaRepository.Schemas[schema.OneOf[0].Reference.Id]; - Assert.Equal("object", baseSchema.Type); + Assert.Equal(JsonSchemaTypes.Object, baseSchema.Type); Assert.Equal(["BaseProperty"], baseSchema.Properties.Keys); // The first sub type schema Assert.NotNull(schema.OneOf[1].Reference); var subType1Schema = schemaRepository.Schemas[schema.OneOf[1].Reference.Id]; - Assert.Equal("object", subType1Schema.Type); + Assert.Equal(JsonSchemaTypes.Object, subType1Schema.Type); Assert.NotNull(subType1Schema.AllOf); var allOf = Assert.Single(subType1Schema.AllOf); Assert.NotNull(allOf.Reference); @@ -659,7 +677,7 @@ public void GenerateSchema_SupportsOption_UseAllOfForPolymorphism() // The second sub type schema Assert.NotNull(schema.OneOf[2].Reference); var subType2Schema = schemaRepository.Schemas[schema.OneOf[2].Reference.Id]; - Assert.Equal("object", subType2Schema.Type); + Assert.Equal(JsonSchemaTypes.Object, subType2Schema.Type); Assert.NotNull(subType2Schema.AllOf); allOf = Assert.Single(subType2Schema.AllOf); Assert.NotNull(allOf.Reference); @@ -691,7 +709,7 @@ public void GenerateSchema_SupportsOption_UseInlineDefinitionsForEnums() var schema = subject.GenerateSchema(typeof(IntEnum), new SchemaRepository()); - Assert.Equal("integer", schema.Type); + Assert.Equal(JsonSchemaTypes.Integer, schema.Type); Assert.NotNull(schema.Enum); } @@ -1059,7 +1077,7 @@ public void GenerateSchema_HandlesTypesWithNestedTypes() var referenceSchema = Subject().GenerateSchema(typeof(ContainingType), schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("object", schema.Type); + Assert.Equal(JsonSchemaTypes.Object, schema.Type); Assert.Equal("NestedType", schema.Properties["Property1"].Reference.Id); } @@ -1072,7 +1090,7 @@ public void GenerateSchema_HandlesSquareArray() Assert.NotNull(referenceSchema.Items); Assert.NotNull(referenceSchema.Items.Type); - Assert.Equal("string", referenceSchema.Items.Type); + Assert.Equal(JsonSchemaTypes.String, referenceSchema.Items.Type); } [Fact] @@ -1151,7 +1169,7 @@ public void GenerateSchema_HonorsSerializerOption_StringEnumConverter( var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; var propertySchema = schema.Properties[nameof(TypeWithDefaultAttributeOnEnum.EnumWithDefault)]; - Assert.Equal("string", propertySchema.Type); + Assert.Equal(JsonSchemaTypes.String, propertySchema.Type); Assert.Equal(expectedEnumAsJson, propertySchema.Enum.Select(openApiAny => openApiAny.ToJson())); Assert.Equal(expectedDefaultAsJson, propertySchema.Default.ToJson()); } @@ -1175,7 +1193,7 @@ public void GenerateSchema_HonorsSerializerAttribute_StringEnumConverter() var referenceSchema = Subject().GenerateSchema(typeof(JsonConverterAnnotatedEnum), schemaRepository); var schema = schemaRepository.Schemas[referenceSchema.Reference.Id]; - Assert.Equal("string", schema.Type); + Assert.Equal(JsonSchemaTypes.String, schema.Type); Assert.Equal(["\"Value1\"", "\"Value2\"", "\"X\""], schema.Enum.Select(openApiAny => openApiAny.ToJson())); } @@ -1324,7 +1342,7 @@ public void GenerateSchema_GeneratesSchema_IfParameterHasTypeConstraints() .GetParameters() .First(); var schema = Subject().GenerateSchema(typeof(string), new SchemaRepository(), parameterInfo: parameterInfo, routeInfo: routeInfo); - Assert.Equal("integer", schema.Type); + Assert.Equal(JsonSchemaTypes.Integer, schema.Type); } private static SchemaGenerator Subject( diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGenerator/SwaggerGeneratorTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGenerator/SwaggerGeneratorTests.cs index 35acf3722f..42914708c7 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGenerator/SwaggerGeneratorTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGenerator/SwaggerGeneratorTests.cs @@ -337,11 +337,14 @@ public void GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationAndApp Assert.NotNull(content.Value.Schema.Reference); Assert.Equal("TestDto", content.Value.Schema.Reference.Id); Assert.Equal(2, operation.RequestBody.Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.RequestBody.Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.RequestBody.Extensions["X-docName"]).Value); + Assert.NotEmpty(operation.Parameters); Assert.Equal("paramQuery", operation.Parameters[0].Name); Assert.Equal(2, operation.Parameters[0].Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.Parameters[0].Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.Parameters[0].Extensions["X-docName"]).Value); } @@ -397,7 +400,7 @@ public void GetSwagger_GenerateParametersSchemas_ForProvidedOpenApiOperation() Assert.Equal("OperationIdSetInMetadata", document.Paths["/resource"].Operations[OperationType.Post].OperationId); Assert.Equal("ParameterInMetadata", document.Paths["/resource"].Operations[OperationType.Post].Parameters[0].Name); Assert.NotNull(document.Paths["/resource"].Operations[OperationType.Post].Parameters[0].Schema); - Assert.Equal("string", document.Paths["/resource"].Operations[OperationType.Post].Parameters[0].Schema.Type); + Assert.Equal(JsonSchemaTypes.String, document.Paths["/resource"].Operations[OperationType.Post].Parameters[0].Schema.Type); } [Fact] @@ -821,7 +824,7 @@ public void GetSwagger_SetsParameterTypeToString_IfApiParameterHasNoCorrespondin var operation = document.Paths["/resource"].Operations[OperationType.Post]; var parameter = Assert.Single(operation.Parameters); - Assert.Equal("string", parameter.Schema.Type); + Assert.Equal(JsonSchemaTypes.String, parameter.Schema.Type); } [Fact] @@ -1055,7 +1058,7 @@ public void GetSwagger_SetsResponseContentType_WhenActionHasFileResult() var content = operation.Responses["200"].Content.FirstOrDefault(); Assert.Equal("application/zip", content.Key); Assert.Equal("binary", content.Value.Schema.Format); - Assert.Equal("string", content.Value.Schema.Type); + Assert.Equal(JsonSchemaTypes.String, content.Value.Schema.Type); } [Fact] @@ -1257,7 +1260,7 @@ public void GetSwagger_SupportsOption_TagSelector() var document = subject.GetSwagger("v1"); - Assert.Equal(["resource"], document.Paths["/resource"].Operations[OperationType.Post].Tags.Select(t => t.Name)); + Assert.Equal(["resource"], [.. document.Paths["/resource"].Operations[OperationType.Post].Tags?.Select(t => t.Name)]); } [Fact] @@ -1281,7 +1284,7 @@ public void GetSwagger_CanReadTagsFromMetadata() var document = subject.GetSwagger("v1"); - Assert.Equal(["Some", "Tags", "Here"], document.Paths["/resource"].Operations[OperationType.Post].Tags.Select(t => t.Name)); + Assert.Equal(["Some", "Tags", "Here"], [.. document.Paths["/resource"].Operations[OperationType.Post].Tags?.Select(t => t.Name)]); } #if NET7_0_OR_GREATER @@ -1420,36 +1423,36 @@ public void GetSwagger_SupportsOption_DescribeAllParametersInCamelCase_ForParame var methodInfo = typeof(FakeController).GetMethod(nameof(FakeController.ActionWithParameter)); var actionDescriptor = new ActionDescriptor { - EndpointMetadata = new List() - { + EndpointMetadata = + [ new OpenApiOperation { OperationId = "OperationIdSetInMetadata", - Parameters = new List() - { + Parameters = + [ new OpenApiParameter { Name = parameterName } - } + ] } - }, + ], RouteValues = new Dictionary { ["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty) } }; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( actionDescriptor, methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new[] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = parameterName, @@ -1457,8 +1460,8 @@ public void GetSwagger_SupportsOption_DescribeAllParametersInCamelCase_ForParame ModelMetadata = ModelMetadataFactory.CreateForType(typeof(string)), Type = typeof(string) } - }), - }, + ]), + ], options: new SwaggerGeneratorOptions { SwaggerDocs = new Dictionary @@ -1619,6 +1622,7 @@ public void GetSwagger_SupportsOption_ParameterFilters() var operation = document.Paths["/resource"].Operations[OperationType.Post]; Assert.Equal(2, operation.Parameters[0].Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.Parameters[0].Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.Parameters[0].Extensions["X-docName"]).Value); } @@ -1656,6 +1660,7 @@ public void GetSwagger_SupportsOption_RequestBodyFilters() var operation = document.Paths["/resource"].Operations[OperationType.Post]; Assert.Equal(2, operation.RequestBody.Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.RequestBody.Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.RequestBody.Extensions["X-docName"]).Value); } @@ -1686,6 +1691,7 @@ public void GetSwagger_SupportsOption_OperationFilters() var operation = document.Paths["/resource"].Operations[OperationType.Post]; Assert.Equal(2, operation.Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.Extensions["X-docName"]).Value); } @@ -1711,9 +1717,10 @@ public void GetSwagger_SupportsOption_DocumentFilters() var document = subject.GetSwagger("v1"); Assert.Equal(2, document.Extensions.Count); + Assert.Contains("ComplexType", document.Components.Schemas.Keys); + Assert.Equal("bar", ((OpenApiString)document.Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)document.Extensions["X-docName"]).Value); - Assert.Contains("ComplexType", document.Components.Schemas.Keys); } [Fact] @@ -1742,6 +1749,7 @@ public async Task GetSwaggerAsync_SupportsOption_OperationFilters() var operation = document.Paths["/resource"].Operations[OperationType.Post]; Assert.Equal(2, operation.Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.Extensions["X-docName"]).Value); } @@ -1772,6 +1780,7 @@ public async Task GetSwaggerAsync_SupportsOption_OperationAsyncFilters() var operation = document.Paths["/resource"].Operations[OperationType.Post]; Assert.Equal(2, operation.Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.Extensions["X-docName"]).Value); } @@ -1797,9 +1806,10 @@ public async Task GetSwaggerAsync_SupportsOption_DocumentAsyncFilters() var document = await subject.GetSwaggerAsync("v1"); Assert.Equal(2, document.Extensions.Count); + Assert.Contains("ComplexType", document.Components.Schemas.Keys); + Assert.Equal("bar", ((OpenApiString)document.Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)document.Extensions["X-docName"]).Value); - Assert.Contains("ComplexType", document.Components.Schemas.Keys); } [Fact] @@ -1823,9 +1833,10 @@ public async Task GetSwaggerAsync_SupportsOption_DocumentFilters() var document = await subject.GetSwaggerAsync("v1"); Assert.Equal(2, document.Extensions.Count); + Assert.Contains("ComplexType", document.Components.Schemas.Keys); + Assert.Equal("bar", ((OpenApiString)document.Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)document.Extensions["X-docName"]).Value); - Assert.Contains("ComplexType", document.Components.Schemas.Keys); } [Fact] @@ -1861,6 +1872,7 @@ public async Task GetSwaggerAsync_SupportsOption_RequestBodyAsyncFilters() var operation = document.Paths["/resource"].Operations[OperationType.Post]; Assert.Equal(2, operation.RequestBody.Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.RequestBody.Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.RequestBody.Extensions["X-docName"]).Value); } @@ -1898,6 +1910,7 @@ public async Task GetSwaggerAsync_SupportsOption_RequestBodyFilters() var operation = document.Paths["/resource"].Operations[OperationType.Post]; Assert.Equal(2, operation.RequestBody.Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.RequestBody.Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.RequestBody.Extensions["X-docName"]).Value); } @@ -1935,6 +1948,7 @@ public async Task GetSwaggerAsync_SupportsOption_ParameterFilters() var operation = document.Paths["/resource"].Operations[OperationType.Post]; Assert.Equal(2, operation.Parameters[0].Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.Parameters[0].Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.Parameters[0].Extensions["X-docName"]).Value); } @@ -1972,6 +1986,7 @@ public async Task GetSwaggerAsync_SupportsOption_ParameterAsyncFilters() var operation = document.Paths["/resource"].Operations[OperationType.Post]; Assert.Equal(2, operation.Parameters[0].Extensions.Count); + Assert.Equal("bar", ((OpenApiString)operation.Parameters[0].Extensions["X-foo"]).Value); Assert.Equal("v1", ((OpenApiString)operation.Parameters[0].Extensions["X-docName"]).Value); } @@ -2414,10 +2429,10 @@ public void GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIF var content = Assert.Single(document.Paths["/resource"].Operations[OperationType.Post].RequestBody.Content); Assert.Equal("application/someMediaType", content.Key); Assert.NotNull(content.Value.Schema); - Assert.Equal("object", content.Value.Schema.Type); + Assert.Equal(JsonSchemaTypes.Object, content.Value.Schema.Type); Assert.NotEmpty(content.Value.Schema.Properties); Assert.NotNull(content.Value.Schema.Properties["param"]); - Assert.Equal("string", content.Value.Schema.Properties["param"].Type); + Assert.Equal(JsonSchemaTypes.String, content.Value.Schema.Properties["param"].Type); Assert.Equal("binary", content.Value.Schema.Properties["param"].Format); Assert.NotNull(content.Value.Encoding); Assert.NotNull(content.Value.Encoding["param"]); @@ -2476,12 +2491,12 @@ public void GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIF var content = Assert.Single(document.Paths["/resource"].Operations[OperationType.Post].RequestBody.Content); Assert.Equal("application/someMediaType", content.Key); Assert.NotNull(content.Value.Schema); - Assert.Equal("object", content.Value.Schema.Type); + Assert.Equal(JsonSchemaTypes.Object, content.Value.Schema.Type); Assert.NotEmpty(content.Value.Schema.Properties); Assert.NotNull(content.Value.Schema.Properties["param"]); - Assert.Equal("array", content.Value.Schema.Properties["param"].Type); + Assert.Equal(JsonSchemaTypes.Array, content.Value.Schema.Properties["param"].Type); Assert.NotNull(content.Value.Schema.Properties["param"].Items); - Assert.Equal("string", content.Value.Schema.Properties["param"].Items.Type); + Assert.Equal(JsonSchemaTypes.String, content.Value.Schema.Properties["param"].Items.Type); Assert.Equal("binary", content.Value.Schema.Properties["param"].Items.Format); Assert.NotNull(content.Value.Encoding); Assert.NotNull(content.Value.Encoding["param"]); @@ -2540,10 +2555,10 @@ public void GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithSt var content = Assert.Single(document.Paths["/resource"].Operations[OperationType.Post].RequestBody.Content); Assert.Equal("application/someMediaType", content.Key); Assert.NotNull(content.Value.Schema); - Assert.Equal("object", content.Value.Schema.Type); + Assert.Equal(JsonSchemaTypes.Object, content.Value.Schema.Type); Assert.NotEmpty(content.Value.Schema.Properties); Assert.NotNull(content.Value.Schema.Properties["param"]); - Assert.Equal("string", content.Value.Schema.Properties["param"].Type); + Assert.Equal(JsonSchemaTypes.String, content.Value.Schema.Properties["param"].Type); Assert.NotNull(content.Value.Encoding); Assert.NotNull(content.Value.Encoding["param"]); Assert.Equal(ParameterStyle.Form, content.Value.Encoding["param"].Style); diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Body.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Body.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Body.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Body.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Body.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Body.DotNet9_0.verified.txt new file mode 100644 index 0000000000..039d96aca5 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Body.DotNet9_0.verified.txt @@ -0,0 +1,47 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + application/someMediaType: { + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + } + }, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 4CB047722B57E9853D09B038EC48DB9A63B1EE5C19DDFD234A172615EE6225134356F1B92FB3881C2D7DAA40B77D534CB317F93B407B4E7B6B74480224A9E7B7 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Form.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Form.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Form.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Form.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Form.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Form.DotNet9_0.verified.txt new file mode 100644 index 0000000000..f933ed006f --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasConsumesAttribute_bindingSourceId=Form.DotNet9_0.verified.txt @@ -0,0 +1,63 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + application/someMediaType: { + Schema: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + param: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + Encoding: { + param: { + Style: Form + } + } + } + } + }, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: E5B7D5A3A69521A769EA033C2E26073D98F03E899B1DFE0A7CF240CE54D26EA3294FDF9D39DCABBB4F32CA029376F8CF147C001935036911E75750C367FD288E +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasFileResult.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasFileResult.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasFileResult.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasFileResult.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasFileResult.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasFileResult.DotNet9_0.verified.txt new file mode 100644 index 0000000000..97bf697dc5 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasFileResult.DotNet9_0.verified.txt @@ -0,0 +1,44 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + Content: { + application/zip: { + Schema: { + Type: string, + Format: binary, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + }, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 83ACD9647CC5FE2F4D9CB77158BC1B03C790DCF45575DD944B54B1B223692F2F000674EA282E908E25354FD80FD6843770F1CA8B70289B8BE70C58F919A2FDDA +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasObsoleteAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasObsoleteAttribute.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasObsoleteAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasObsoleteAttribute.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasObsoleteAttribute.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasObsoleteAttribute.DotNet9_0.verified.txt new file mode 100644 index 0000000000..8ad8c607d8 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasObsoleteAttribute.DotNet9_0.verified.txt @@ -0,0 +1,30 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: true + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 6ED193BE1E35B9D7BF0B260B931947E4AAC0931E500AA8ED441B6D9D2A5AFA228C99ED8B295DB246E18AFAD63CB63455167621785F98F447EBF31A5431F61380 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasProducesAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasProducesAttribute.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasProducesAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasProducesAttribute.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasProducesAttribute.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasProducesAttribute.DotNet9_0.verified.txt new file mode 100644 index 0000000000..1eccdd4e9f --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHasProducesAttribute.DotNet9_0.verified.txt @@ -0,0 +1,44 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + Content: { + application/someMediaType: { + Schema: { + Type: integer, + Format: int32, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + }, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 70543EA64D7658413247389AF5490AD05BEEDF3D5FDCEC1436353732D8D2F1566EDB6CE23863A45C135B8715D60FA95B90E6D460181B1FEABD2CD061914DFE13 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeButNotWithIFormFile.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeButNotWithIFormFile.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeButNotWithIFormFile.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeButNotWithIFormFile.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeButNotWithIFormFile.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeButNotWithIFormFile.DotNet9_0.verified.txt new file mode 100644 index 0000000000..00be61b1ac --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeButNotWithIFormFile.DotNet9_0.verified.txt @@ -0,0 +1,73 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param1, + In: Query, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Form, + Explode: true, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + }, + { + UnresolvedReference: false, + Name: param2, + In: Query, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Form, + Explode: true, + AllowReserved: false, + Schema: { + Type: string, + Format: binary, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 0FB4C6819BEAFC6E91679E56836641A46864BF8AB09F4C5439146C4B568315AE89C2FE246798FEB6DFF832DE97AE90010624CB9342E8E41AC45064041DE39A25 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeWithSwaggerIgnore.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeWithSwaggerIgnore.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeWithSwaggerIgnore.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeWithSwaggerIgnore.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeWithSwaggerIgnore.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeWithSwaggerIgnore.DotNet9_0.verified.txt new file mode 100644 index 0000000000..0eec3a2b81 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionHavingFromFormAttributeWithSwaggerIgnore.DotNet9_0.verified.txt @@ -0,0 +1,63 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + multipart/form-data: { + Schema: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + NotIgnoredString: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + Encoding: { + NotIgnoredString: { + Style: Form + } + } + } + } + }, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: F2D8CE9F78193258F625FBA0732E8543EACC9F98F35622C7D834B9A4CF30328B824D914FFE1E1C94E268978D828FE142ED48EBAB9F468EF288FFD238C56C20E1 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasBindNeverAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasBindNeverAttribute.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasBindNeverAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasBindNeverAttribute.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasSwaggerIgnoreAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasBindNeverAttribute.DotNet9_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasSwaggerIgnoreAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasBindNeverAttribute.DotNet9_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ConflictingActionsResolverIsSpecified.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasSwaggerIgnoreAttribute.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ConflictingActionsResolverIsSpecified.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasSwaggerIgnoreAttribute.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasSwaggerIgnoreAttribute.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasSwaggerIgnoreAttribute.DotNet9_0.verified.txt new file mode 100644 index 0000000000..b275ef8989 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionParameterHasSwaggerIgnoreAttribute.DotNet9_0.verified.txt @@ -0,0 +1,30 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 0E75218C57C662359EC554B377E7600D033FDF17E191A0E468F1E402807067F96CA4BF92320CC0B13E796E1E39DF7997BCF9A2F00DEF42D6D1AD6F47A7F35666 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithConsumesAttributeAndProvidedOpenApiOperation.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithConsumesAttributeAndProvidedOpenApiOperation.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithConsumesAttributeAndProvidedOpenApiOperation.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithConsumesAttributeAndProvidedOpenApiOperation.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithConsumesAttributeAndProvidedOpenApiOperation.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithConsumesAttributeAndProvidedOpenApiOperation.DotNet9_0.verified.txt new file mode 100644 index 0000000000..7154917849 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithConsumesAttributeAndProvidedOpenApiOperation.DotNet9_0.verified.txt @@ -0,0 +1,67 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + OperationId: OperationIdSetInMetadata, + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + application/someMediaType: { + Schema: { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: TestDto, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/TestDto, + ReferenceV2: #/definitions/TestDto + } + } + } + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: { + Schemas: { + TestDto: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + Prop1: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: true, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: false, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + }, + HashCode: 59A5DD972A919CE8EF3F08E63BB492CCCA30B825146EA05B2BEF4690888EA52FB3CEC61C7F1F9A14629EDFF141CC49084DA127F3D6C5F555D8EA39F7B202C4E9 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithEndpointNameMetadata.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithEndpointNameMetadata.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithEndpointNameMetadata.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithEndpointNameMetadata.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithEndpointNameMetadata.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithEndpointNameMetadata.DotNet9_0.verified.txt new file mode 100644 index 0000000000..aaaed8c375 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithEndpointNameMetadata.DotNet9_0.verified.txt @@ -0,0 +1,31 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + OperationId: SomeEndpointName, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: A0047BEEDFB7C084AF6BF3412F47917E1914849406956B23249FD5A555B9545157FBFF5C1EAFC073B55E59FDE9BDB1774670EFE402C7319D5EC6A6A43D94E439 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithParameterAndProvidedOpenApiOperation.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithParameterAndProvidedOpenApiOperation.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithParameterAndProvidedOpenApiOperation.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithParameterAndProvidedOpenApiOperation.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithParameterAndProvidedOpenApiOperation.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithParameterAndProvidedOpenApiOperation.DotNet9_0.verified.txt new file mode 100644 index 0000000000..5c71462efe --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithParameterAndProvidedOpenApiOperation.DotNet9_0.verified.txt @@ -0,0 +1,40 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + OperationId: OperationIdSetInMetadata, + Parameters: [ + { + UnresolvedReference: false, + Name: ParameterInMetadata, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 80ACD622C6A7E73B1C5084D230E624A2A5897CCCC091D32500F9192221224A9A256D1E80276A6D47B85459035DFF93938E2378ACE8A3E854CB32390244297D61 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProducesAttributeAndProvidedOpenApiOperation.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProducesAttributeAndProvidedOpenApiOperation.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProducesAttributeAndProvidedOpenApiOperation.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProducesAttributeAndProvidedOpenApiOperation.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProducesAttributeAndProvidedOpenApiOperation.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProducesAttributeAndProvidedOpenApiOperation.DotNet9_0.verified.txt new file mode 100644 index 0000000000..bdeb7e02a6 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProducesAttributeAndProvidedOpenApiOperation.DotNet9_0.verified.txt @@ -0,0 +1,68 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + OperationId: OperationIdSetInMetadata, + Responses: { + 200: { + Content: { + application/someMediaType: { + Schema: { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: TestDto, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/TestDto, + ReferenceV2: #/definitions/TestDto + } + } + } + }, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: { + Schemas: { + TestDto: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + Prop1: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: true, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: false, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + }, + HashCode: 33EF286A101E847C16BF4B86DF410E6C22D16FEA221DEC72217642B13238E9C69382B5EBE1F7B9FEFC5E2819EA81D1C4C28A8E2AFF075F8E1CCF425F635F9532 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProvidedOpenApiMetadata.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProvidedOpenApiMetadata.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProvidedOpenApiMetadata.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProvidedOpenApiMetadata.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProvidedOpenApiMetadata.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProvidedOpenApiMetadata.DotNet9_0.verified.txt new file mode 100644 index 0000000000..facec5635b --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithProvidedOpenApiMetadata.DotNet9_0.verified.txt @@ -0,0 +1,31 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + OperationId: OperationIdSetInMetadata, + Parameters: [ + { + UnresolvedReference: false, + Name: ParameterInMetadata, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false + } + ], + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 76DE54DD44D94D07BC803E615ECB0F6D290C3B8803EFB5EADF02C6B180682B1C20BFDD4C9CD50F71D5AD7042B7B4570903F3AF1CC7970ABCA1CEE20FBF971FFD +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithBindRequiredAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithBindRequiredAttribute.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithBindRequiredAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithBindRequiredAttribute.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithRequiredAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithBindRequiredAttribute.DotNet9_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithRequiredAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithBindRequiredAttribute.DotNet9_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithRequiredAttribute.DotNet8_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithRequiredAttribute.DotNet8_0.verified.txt new file mode 100644 index 0000000000..0391bc7c93 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithRequiredAttribute.DotNet8_0.verified.txt @@ -0,0 +1,47 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + RequestBody: { + UnresolvedReference: false, + Required: true, + Content: { + application/json: { + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + } + }, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 804D6F0C92F4BE50ED4B40A4DD1F6D3FB0F279B348764AC01ABFD0218A5DE81B9CDA62C18D1345F64751D4FA1CA98298834D12D7AF7799F4845203B45FE40CFE +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithRequiredAttribute.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithRequiredAttribute.DotNet9_0.verified.txt new file mode 100644 index 0000000000..0391bc7c93 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredBodyParameter_action=ActionWithParameterWithRequiredAttribute.DotNet9_0.verified.txt @@ -0,0 +1,47 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + RequestBody: { + UnresolvedReference: false, + Required: true, + Content: { + application/json: { + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + } + }, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 804D6F0C92F4BE50ED4B40A4DD1F6D3FB0F279B348764AC01ABFD0218A5DE81B9CDA62C18D1345F64751D4FA1CA98298834D12D7AF7799F4845203B45FE40CFE +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredMember.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredMember.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredMember.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredMember.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredParameter_action=ActionWithParameterWithBindRequiredAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredMember.DotNet9_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredParameter_action=ActionWithParameterWithBindRequiredAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredMember.DotNet9_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredParameter_action=ActionWithParameterWithRequiredAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithBindRequiredAttribute.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredParameter_action=ActionWithParameterWithRequiredAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithBindRequiredAttribute.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithBindRequiredAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithBindRequiredAttribute.DotNet9_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithBindRequiredAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithBindRequiredAttribute.DotNet9_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithRequiredAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithRequiredAttribute.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithRequiredAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithRequiredAttribute.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithRequiredAttribute.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithRequiredAttribute.DotNet9_0.verified.txt new file mode 100644 index 0000000000..f8133b12f1 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRequiredQueryParameter_action=ActionWithParameterWithRequiredAttribute.DotNet9_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param, + In: Query, + Required: true, + Deprecated: false, + AllowEmptyValue: false, + Style: Form, + Explode: true, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: A2DDB9D84BC2303C2E8B82FEE969073D4DCAE3D40331C1ED8376E3F427E46C7CAE5AE2791BC5FE1FFFE026EBE90FC10DE8A0409D9F0B6EBC5DBE6CB294DD6A84 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithReturnValueAndSupportedResponseTypes.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithReturnValueAndSupportedResponseTypes.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithReturnValueAndSupportedResponseTypes.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithReturnValueAndSupportedResponseTypes.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithReturnValueAndSupportedResponseTypes.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithReturnValueAndSupportedResponseTypes.DotNet9_0.verified.txt new file mode 100644 index 0000000000..7feed0f987 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithReturnValueAndSupportedResponseTypes.DotNet9_0.verified.txt @@ -0,0 +1,56 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + Content: { + application/json: { + Schema: { + Type: integer, + Format: int32, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + }, + UnresolvedReference: false + }, + 400: { + Description: Bad Request, + UnresolvedReference: false + }, + 422: { + Description: Unprocessable Content, + UnresolvedReference: false + }, + default: { + Description: Error, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 49491612C8548E72072C4BF9884EBB4F3B076CB8FA86B0ADA736DD5AA2A7EFBDE1E5E4E2698AD9241CCB5A6AA19E150B7B558356C9F7B4A6027DCC77657B5685 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRouteNameMetadata.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRouteNameMetadata.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRouteNameMetadata.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRouteNameMetadata.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRouteNameMetadata.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRouteNameMetadata.DotNet9_0.verified.txt new file mode 100644 index 0000000000..9c7d1af46d --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionWithRouteNameMetadata.DotNet9_0.verified.txt @@ -0,0 +1,31 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + OperationId: SomeRouteName, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 8A51577C0837548151E3938DC7033AF6AFDE7FD4E5F6F2FE20CC8931B3D18A883C1FB3FE92120D0A44EC31DDE90DDEDE4A237B3138AD45A37278F8924958D5A7 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAcceptFromHeaderParameter.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAcceptFromHeaderParameter.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAcceptFromHeaderParameter.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAcceptFromHeaderParameter.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAuthorizationFromHeaderParameter.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAcceptFromHeaderParameter.DotNet9_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAuthorizationFromHeaderParameter.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAcceptFromHeaderParameter.DotNet9_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithContentTypeFromHeaderParameter.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAuthorizationFromHeaderParameter.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithContentTypeFromHeaderParameter.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAuthorizationFromHeaderParameter.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAuthorizationFromHeaderParameter.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAuthorizationFromHeaderParameter.DotNet9_0.verified.txt new file mode 100644 index 0000000000..49c8aec81d --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithAuthorizationFromHeaderParameter.DotNet9_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Get: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param, + In: Header, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: E126911C7FB97665966DB7EA833EA70FDF82A779304ECD9B963D5A50C6E0AE51A3180983631720BDCD1BCDA3CAA7E79F0F0042120949EA990884D6188CE77AF1 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithContentTypeFromHeaderParameter.DotNet8_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithContentTypeFromHeaderParameter.DotNet8_0.verified.txt new file mode 100644 index 0000000000..49c8aec81d --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithContentTypeFromHeaderParameter.DotNet8_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Get: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param, + In: Header, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: E126911C7FB97665966DB7EA833EA70FDF82A779304ECD9B963D5A50C6E0AE51A3180983631720BDCD1BCDA3CAA7E79F0F0042120949EA990884D6188CE77AF1 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithContentTypeFromHeaderParameter.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithContentTypeFromHeaderParameter.DotNet9_0.verified.txt new file mode 100644 index 0000000000..49c8aec81d --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ActionsWithIllegalHeaderParameters_action=ActionWithContentTypeFromHeaderParameter.DotNet9_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Get: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param, + In: Header, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: E126911C7FB97665966DB7EA833EA70FDF82A779304ECD9B963D5A50C6E0AE51A3180983631720BDCD1BCDA3CAA7E79F0F0042120949EA990884D6188CE77AF1 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiDescriptionsWithMatchingGroupName.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiDescriptionsWithMatchingGroupName.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiDescriptionsWithMatchingGroupName.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiDescriptionsWithMatchingGroupName.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiDescriptionsWithMatchingGroupName.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiDescriptionsWithMatchingGroupName.DotNet9_0.verified.txt new file mode 100644 index 0000000000..73d6704137 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiDescriptionsWithMatchingGroupName.DotNet9_0.verified.txt @@ -0,0 +1,45 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Get: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + }, + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 0F1036F23326E2BD7543491DEC0E03ABCA5BC97AF845BEE30C164155D616F306F6F6E21A77507DA6BE2A85DF1A17B1F07AE23E7608E37C971BAF1CBA2491E899 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterDescriptionForBodyIsRequired.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterDescriptionForBodyIsRequired.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterDescriptionForBodyIsRequired.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterDescriptionForBodyIsRequired.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterDescriptionForBodyIsRequired.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterDescriptionForBodyIsRequired.DotNet9_0.verified.txt new file mode 100644 index 0000000000..70c95a24b4 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterDescriptionForBodyIsRequired.DotNet9_0.verified.txt @@ -0,0 +1,34 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Foo, + UnresolvedReference: false + } + ], + RequestBody: { + UnresolvedReference: false, + Required: true + }, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 19A6400D0649D9875F38AAD5D6902D74BB45BC7435F3C76982D8CC6022ABD2DF08CB9083F22D74D4B915231556A80FA79185EC43D3775D1D46B53BBA970FAB59 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterHasNoCorrespondingActionParameter.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterHasNoCorrespondingActionParameter.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterHasNoCorrespondingActionParameter.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterHasNoCorrespondingActionParameter.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterIsBoundToPath.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterHasNoCorrespondingActionParameter.DotNet9_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterIsBoundToPath.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterHasNoCorrespondingActionParameter.DotNet9_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Path.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterIsBoundToPath.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Path.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterIsBoundToPath.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterIsBoundToPath.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterIsBoundToPath.DotNet9_0.verified.txt new file mode 100644 index 0000000000..d72f56e957 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParameterIsBoundToPath.DotNet9_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param, + In: Path, + Required: true, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 38B7A774F1E494464B7C8CDF5CEBD39D2F2E60726F987D4E54C8C38D7B7FB8EB46AF4D81E8F4A34122ADCEB174E9309FE336E72723AC7578A6E7AE249CEF35A2 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreBoundToForm.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreBoundToForm.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreBoundToForm.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreBoundToForm.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreBoundToForm.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreBoundToForm.DotNet9_0.verified.txt new file mode 100644 index 0000000000..60e25dab61 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreBoundToForm.DotNet9_0.verified.txt @@ -0,0 +1,76 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + multipart/form-data: { + Schema: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + param1: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + param2: { + Type: integer, + Format: int32, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + Encoding: { + param1: { + Style: Form + }, + param2: { + Style: Form + } + } + } + } + }, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: CC72B9C2B39FBC08D572E3EC1D511C5CE6706B54BF2DE5B3D381BAC8ABFCA83D8DDDDB402CDC8AD50122D927D56937A1B4F47078D561007DA2EFD4DA82FAF8CF +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Header.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Header.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Header.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Header.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Header.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Header.DotNet9_0.verified.txt new file mode 100644 index 0000000000..48c21a0ac9 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Header.DotNet9_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param, + In: Header, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 7B5009B038667AE7A48CBB1ABC73A6971D6453FAA7FBC670A231E82A45223BE46E36B2A10F66D6BC665D2C89EE2A2159EF4CBB45D66220D13291A7B5D1CFBA21 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Path.DotNet8_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Path.DotNet8_0.verified.txt new file mode 100644 index 0000000000..d72f56e957 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Path.DotNet8_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param, + In: Path, + Required: true, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 38B7A774F1E494464B7C8CDF5CEBD39D2F2E60726F987D4E54C8C38D7B7FB8EB46AF4D81E8F4A34122ADCEB174E9309FE336E72723AC7578A6E7AE249CEF35A2 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Path.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Path.DotNet9_0.verified.txt new file mode 100644 index 0000000000..d72f56e957 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Path.DotNet9_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param, + In: Path, + Required: true, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 38B7A774F1E494464B7C8CDF5CEBD39D2F2E60726F987D4E54C8C38D7B7FB8EB46AF4D81E8F4A34122ADCEB174E9309FE336E72723AC7578A6E7AE249CEF35A2 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Query.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Query.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Query.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Query.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=null.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Query.DotNet9_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=null.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=Query.DotNet9_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=null.DotNet8_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=null.DotNet8_0.verified.txt new file mode 100644 index 0000000000..856c5ca711 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=null.DotNet8_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param, + In: Query, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Form, + Explode: true, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 58CF9F0306B53D071A6262CED2A4A2D41D0DB9D62C183D00CFF85A74891E812B0AD9E56AF4F9F84E5DE4D0864EF33832BA39E5397CC6E2D2EE560075E91B4FC2 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=null.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=null.DotNet9_0.verified.txt new file mode 100644 index 0000000000..856c5ca711 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ApiParametersThatAreNotBoundToBodyOrForm_bindingSourceId=null.DotNet9_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param, + In: Query, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Form, + Explode: true, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 58CF9F0306B53D071A6262CED2A4A2D41D0DB9D62C183D00CFF85A74891E812B0AD9E56AF4F9F84E5DE4D0864EF33832BA39E5397CC6E2D2EE560075E91B4FC2 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ConflictingActionsResolverIsSpecified.DotNet8_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ConflictingActionsResolverIsSpecified.DotNet8_0.verified.txt new file mode 100644 index 0000000000..b275ef8989 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ConflictingActionsResolverIsSpecified.DotNet8_0.verified.txt @@ -0,0 +1,30 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 0E75218C57C662359EC554B377E7600D033FDF17E191A0E468F1E402807067F96CA4BF92320CC0B13E796E1E39DF7997BCF9A2F00DEF42D6D1AD6F47A7F35666 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ConflictingActionsResolverIsSpecified.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ConflictingActionsResolverIsSpecified.DotNet9_0.verified.txt new file mode 100644 index 0000000000..b275ef8989 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.ConflictingActionsResolverIsSpecified.DotNet9_0.verified.txt @@ -0,0 +1,30 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 0E75218C57C662359EC554B377E7600D033FDF17E191A0E468F1E402807067F96CA4BF92320CC0B13E796E1E39DF7997BCF9A2F00DEF42D6D1AD6F47A7F35666 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasDescriptionAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasDescriptionAttribute.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasDescriptionAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasDescriptionAttribute.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasDescriptionAttribute.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasDescriptionAttribute.DotNet9_0.verified.txt new file mode 100644 index 0000000000..99bba4ddf0 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasDescriptionAttribute.DotNet9_0.verified.txt @@ -0,0 +1,31 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Description: A Test Description, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 377D7B06298BAF6A0588F14C290399EBDBB413894F0CD99EF1925572243C3E5A5327372612D817C05797EA624236A755956F038D6EE98703FC1B5D50CEF6DA12 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasSummaryAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasSummaryAttribute.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasSummaryAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasSummaryAttribute.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasSummaryAttribute.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasSummaryAttribute.DotNet9_0.verified.txt new file mode 100644 index 0000000000..f0d4c611fb --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasSummaryAttribute.DotNet9_0.verified.txt @@ -0,0 +1,31 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Summary: A Test Summary, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 7FA24A4FA7C42D165A62545BD3562D78996223809931B2053BCD1658D0460D8F72824735CF34E0A5CF73E80E26F219BE05D1CCEB6CB197B29FF72EFB24DE00F5 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasTags.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasTags.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasTags.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasTags.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasTags.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasTags.DotNet9_0.verified.txt new file mode 100644 index 0000000000..07c776deb8 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.EndpointMetadataHasTags.DotNet9_0.verified.txt @@ -0,0 +1,38 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Some, + UnresolvedReference: false + }, + { + Name: Tags, + UnresolvedReference: false + }, + { + Name: Here, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 6F8975472729E3A264232F09327A9B51A158FC6D0952BFC812CA902D14346E719EDB456AC1247F9020009B8A3A813011BB9CC7E9699A064E91F4A73A32FD7A0D +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Copies_Description_From_GeneratedSchema.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Copies_Description_From_GeneratedSchema.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Copies_Description_From_GeneratedSchema.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Copies_Description_From_GeneratedSchema.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Copies_Description_From_GeneratedSchema.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Copies_Description_From_GeneratedSchema.DotNet9_0.verified.txt new file mode 100644 index 0000000000..4497bf9672 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Copies_Description_From_GeneratedSchema.DotNet9_0.verified.txt @@ -0,0 +1,130 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: EnumWithDefault, + In: Query, + Description:

Members:

  • Value2 - 2
  • Value4 - 4
  • Value8 - 8
, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Form, + Explode: true, + AllowReserved: false, + Schema: { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: IntEnum, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/IntEnum, + ReferenceV2: #/definitions/IntEnum + } + } + }, + { + UnresolvedReference: false, + Name: EnumArrayWithDefault, + In: Query, + Description:

Members:

  • Value2 - 2
  • Value4 - 4
  • Value8 - 8
, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Form, + Explode: true, + AllowReserved: false, + Schema: { + Type: array, + Description:

Members:

  • Value2 - 2
  • Value4 - 4
  • Value8 - 8
, + Default: [ + { + Value: 4 + } + ], + ReadOnly: false, + WriteOnly: false, + Items: { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: IntEnum, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/IntEnum, + ReferenceV2: #/definitions/IntEnum + } + }, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: { + Schemas: { + IntEnum: { + Type: integer, + Format: int32, + Description:

Members:

  • Value2 - 2
  • Value4 - 4
  • Value8 - 8
, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Enum: [ + { + Value: 2 + }, + { + Value: 4 + }, + { + Value: 8 + } + ], + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + }, + HashCode: 29A4A89ADE3B75E921A9EF9CE77F3E1517293B167A0B1513F55C57F3E84194193E8B24F875170DE0524C73CF5AB9DDCDF6556F1BDC2E6EA1F8171340F4C0F0B1 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFile.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFile.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFile.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFile.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFile.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFile.DotNet9_0.verified.txt new file mode 100644 index 0000000000..5ee6d90317 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFile.DotNet9_0.verified.txt @@ -0,0 +1,53 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + OperationId: OperationIdSetInMetadata, + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + application/someMediaType: { + Schema: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + param: { + Type: string, + Format: binary, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + Encoding: { + param: { + Style: Form + } + } + } + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 7D034A2620C1D85B3AC60194DFA59693F727DE4704B2D02E124FDA37F843426C258EF2BEB84E6B8E8D315E23A4BCBE1F423B479E6CDF8AFFB8514D49B9A3CC9E +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFileCollection.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFileCollection.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFileCollection.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFileCollection.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFileCollection.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFileCollection.DotNet9_0.verified.txt new file mode 100644 index 0000000000..4ff258c0fd --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIFormFileCollection.DotNet9_0.verified.txt @@ -0,0 +1,62 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + OperationId: OperationIdSetInMetadata, + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + application/someMediaType: { + Schema: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + param: { + Type: array, + ReadOnly: false, + WriteOnly: false, + Items: { + Type: string, + Format: binary, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + Encoding: { + param: { + Style: Form + } + } + } + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 073D8B8E67D5100DD8AF06EC69A3C02B8DBF29E46621ED6EB590DEA519F2C8941398F6B95292D891CC4E18C2F4D5D38A8F904545CFFC219E4FF4613AD605E5A5 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithSeveralFromForms.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithSeveralFromForms.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithSeveralFromForms.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithSeveralFromForms.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithSeveralFromForms.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithSeveralFromForms.DotNet9_0.verified.txt new file mode 100644 index 0000000000..6c22fe28bc --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithSeveralFromForms.DotNet9_0.verified.txt @@ -0,0 +1,174 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + OperationId: OperationIdSetInMetadata, + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + application/someMediaType: { + Schema: { + ReadOnly: false, + WriteOnly: false, + AllOf: [ + { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: TestDto, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/TestDto, + ReferenceV2: #/definitions/TestDto + } + }, + { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: TypeWithDefaultAttributeOnEnum, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/TypeWithDefaultAttributeOnEnum, + ReferenceV2: #/definitions/TypeWithDefaultAttributeOnEnum + } + } + ], + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: { + Schemas: { + IntEnum: { + Type: integer, + Format: int32, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Enum: [ + { + Value: 2 + }, + { + Value: 4 + }, + { + Value: 8 + } + ], + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + TestDto: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + Prop1: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: true, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: false, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + TypeWithDefaultAttributeOnEnum: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + EnumArrayWithDefault: { + Type: array, + Default: [ + { + Value: 4 + } + ], + ReadOnly: false, + WriteOnly: false, + Items: { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: IntEnum, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/IntEnum, + ReferenceV2: #/definitions/IntEnum + } + }, + AdditionalPropertiesAllowed: true, + Nullable: true, + Deprecated: false, + UnresolvedReference: false + }, + EnumWithDefault: { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: IntEnum, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/IntEnum, + ReferenceV2: #/definitions/IntEnum + } + } + }, + AdditionalPropertiesAllowed: false, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + }, + HashCode: 41D7DF10C7C0CE16E982FDA61A24E00E80C545544532DDE161A3189D46D8B3F2FD312173BC4F903FA4F3D695D66A00CEF815217B8B865479D45961D02D3B8609 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithStringFromForm.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithStringFromForm.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithStringFromForm.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithStringFromForm.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithStringFromForm.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithStringFromForm.DotNet9_0.verified.txt new file mode 100644 index 0000000000..e7c7a6ab9f --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithStringFromForm.DotNet9_0.verified.txt @@ -0,0 +1,52 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + OperationId: OperationIdSetInMetadata, + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + application/someMediaType: { + Schema: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + param: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + Encoding: { + param: { + Style: Form + } + } + } + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 7639B8A665AFC72F5C8D9ED02AA2E6416B9F82FDCC86D490FD248D3B657355F3993BD00384468E8D23DC0AC9FACECD425824F9596F6183EBDF974B9343CEDCF7 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject.DotNet9_0.verified.txt new file mode 100644 index 0000000000..c476d36fe6 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject.DotNet9_0.verified.txt @@ -0,0 +1,78 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + multipart/form-data: { + Schema: { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: SwaggerIngoreAnnotatedType, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/SwaggerIngoreAnnotatedType, + ReferenceV2: #/definitions/SwaggerIngoreAnnotatedType + } + } + } + } + }, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: { + Schemas: { + SwaggerIngoreAnnotatedType: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + NotIgnoredString: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: true, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: false, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + }, + HashCode: 0E2C58414C7ED713D3719C648D84DD5BD89DA32B914B93EB79C850258F556DDBB26E7B3CE9D60B6FFC5F288B4A255E3A9B947C7CD3F5ED921B2416BB9F155882 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject_AndString.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject_AndString.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject_AndString.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject_AndString.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject_AndString.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject_AndString.DotNet9_0.verified.txt new file mode 100644 index 0000000000..32b4296eaa --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_FromFormObject_AndString.DotNet9_0.verified.txt @@ -0,0 +1,113 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + RequestBody: { + UnresolvedReference: false, + Required: false, + Content: { + multipart/form-data: { + Schema: { + ReadOnly: false, + WriteOnly: false, + AllOf: [ + { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: SwaggerIngoreAnnotatedType, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/SwaggerIngoreAnnotatedType, + ReferenceV2: #/definitions/SwaggerIngoreAnnotatedType + } + }, + { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + param2: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + ], + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + }, + Encoding: { + param2: { + Style: Form + } + } + } + } + }, + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: { + Schemas: { + SwaggerIngoreAnnotatedType: { + Type: object, + ReadOnly: false, + WriteOnly: false, + Properties: { + NotIgnoredString: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: true, + Deprecated: false, + UnresolvedReference: false + } + }, + AdditionalPropertiesAllowed: false, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + }, + HashCode: 7E7750D2523B09ED937BC8BD153C28310201A9806AA769317BC100C6D938DCB55AA32E2290EB9A7563A8907012DB9BA0FA3035FE63823769A229BD27AFE98FA6 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_TypeIsEnum_AndModelMetadataTypeIsString.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_TypeIsEnum_AndModelMetadataTypeIsString.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_TypeIsEnum_AndModelMetadataTypeIsString.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_TypeIsEnum_AndModelMetadataTypeIsString.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_TypeIsEnum_AndModelMetadataTypeIsString.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_TypeIsEnum_AndModelMetadataTypeIsString.DotNet9_0.verified.txt new file mode 100644 index 0000000000..1376d80d26 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.GetSwagger_Works_As_Expected_When_TypeIsEnum_AndModelMetadataTypeIsString.DotNet9_0.verified.txt @@ -0,0 +1,84 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Parameters: [ + { + UnresolvedReference: false, + Name: param1, + In: Query, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Form, + Explode: true, + AllowReserved: false, + Schema: { + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false, + Reference: { + IsFragrament: false, + Type: Schema, + Id: IntEnum, + IsExternal: false, + IsLocal: true, + ReferenceV3: #/components/schemas/IntEnum, + ReferenceV2: #/definitions/IntEnum + } + } + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: { + Schemas: { + IntEnum: { + Type: integer, + Format: int32, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Enum: [ + { + Value: 2 + }, + { + Value: 4 + }, + { + Value: 8 + } + ], + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + }, + HashCode: F2B8FE01A8D273C628EBD9F65C7F1E80622E3C5CBBB8F150E247A34C4558F617F1D056F7B1113ABE978F9E433A9FBCA1C65A6387FB918AF00AFB54E6F5A47C5D +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderParameterWithOpenApiOperation_action=ActionWithAcceptFromHeaderParameter.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithAcceptFromHeaderParameter.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderParameterWithOpenApiOperation_action=ActionWithAcceptFromHeaderParameter.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithAcceptFromHeaderParameter.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithAcceptFromHeaderParameter.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithAcceptFromHeaderParameter.DotNet9_0.verified.txt new file mode 100644 index 0000000000..253712d058 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithAcceptFromHeaderParameter.DotNet9_0.verified.txt @@ -0,0 +1,50 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Get: { + OperationId: OperationIdSetInMetadata, + Parameters: [ + { + UnresolvedReference: false, + Name: accept, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false + }, + { + UnresolvedReference: false, + Name: param, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 48AB134AF00E0ED90AEA7E4E5BADDD7218AB02E7956DD5FAE3C500F4324F14066B32F2EF85E9C52A68431858FED77604C3ABE6CAED518CCB8EC46D22DF63A3DF +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderParameterWithOpenApiOperation_action=ActionWithAuthorizationFromHeaderParameter.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithAuthorizationFromHeaderParameter.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderParameterWithOpenApiOperation_action=ActionWithAuthorizationFromHeaderParameter.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithAuthorizationFromHeaderParameter.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithAuthorizationFromHeaderParameter.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithAuthorizationFromHeaderParameter.DotNet9_0.verified.txt new file mode 100644 index 0000000000..e6b98e02f1 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithAuthorizationFromHeaderParameter.DotNet9_0.verified.txt @@ -0,0 +1,50 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Get: { + OperationId: OperationIdSetInMetadata, + Parameters: [ + { + UnresolvedReference: false, + Name: authorization, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false + }, + { + UnresolvedReference: false, + Name: param, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 7B61DF19EC4750E8986D14FA33D86546B51021EA5782C80735BD0BE7A8937AB7CF57D19DDB31BAF396652C20AE904404BAF7116B4C6678720293B513806412ED +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderParameterWithOpenApiOperation_action=ActionWithContentTypeFromHeaderParameter.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithContentTypeFromHeaderParameter.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderParameterWithOpenApiOperation_action=ActionWithContentTypeFromHeaderParameter.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithContentTypeFromHeaderParameter.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithContentTypeFromHeaderParameter.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithContentTypeFromHeaderParameter.DotNet9_0.verified.txt new file mode 100644 index 0000000000..7d4ba212df --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.IllegalHeaderForOperation_action=ActionWithContentTypeFromHeaderParameter.DotNet9_0.verified.txt @@ -0,0 +1,50 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Get: { + OperationId: OperationIdSetInMetadata, + Parameters: [ + { + UnresolvedReference: false, + Name: Content-Type, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false + }, + { + UnresolvedReference: false, + Name: param, + Required: false, + Deprecated: false, + AllowEmptyValue: false, + Style: Simple, + Explode: false, + AllowReserved: false, + Schema: { + Type: string, + ReadOnly: false, + WriteOnly: false, + AdditionalPropertiesAllowed: true, + Nullable: false, + Deprecated: false, + UnresolvedReference: false + } + } + ], + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: F6CB61AEE648F54EC5BBCD1801BF8194997A0D5B99DDCFC0AF71CEDF79888B58EC1798313ECD4181CBAA61F377A80199CDB82412B744E9EF115F247F8A4A18EC +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.OperationHasSwaggerIgnoreAttribute.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.OperationHasSwaggerIgnoreAttribute.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.OperationHasSwaggerIgnoreAttribute.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.OperationHasSwaggerIgnoreAttribute.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.OperationHasSwaggerIgnoreAttribute.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.OperationHasSwaggerIgnoreAttribute.DotNet9_0.verified.txt new file mode 100644 index 0000000000..ba50ebcb2d --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.OperationHasSwaggerIgnoreAttribute.DotNet9_0.verified.txt @@ -0,0 +1,8 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Components: {}, + HashCode: 862B7E551B2E991D5F9B640090999C8D4EA20752DC6C69FC82E176A30B2039344A80321E469E806BD3AEA3641DAD6DEE970423561F262A187C04F58915996596 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.SortKeySelectorIsSpecified.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.SortKeySelectorIsSpecified.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.SortKeySelectorIsSpecified.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.SortKeySelectorIsSpecified.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.SortKeySelectorIsSpecified.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.SortKeySelectorIsSpecified.DotNet9_0.verified.txt new file mode 100644 index 0000000000..86ae63d164 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.SortKeySelectorIsSpecified.DotNet9_0.verified.txt @@ -0,0 +1,70 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource1: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + }, + /resource2: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + }, + /resource3: { + Operations: { + Post: { + Tags: [ + { + Name: Fake, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 6A7EE4850A3B6C88EFE631633A4697175A2BD849DD792CC4F3182CBE0F1480315A7C7BDEE0EA3243913A2D1632B10B91554A10C017B345B76018EBF3A2AF774B +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.TagSelectorIsSpecified.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.TagSelectorIsSpecified.DotNet8_0.verified.txt similarity index 100% rename from test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.TagSelectorIsSpecified.verified.txt rename to test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.TagSelectorIsSpecified.DotNet8_0.verified.txt diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.TagSelectorIsSpecified.DotNet9_0.verified.txt b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.TagSelectorIsSpecified.DotNet9_0.verified.txt new file mode 100644 index 0000000000..67eccdecb8 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.TagSelectorIsSpecified.DotNet9_0.verified.txt @@ -0,0 +1,30 @@ +{ + Info: { + Title: Test API, + Version: V1 + }, + Paths: { + /resource: { + Operations: { + Post: { + Tags: [ + { + Name: resource, + UnresolvedReference: false + } + ], + Responses: { + 200: { + Description: OK, + UnresolvedReference: false + } + }, + Deprecated: false + } + }, + UnresolvedReference: false + } + }, + Components: {}, + HashCode: 69CCB42286A25F56E56EAA7871BD9DA98131363AC8B40108CAE81CC37239B4120053F46BCE3E442D28004982C097C4712D8646DE2B588BBFCA085557BC0488F7 +} \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.cs index fc25ad763a..ee9142863e 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGeneratorVerifyTests/SwaggerGeneratorVerifyTests.cs @@ -27,8 +27,8 @@ public class SwaggerGeneratorVerifyTests public Task ApiDescriptionsWithMatchingGroupName() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithNoParameters), groupName: "v1", httpMethod: "POST", relativePath: "resource"), @@ -37,7 +37,7 @@ public Task ApiDescriptionsWithMatchingGroupName() ApiDescriptionFactory.Create( c => nameof(c.ActionWithNoParameters), groupName: "v2", httpMethod: "POST", relativePath: "resource"), - }, + ], options: new SwaggerGeneratorOptions { SwaggerDocs = new Dictionary @@ -49,23 +49,25 @@ public Task ApiDescriptionsWithMatchingGroupName() var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task ActionWithRouteNameMetadata() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithRouteNameMetadata), groupName: "v1", httpMethod: "POST", relativePath: "resource"), - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -74,22 +76,23 @@ public Task ActionWithEndpointNameMetadata() var methodInfo = typeof(FakeController).GetMethod(nameof(FakeController.ActionWithParameter)); var actionDescriptor = new ActionDescriptor { - EndpointMetadata = new List() { new EndpointNameMetadata("SomeEndpointName") }, + EndpointMetadata = [new EndpointNameMetadata("SomeEndpointName")], RouteValues = new Dictionary { ["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty) } }; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create(actionDescriptor, methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource"), - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -98,35 +101,36 @@ public Task ActionWithProvidedOpenApiMetadata() var methodInfo = typeof(FakeController).GetMethod(nameof(FakeController.ActionWithParameter)); var actionDescriptor = new ActionDescriptor { - EndpointMetadata = new List() - { + EndpointMetadata = + [ new OpenApiOperation { OperationId = "OperationIdSetInMetadata", - Parameters = new List() - { + Parameters = + [ new OpenApiParameter { Name = "ParameterInMetadata" } - } + ] } - }, + ], RouteValues = new Dictionary { ["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty) } }; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create(actionDescriptor, methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource"), - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -135,8 +139,8 @@ public Task ActionWithProducesAttributeAndProvidedOpenApiOperation() var methodInfo = typeof(FakeController).GetMethod(nameof(FakeController.ActionWithProducesAttribute)); var actionDescriptor = new ActionDescriptor { - EndpointMetadata = new List() - { + EndpointMetadata = + [ new OpenApiOperation { OperationId = "OperationIdSetInMetadata", @@ -151,35 +155,36 @@ public Task ActionWithProducesAttributeAndProvidedOpenApiOperation() } } } - }, + ], RouteValues = new Dictionary { ["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty) } }; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( actionDescriptor, methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource", - supportedResponseTypes: new[] - { + supportedResponseTypes: + [ new ApiResponseType() { StatusCode = 200, Type = typeof(TestDto) } - }), - } + ]), + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -188,8 +193,8 @@ public Task ActionWithConsumesAttributeAndProvidedOpenApiOperation() var methodInfo = typeof(FakeController).GetMethod(nameof(FakeController.ActionWithConsumesAttribute)); var actionDescriptor = new ActionDescriptor { - EndpointMetadata = new List() - { + EndpointMetadata = + [ new OpenApiOperation { OperationId = "OperationIdSetInMetadata", @@ -201,36 +206,37 @@ public Task ActionWithConsumesAttributeAndProvidedOpenApiOperation() } } } - }, + ], RouteValues = new Dictionary { ["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty) } }; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( actionDescriptor, methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new[] - { + parameterDescriptions: + [ new ApiParameterDescription() { Name = "param", Source = BindingSource.Body, ModelMetadata = ModelMetadataFactory.CreateForType(typeof(TestDto)) } - }), - } + ]), + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -239,73 +245,75 @@ public Task ActionWithParameterAndProvidedOpenApiOperation() var methodInfo = typeof(FakeController).GetMethod(nameof(FakeController.ActionWithParameter)); var actionDescriptor = new ActionDescriptor { - EndpointMetadata = new List() - { + EndpointMetadata = + [ new OpenApiOperation { OperationId = "OperationIdSetInMetadata", - Parameters = new List() - { + Parameters = + [ new OpenApiParameter { Name = "ParameterInMetadata" } - } + ] } - }, + ], RouteValues = new Dictionary { ["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty) } }; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( actionDescriptor, methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new[] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "ParameterInMetadata", ModelMetadata = ModelMetadataFactory.CreateForType(typeof(string)), Type = typeof(string) } - }), - } + ]), + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task ActionHasObsoleteAttribute() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithObsoleteAttribute), groupName: "v1", httpMethod: "POST", relativePath: "resource"), - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task SortKeySelectorIsSpecified() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithNoParameters), groupName: "v1", httpMethod: "POST", relativePath: "resource3"), @@ -314,7 +322,7 @@ public Task SortKeySelectorIsSpecified() ApiDescriptionFactory.Create( c => nameof(c.ActionWithNoParameters), groupName: "v1", httpMethod: "POST", relativePath: "resource2"), - }, + ], options: new SwaggerGeneratorOptions { SwaggerDocs = new Dictionary @@ -327,31 +335,33 @@ public Task SortKeySelectorIsSpecified() var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task TagSelectorIsSpecified() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithNoParameters), groupName: "v1", httpMethod: "POST", relativePath: "resource"), - }, + ], options: new SwaggerGeneratorOptions { SwaggerDocs = new Dictionary { ["v1"] = new OpenApiInfo { Version = "V1", Title = "Test API" } }, - TagsSelector = (apiDesc) => new[] { apiDesc.RelativePath } + TagsSelector = (apiDesc) => [apiDesc.RelativePath] } ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -360,22 +370,23 @@ public Task EndpointMetadataHasTags() var methodInfo = typeof(FakeController).GetMethod(nameof(FakeController.ActionWithParameter)); var actionDescriptor = new ActionDescriptor { - EndpointMetadata = new List() { new TagsAttribute("Some", "Tags", "Here") }, + EndpointMetadata = [new TagsAttribute("Some", "Tags", "Here")], RouteValues = new Dictionary { ["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty) } }; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create(actionDescriptor, methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource"), - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Theory] @@ -386,103 +397,107 @@ public Task EndpointMetadataHasTags() public Task ApiParametersThatAreNotBoundToBodyOrForm(string bindingSourceId) { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithParameter), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new [] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param", Source = (bindingSourceId != null) ? new BindingSource(bindingSourceId, null, false, true) : null } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document).UseParameters(bindingSourceId); + return Verifier.Verify(document) + .UseParameters(bindingSourceId) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task OperationHasSwaggerIgnoreAttribute() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithSwaggerIgnoreAttribute), groupName: "v1", httpMethod: "POST", relativePath: "ignored", - parameterDescriptions: Array.Empty() + parameterDescriptions: [] ) - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task ActionParameterHasBindNeverAttribute() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithParameterWithBindNeverAttribute), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new [] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param", Source = BindingSource.Query } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task ActionParameterHasSwaggerIgnoreAttribute() { var subject = Subject( - new[] - { + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithIntParameterWithSwaggerIgnoreAttribute), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new[] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param", Source = BindingSource.Query } - } + ] ) - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Theory] @@ -495,15 +510,14 @@ public Task ActionsWithIllegalHeaderParameters(string action) var fromHeaderAttribute = illegalParameter.GetCustomAttribute(); var subject = Subject( - new[] - { + [ ApiDescriptionFactory.Create( c => action, groupName: "v1", httpMethod: "GET", relativePath: "resource", - parameterDescriptions: new[] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = fromHeaderAttribute?.Name ?? illegalParameter.Name, @@ -515,14 +529,16 @@ public Task ActionsWithIllegalHeaderParameters(string action) Name = "param", Source = BindingSource.Header } - } + ] ) - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document).UseParameters(action); + return Verifier.Verify(document) + .UseParameters(action) + .UniqueForTargetFrameworkAndVersion(); } [Theory] @@ -537,13 +553,13 @@ public Task ActionParameterIsIllegalHeaderParameterWithProvidedOpenApiOperation( var methodInfo = typeof(FakeController).GetMethod(action); var actionDescriptor = new ActionDescriptor { - EndpointMetadata = new List() - { + EndpointMetadata = + [ new OpenApiOperation { OperationId = "OperationIdSetInMetadata", - Parameters = new List() - { + Parameters = + [ new OpenApiParameter { Name = illegalParameterName, @@ -552,25 +568,25 @@ public Task ActionParameterIsIllegalHeaderParameterWithProvidedOpenApiOperation( { Name = "param", } - } + ] } - }, + ], RouteValues = new Dictionary { ["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty) } }; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( actionDescriptor, methodInfo, groupName: "v1", httpMethod: "GET", relativePath: "resource", - parameterDescriptions: new[] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = illegalParameterName, @@ -584,42 +600,44 @@ public Task ActionParameterIsIllegalHeaderParameterWithProvidedOpenApiOperation( ModelMetadata = ModelMetadataFactory.CreateForType(typeof(string)), Type = typeof(string) } - }), - } + ]), + ] ); var document = subject.GetSwagger("v1"); return Verifier.Verify(document) .UseParameters(action) - .UseMethodName("IllegalHeaderParameterWithOpenApiOperation"); + .UseMethodName("IllegalHeaderForOperation") + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task ApiParameterIsBoundToPath() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithParameter), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new [] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param", Source = BindingSource.Path } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Theory] @@ -628,27 +646,29 @@ public Task ApiParameterIsBoundToPath() public Task ActionWithRequiredQueryParameter(string action) { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( methodInfo: typeof(FakeController).GetMethod(action), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new [] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param", Source = BindingSource.Query } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document).UseParameters(action); + return Verifier.Verify(document) + .UseParameters(action) + .UniqueForTargetFrameworkAndVersion(); } [Theory] @@ -657,31 +677,33 @@ public Task ActionWithRequiredQueryParameter(string action) public Task ActionWithRequiredBodyParameter(string action) { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( methodInfo: typeof(FakeController).GetMethod(action), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new [] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param", Source = BindingSource.Body, } - }, - supportedRequestFormats: new[] - { + ], + supportedRequestFormats: + [ new ApiRequestFormat { MediaType = "application/json" } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document).UseParameters(action); + return Verifier.Verify(document) + .UseParameters(action) + .UniqueForTargetFrameworkAndVersion(); } #if NET7_0_OR_GREATER @@ -689,28 +711,29 @@ public Task ActionWithRequiredBodyParameter(string action) public Task ActionWithRequiredMember() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( methodInfo: typeof(FakeController).GetMethod(nameof(FakeController.ActionWithRequiredMember)), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new [] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param", Source = BindingSource.Query, ModelMetadata = ModelMetadataFactory.CreateForProperty(typeof(FakeController.TypeWithRequiredProperty), "RequiredProperty") } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -719,22 +742,23 @@ public Task EndpointMetadataHasSummaryAttribute() var methodInfo = typeof(FakeController).GetMethod(nameof(FakeController.ActionWithParameter)); var actionDescriptor = new ActionDescriptor { - EndpointMetadata = new List() { new EndpointSummaryAttribute("A Test Summary") }, + EndpointMetadata = [new EndpointSummaryAttribute("A Test Summary")], RouteValues = new Dictionary { ["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty) } }; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create(actionDescriptor, methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource"), - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -743,22 +767,23 @@ public Task EndpointMetadataHasDescriptionAttribute() var methodInfo = typeof(FakeController).GetMethod(nameof(FakeController.ActionWithParameter)); var actionDescriptor = new ActionDescriptor { - EndpointMetadata = new List() { new EndpointDescriptionAttribute("A Test Description") }, + EndpointMetadata = [new EndpointDescriptionAttribute("A Test Description")], RouteValues = new Dictionary { ["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty) } }; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create(actionDescriptor, methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource"), - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } #endif @@ -787,57 +812,59 @@ static void Execute(object obj) { } }; var subject = Subject( - apiDescriptions: new[] - { - ApiDescriptionFactory.Create(actionDescriptor, action.Method, groupName: "v1", httpMethod: "POST", relativePath: "resource", parameterDescriptions: new[]{ parameter }), - } + apiDescriptions: + [ + ApiDescriptionFactory.Create(actionDescriptor, action.Method, groupName: "v1", httpMethod: "POST", relativePath: "resource", parameterDescriptions: [parameter]), + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task ApiParameterHasNoCorrespondingActionParameter() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithNoParameters), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new [] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param", Source = BindingSource.Path } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task ApiParametersThatAreBoundToForm() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithMultipleParameters), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new [] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param1", @@ -849,14 +876,15 @@ public Task ApiParametersThatAreBoundToForm() Source = BindingSource.Form, } - } + ] ) - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Theory] @@ -865,71 +893,74 @@ public Task ApiParametersThatAreBoundToForm() public Task ActionHasConsumesAttribute(string bindingSourceId) { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithConsumesAttribute), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new [] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param", Source = new BindingSource(bindingSourceId, null, false, true) } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document).UseParameters(bindingSourceId); + return Verifier.Verify(document) + .UseParameters(bindingSourceId) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task ActionWithReturnValueAndSupportedResponseTypes() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithReturnValue), groupName: "v1", httpMethod: "POST", relativePath: "resource", - supportedResponseTypes: new [] - { + supportedResponseTypes: + [ new ApiResponseType { - ApiResponseFormats = new [] { new ApiResponseFormat { MediaType = "application/json" } }, + ApiResponseFormats = [new ApiResponseFormat { MediaType = "application/json" }], StatusCode = 200, }, new ApiResponseType { - ApiResponseFormats = new [] { new ApiResponseFormat { MediaType = "application/json" } }, + ApiResponseFormats = [new ApiResponseFormat { MediaType = "application/json" }], StatusCode = 400 }, new ApiResponseType { - ApiResponseFormats = new [] { new ApiResponseFormat { MediaType = "application/json" } }, + ApiResponseFormats = [new ApiResponseFormat { MediaType = "application/json" }], StatusCode = 422 }, new ApiResponseType { - ApiResponseFormats = new [] { new ApiResponseFormat { MediaType = "application/json" } }, + ApiResponseFormats = [new ApiResponseFormat { MediaType = "application/json" }], IsDefaultResponse = true } - } + ] ) - } + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -940,67 +971,69 @@ public Task ActionHasFileResult() groupName: "v1", httpMethod: "POST", relativePath: "resource", - supportedResponseTypes: new[] - { + supportedResponseTypes: + [ new ApiResponseType { - ApiResponseFormats = new [] { new ApiResponseFormat { MediaType = "application/zip" } }, + ApiResponseFormats = [new ApiResponseFormat { MediaType = "application/zip" }], StatusCode = 200, Type = typeof(FileContentResult) } - }); + ]); // ASP.NET Core sets ModelMetadata to null for FileResults apiDescription.SupportedResponseTypes[0].ModelMetadata = null; var subject = Subject( - apiDescriptions: new[] { apiDescription } + apiDescriptions: [apiDescription] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task ActionHasProducesAttribute() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithProducesAttribute), groupName: "v1", httpMethod: "POST", relativePath: "resource", - supportedResponseTypes: new [] - { + supportedResponseTypes: + [ new ApiResponseType { - ApiResponseFormats = new [] { new ApiResponseFormat { MediaType = "application/json" } }, + ApiResponseFormats = [new ApiResponseFormat { MediaType = "application/json" }], StatusCode = 200, } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] public Task ConflictingActionsResolverIsSpecified() { var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionWithNoParameters), groupName: "v1", httpMethod: "POST", relativePath: "resource"), ApiDescriptionFactory.Create( c => nameof(c.ActionWithNoParameters), groupName: "v1", httpMethod: "POST", relativePath: "resource") - }, + ], options: new SwaggerGeneratorOptions { SwaggerDocs = new Dictionary @@ -1013,7 +1046,8 @@ public Task ConflictingActionsResolverIsSpecified() var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -1028,15 +1062,15 @@ public Task ActionHavingFromFormAttributeButNotWithIFormFile() .GetParameters()[1]; var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionHavingFromFormAttributeButNotWithIFormFile), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new[] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = "param1", // Name of the parameter @@ -1049,13 +1083,14 @@ public Task ActionHavingFromFormAttributeButNotWithIFormFile() Type = typeof(IFormFile), // Type of the parameter ParameterDescriptor = new ControllerParameterDescriptor { ParameterInfo = fileUploadParameterInfo } } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -1073,15 +1108,15 @@ public Task ActionHavingFromFormAttributeWithSwaggerIgnore() new FakeICompositeMetadataDetailsProvider(), new DefaultMetadataDetails(ModelMetadataIdentity.ForProperty(propertyNotIgnored, typeof(string), typeof(SwaggerIngoreAnnotatedType)), ModelAttributes.GetAttributesForProperty(typeof(SwaggerIngoreAnnotatedType), propertyNotIgnored))); var subject = Subject( - apiDescriptions: new[] - { + apiDescriptions: + [ ApiDescriptionFactory.Create( c => nameof(c.ActionHavingFromFormAttributeWithSwaggerIgnore), groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new[] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = nameof(SwaggerIngoreAnnotatedType.IgnoredString), @@ -1096,12 +1131,13 @@ public Task ActionHavingFromFormAttributeWithSwaggerIgnore() Type = typeof(string), ModelMetadata = modelMetadataNotIgnored } - }) - } + ]) + ] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -1129,7 +1165,8 @@ public Task GetSwagger_Works_As_Expected_When_FromFormObject() ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -1164,7 +1201,8 @@ public Task GetSwagger_Works_As_Expected_When_FromFormObject_AndString() ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -1193,7 +1231,8 @@ public Task GetSwagger_Works_As_Expected_When_TypeIsEnum_AndModelMetadataTypeIsS var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -1218,8 +1257,8 @@ public Task GetSwagger_Copies_Description_From_GeneratedSchema() groupName: "v1", httpMethod: "POST", relativePath: "resource", - parameterDescriptions: new[] - { + parameterDescriptions: + [ new ApiParameterDescription { Name = nameof(TypeWithDefaultAttributeOnEnum.EnumWithDefault), @@ -1234,13 +1273,14 @@ public Task GetSwagger_Copies_Description_From_GeneratedSchema() Type = typeof(IntEnum[]), ModelMetadata = modelMetadataForEnumArray } - }) + ]) ], schemaFilters: [new TestEnumSchemaFilter()] ); var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -1297,7 +1337,8 @@ public Task GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithSe var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -1348,7 +1389,8 @@ public Task GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIF var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -1399,7 +1441,8 @@ public Task GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithIF var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } [Fact] @@ -1450,7 +1493,8 @@ public Task GetSwagger_GenerateConsumesSchemas_ForProvidedOpenApiOperationWithSt var document = subject.GetSwagger("v1"); - return Verifier.Verify(document); + return Verifier.Verify(document) + .UniqueForTargetFrameworkAndVersion(); } private static SwaggerGenerator Subject( @@ -1463,11 +1507,11 @@ private static SwaggerGenerator Subject( options ?? DefaultOptions, new FakeApiDescriptionGroupCollectionProvider(apiDescriptions), new SchemaGenerator(new SchemaGeneratorOptions() { SchemaFilters = schemaFilters ?? [] }, new JsonSerializerDataContractResolver(new JsonSerializerOptions())), - new FakeAuthenticationSchemeProvider(authenticationSchemes ?? Enumerable.Empty()) + new FakeAuthenticationSchemeProvider(authenticationSchemes ?? []) ); } - private static readonly SwaggerGeneratorOptions DefaultOptions = new SwaggerGeneratorOptions + private static readonly SwaggerGeneratorOptions DefaultOptions = new() { SwaggerDocs = new Dictionary { diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsExampleHelperTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsExampleHelperTests.cs index a3aef1458c..ee45fdaf41 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsExampleHelperTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsExampleHelperTests.cs @@ -19,14 +19,16 @@ public void Create_BuildsOpenApiArrayJson__When_NotStringTypeAndDataIsArray() "[\"one\",\"two\",\"three\"]"); Assert.NotNull(example); + var actual = Assert.IsType(example); + Assert.Equal(3, actual.Count); var item1 = Assert.IsType(actual[0]); var item2 = Assert.IsType(actual[1]); var item3 = Assert.IsType(actual[2]); - Assert.Equal("one", item1.Value); - Assert.Equal("two", item2.Value); + Assert.Equal("one", item1.Value); + Assert.Equal("two", item2.Value); Assert.Equal("three", item3.Value); } @@ -34,13 +36,14 @@ public void Create_BuildsOpenApiArrayJson__When_NotStringTypeAndDataIsArray() public void Create_BuildsOpenApiString_When_TypeString() { string exampleString = "example string with special characters\"<>\r\n\""; - OpenApiSchema schema = new OpenApiSchema { Type = "string" }; + var schema = new OpenApiSchema { Type = JsonSchemaTypes.String }; schemaRepository.AddDefinition("test", schema); - + var example = XmlCommentsExampleHelper.Create( schemaRepository, schema, exampleString); Assert.NotNull(example); + var actual = Assert.IsType(example); Assert.Equal(actual.Value, exampleString); } @@ -48,13 +51,14 @@ public void Create_BuildsOpenApiString_When_TypeString() [Fact] public void Create_ReturnsNull_When_TypeString_and_ValueNull() { - var schema = new OpenApiSchema { Type = "string" }; + var schema = new OpenApiSchema { Type = JsonSchemaTypes.String }; schemaRepository.AddDefinition("test", schema); var example = XmlCommentsExampleHelper.Create( schemaRepository, schema, "null"); Assert.NotNull(example); + var actual = Assert.IsType(example); Assert.Equal(AnyType.Null, actual.AnyType); } @@ -67,6 +71,7 @@ public void Create_AllowsSchemaToBeNull() var example = XmlCommentsExampleHelper.Create(schemaRepository, schema, "[]"); Assert.NotNull(example); + var actual = Assert.IsType(example); Assert.Empty(actual); } diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsParameterFilterTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsParameterFilterTests.cs index 392bcdbe3b..67cae38a59 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsParameterFilterTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsParameterFilterTests.cs @@ -12,7 +12,7 @@ public class XmlCommentsParameterFilterTests [Fact] public void Apply_SetsDescriptionAndExample_FromActionParamTag() { - var parameter = new OpenApiParameter { Schema = new OpenApiSchema { Type = "string" } }; + var parameter = new OpenApiParameter { Schema = new OpenApiSchema { Type = JsonSchemaTypes.String } }; var parameterInfo = typeof(FakeControllerWithXmlComments) .GetMethod(nameof(FakeControllerWithXmlComments.ActionWithParamTags)) .GetParameters()[0]; @@ -29,7 +29,7 @@ public void Apply_SetsDescriptionAndExample_FromActionParamTag() [Fact] public void Apply_SetsDescriptionAndExample_FromUriTypeActionParamTag() { - var parameter = new OpenApiParameter { Schema = new OpenApiSchema { Type = "string" } }; + var parameter = new OpenApiParameter { Schema = new OpenApiSchema { Type = JsonSchemaTypes.String } }; var parameterInfo = typeof(FakeControllerWithXmlComments) .GetMethod(nameof(FakeControllerWithXmlComments.ActionWithParamTags)) .GetParameters()[1]; @@ -46,7 +46,7 @@ public void Apply_SetsDescriptionAndExample_FromUriTypeActionParamTag() [Fact] public void Apply_SetsDescriptionAndExample_FromUnderlyingGenericTypeActionParamTag() { - var parameter = new OpenApiParameter { Schema = new OpenApiSchema { Type = "string" } }; + var parameter = new OpenApiParameter { Schema = new OpenApiSchema { Type = JsonSchemaTypes.String } }; var parameterInfo = typeof(FakeConstructedControllerWithXmlComments) .GetMethod(nameof(FakeConstructedControllerWithXmlComments.ActionWithParamTags)) .GetParameters()[0]; @@ -63,7 +63,7 @@ public void Apply_SetsDescriptionAndExample_FromUnderlyingGenericTypeActionParam [Fact] public void Apply_SetsDescriptionAndExample_FromPropertySummaryAndExampleTags() { - var parameter = new OpenApiParameter { Schema = new OpenApiSchema { Type = "string", Description = "schema-level description" } }; + var parameter = new OpenApiParameter { Schema = new OpenApiSchema { Type = JsonSchemaTypes.String, Description = "schema-level description" } }; var propertyInfo = typeof(XmlAnnotatedType).GetProperty(nameof(XmlAnnotatedType.StringProperty)); var apiParameterDescription = new ApiParameterDescription { }; var filterContext = new ParameterFilterContext(apiParameterDescription, null, null, propertyInfo: propertyInfo); @@ -79,7 +79,7 @@ public void Apply_SetsDescriptionAndExample_FromPropertySummaryAndExampleTags() [Fact] public void Apply_SetsDescriptionAndExample_FromUriTypePropertySummaryAndExampleTags() { - var parameter = new OpenApiParameter { Schema = new OpenApiSchema { Type = "string", Description = "schema-level description" } }; + var parameter = new OpenApiParameter { Schema = new OpenApiSchema { Type = JsonSchemaTypes.String, Description = "schema-level description" } }; var propertyInfo = typeof(XmlAnnotatedType).GetProperty(nameof(XmlAnnotatedType.StringPropertyWithUri)); var apiParameterDescription = new ApiParameterDescription { }; var filterContext = new ParameterFilterContext(apiParameterDescription, null, null, propertyInfo: propertyInfo); diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsRequestBodyFilterTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsRequestBodyFilterTests.cs index eddfd34133..dd5abd5a39 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsRequestBodyFilterTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsRequestBodyFilterTests.cs @@ -19,7 +19,7 @@ public void Apply_SetsDescriptionAndExample_FromActionParamTag() { Content = new Dictionary { - ["application/json"] = new OpenApiMediaType { Schema = new OpenApiSchema { Type = "string" } } + ["application/json"] = new OpenApiMediaType { Schema = new OpenApiSchema { Type = JsonSchemaTypes.String } } } }; var parameterInfo = typeof(FakeControllerWithXmlComments) @@ -45,7 +45,7 @@ public void Apply_SetsDescriptionAndExample_FromUnderlyingGenericTypeActionParam { Content = new Dictionary { - ["application/json"] = new OpenApiMediaType { Schema = new OpenApiSchema { Type = "string" } } + ["application/json"] = new OpenApiMediaType { Schema = new OpenApiSchema { Type = JsonSchemaTypes.String } } } }; var parameterInfo = typeof(FakeConstructedControllerWithXmlComments) @@ -71,7 +71,7 @@ public void Apply_SetsDescriptionAndExample_FromPropertySummaryAndExampleTags() { Content = new Dictionary { - ["application/json"] = new OpenApiMediaType { Schema = new OpenApiSchema { Type = "string" } } + ["application/json"] = new OpenApiMediaType { Schema = new OpenApiSchema { Type = JsonSchemaTypes.String } } } }; var bodyParameterDescription = new ApiParameterDescription @@ -95,7 +95,7 @@ public void Apply_SetsDescriptionAndExample_FromUriTypePropertySummaryAndExample { Content = new Dictionary { - ["application/json"] = new OpenApiMediaType { Schema = new OpenApiSchema { Type = "string" } } + ["application/json"] = new OpenApiMediaType { Schema = new OpenApiSchema { Type = JsonSchemaTypes.String } } } }; var bodyParameterDescription = new ApiParameterDescription @@ -118,7 +118,7 @@ public void Apply_SetsDescription_ForParameterFromBody() { Content = new Dictionary { - ["application/json"] = new OpenApiMediaType { Schema = new OpenApiSchema { Type = "string" } } + ["application/json"] = new OpenApiMediaType { Schema = new OpenApiSchema { Type = JsonSchemaTypes.String } } } }; var parameterInfo = typeof(FakeControllerWithXmlComments) @@ -150,7 +150,7 @@ public void Apply_SetsDescription_ForParameterFromForm() { Schema = new OpenApiSchema { - Type = "string", + Type = JsonSchemaTypes.String, Properties = new Dictionary() { [parameterInfo.Name] = new() diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsSchemaFilterTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsSchemaFilterTests.cs index cc35e1c7da..801bf57093 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsSchemaFilterTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsSchemaFilterTests.cs @@ -6,6 +6,8 @@ using Swashbuckle.AspNetCore.TestSupport; using Xunit; +using JsonSchemaType = string; + namespace Swashbuckle.AspNetCore.SwaggerGen.Test { public class XmlCommentsSchemaFilterTests @@ -56,36 +58,41 @@ public void Apply_SetsDescription_FromPropertySummaryTag( Assert.Equal(expectedDescription, schema.Description); } + public static TheoryData Apply_SetsExample_FromPropertyExampleTag_Data() => new() + { + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.BoolProperty), JsonSchemaTypes.Boolean, "true" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.IntProperty), JsonSchemaTypes.Integer, "10" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.LongProperty), JsonSchemaTypes.Integer, "4294967295" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.FloatProperty), JsonSchemaTypes.Number, "1.2" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.DoubleProperty), JsonSchemaTypes.Number, "1.25" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.DateTimeProperty), JsonSchemaTypes.String, "\"6/22/2022 12:00:00 AM\"" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.EnumProperty), JsonSchemaTypes.Integer, "2" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.GuidProperty), JsonSchemaTypes.String, "\"d3966535-2637-48fa-b911-e3c27405ee09\"" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.StringProperty), JsonSchemaTypes.String, "\"Example for StringProperty\"" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.ObjectProperty), JsonSchemaTypes.Object, "{\n \"prop1\": 1,\n \"prop2\": \"foobar\"\n}" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.StringPropertyWithNullExample), JsonSchemaTypes.String, "null" }, + { typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.StringPropertyWithUri), JsonSchemaTypes.String, "\"https://test.com/a?b=1&c=2\"" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.BoolProperty), JsonSchemaTypes.Boolean, "true" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.IntProperty), JsonSchemaTypes.Integer, "10" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.LongProperty), JsonSchemaTypes.Integer, "4294967295" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.FloatProperty), JsonSchemaTypes.Number, "1.2" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.DoubleProperty), JsonSchemaTypes.Number, "1.25" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.DateTimeProperty), JsonSchemaTypes.String, "\"6/22/2022 12:00:00 AM\"" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.EnumProperty), JsonSchemaTypes.Integer, "2" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.GuidProperty), JsonSchemaTypes.String, "\"d3966535-2637-48fa-b911-e3c27405ee09\"" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.StringProperty), JsonSchemaTypes.String, "\"Example for StringProperty\"" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.ObjectProperty), JsonSchemaTypes.Object, "{\n \"prop1\": 1,\n \"prop2\": \"foobar\"\n}" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.StringPropertyWithNullExample), JsonSchemaTypes.String, "null" }, + { typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.StringPropertyWithUri), JsonSchemaTypes.String, "\"https://test.com/a?b=1&c=2\"" }, + }; + [Theory] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.BoolProperty), "boolean", "true")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.IntProperty), "integer", "10")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.LongProperty), "integer", "4294967295")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.FloatProperty), "number", "1.2")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.DoubleProperty), "number", "1.25")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.DateTimeProperty), "string", "\"6/22/2022 12:00:00 AM\"")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.EnumProperty), "integer", "2")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.GuidProperty), "string", "\"d3966535-2637-48fa-b911-e3c27405ee09\"")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.StringProperty), "string", "\"Example for StringProperty\"")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.ObjectProperty), "object", "{\n \"prop1\": 1,\n \"prop2\": \"foobar\"\n}")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.StringPropertyWithNullExample), "string", "null")] - [InlineData(typeof(XmlAnnotatedType), nameof(XmlAnnotatedType.StringPropertyWithUri), "string", "\"https://test.com/a?b=1&c=2\"")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.BoolProperty), "boolean", "true")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.IntProperty), "integer", "10")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.LongProperty), "integer", "4294967295")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.FloatProperty), "number", "1.2")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.DoubleProperty), "number", "1.25")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.DateTimeProperty), "string", "\"6/22/2022 12:00:00 AM\"")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.EnumProperty), "integer", "2")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.GuidProperty), "string", "\"d3966535-2637-48fa-b911-e3c27405ee09\"")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.StringProperty), "string", "\"Example for StringProperty\"")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.ObjectProperty), "object", "{\n \"prop1\": 1,\n \"prop2\": \"foobar\"\n}")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.StringPropertyWithNullExample), "string", "null")] - [InlineData(typeof(XmlAnnotatedRecord), nameof(XmlAnnotatedRecord.StringPropertyWithUri), "string", "\"https://test.com/a?b=1&c=2\"")] + [MemberData(nameof(Apply_SetsExample_FromPropertyExampleTag_Data))] [UseInvariantCulture] public void Apply_SetsExample_FromPropertyExampleTag( Type declaringType, string propertyName, - string schemaType, + JsonSchemaType schemaType, string expectedExampleAsJson) { var propertyInfo = declaringType.GetProperty(propertyName); @@ -98,36 +105,41 @@ public void Apply_SetsExample_FromPropertyExampleTag( Assert.Equal(expectedExampleAsJson, schema.Example.ToJson()); } + public static TheoryData Apply_DoesNotSetExample_WhenPropertyExampleTagIsNotProvided_Data => new() + { + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.BoolProperty), JsonSchemaTypes.Boolean }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.IntProperty), JsonSchemaTypes.Integer }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.LongProperty), JsonSchemaTypes.Integer }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.FloatProperty), JsonSchemaTypes.Number }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.DoubleProperty), JsonSchemaTypes.Number }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.DateTimeProperty), JsonSchemaTypes.String }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.EnumProperty), JsonSchemaTypes.Integer }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.GuidProperty), JsonSchemaTypes.String }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.StringProperty), JsonSchemaTypes.String }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.ObjectProperty), JsonSchemaTypes.Object }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.StringPropertyWithNullExample), JsonSchemaTypes.String }, + { typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.StringPropertyWithUri), JsonSchemaTypes.String }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.BoolProperty), JsonSchemaTypes.Boolean }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.IntProperty), JsonSchemaTypes.Integer }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.LongProperty), JsonSchemaTypes.Integer }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.FloatProperty), JsonSchemaTypes.Number }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.DoubleProperty), JsonSchemaTypes.Number }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.DateTimeProperty), JsonSchemaTypes.String }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.EnumProperty), JsonSchemaTypes.Integer }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.GuidProperty), JsonSchemaTypes.String }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.StringProperty), JsonSchemaTypes.String }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.ObjectProperty), JsonSchemaTypes.Object }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.StringPropertyWithNullExample), JsonSchemaTypes.String }, + { typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.StringPropertyWithUri), JsonSchemaTypes.String }, + }; + [Theory] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.BoolProperty), "boolean")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.IntProperty), "integer")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.LongProperty), "integer")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.FloatProperty), "number")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.DoubleProperty), "number")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.DateTimeProperty), "string")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.EnumProperty), "integer")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.GuidProperty), "string")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.StringProperty), "string")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.ObjectProperty), "object")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.StringPropertyWithNullExample), "string")] - [InlineData(typeof(XmlAnnotatedTypeWithoutExample), nameof(XmlAnnotatedTypeWithoutExample.StringPropertyWithUri), "string")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.BoolProperty), "boolean")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.IntProperty), "integer")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.LongProperty), "integer")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.FloatProperty), "number")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.DoubleProperty), "number")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.DateTimeProperty), "string")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.EnumProperty), "integer")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.GuidProperty), "string")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.StringProperty), "string")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.ObjectProperty), "object")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.StringPropertyWithNullExample), "string")] - [InlineData(typeof(XmlAnnotatedRecordWithoutExample), nameof(XmlAnnotatedRecordWithoutExample.StringPropertyWithUri), "string")] + [MemberData(nameof(Apply_DoesNotSetExample_WhenPropertyExampleTagIsNotProvided_Data))] [UseInvariantCulture] public void Apply_DoesNotSetExample_WhenPropertyExampleTagIsNotProvided( Type declaringType, string propertyName, - string schemaType) + JsonSchemaType schemaType) { var propertyInfo = declaringType.GetProperty(propertyName); var schema = new OpenApiSchema { Type = schemaType }; @@ -146,7 +158,7 @@ public void Apply_UsesInvariantCulture_WhenSettingExample( float expectedValue) { var propertyInfo = typeof(XmlAnnotatedType).GetProperty(nameof(XmlAnnotatedType.FloatProperty)); - var schema = new OpenApiSchema { Type = "number", Format = "float" }; + var schema = new OpenApiSchema { Type = JsonSchemaTypes.Number, Format = "float" }; var filterContext = new SchemaFilterContext(propertyInfo.PropertyType, null, null, memberInfo: propertyInfo); var defaultCulture = CultureInfo.CurrentCulture; diff --git a/test/Swashbuckle.AspNetCore.TestSupport/Extensions/IOpenApiAnyExtensions.cs b/test/Swashbuckle.AspNetCore.TestSupport/Extensions/IOpenApiAnyExtensions.cs index 8b4211e3d6..53db14ba9e 100644 --- a/test/Swashbuckle.AspNetCore.TestSupport/Extensions/IOpenApiAnyExtensions.cs +++ b/test/Swashbuckle.AspNetCore.TestSupport/Extensions/IOpenApiAnyExtensions.cs @@ -1,18 +1,19 @@ using System.IO; using Microsoft.OpenApi; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Writers; +using Any = Microsoft.OpenApi.Any.IOpenApiAny; + namespace Swashbuckle.AspNetCore.TestSupport { public static class IOpenApiAnyExtensions { - public static string ToJson(this IOpenApiAny openApiAny) + public static string ToJson(this Any openApiAny) { var stringWriter = new StringWriter(); var jsonWriter = new OpenApiJsonWriter(stringWriter); - openApiAny.Write(jsonWriter, OpenApiSpecVersion.OpenApi3_0); + openApiAny.Write(jsonWriter, OpenApiSpecVersion.OpenApi3_0); return stringWriter.ToString(); } diff --git a/test/WebSites/Basic/Swagger/ExamplesSchemaFilter.cs b/test/WebSites/Basic/Swagger/ExamplesSchemaFilter.cs index 95bf8172ca..f205c0cc15 100644 --- a/test/WebSites/Basic/Swagger/ExamplesSchemaFilter.cs +++ b/test/WebSites/Basic/Swagger/ExamplesSchemaFilter.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; @@ -9,12 +8,7 @@ public class ExamplesSchemaFilter : ISchemaFilter { public void Apply(OpenApiSchema schema, SchemaFilterContext context) { - schema.Example = GetExampleOrNullFor(context.Type); - } - - private static IOpenApiAny GetExampleOrNullFor(Type type) - { - return type.Name switch + schema.Example = context.Type.Name switch { "Product" => new OpenApiObject { diff --git a/test/WebSites/MvcWithNullable/MvcWithNullable.csproj b/test/WebSites/MvcWithNullable/MvcWithNullable.csproj index 21c72fe119..9c538518c3 100644 --- a/test/WebSites/MvcWithNullable/MvcWithNullable.csproj +++ b/test/WebSites/MvcWithNullable/MvcWithNullable.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/WebSites/OAuth2Integration/OAuth2Integration.csproj b/test/WebSites/OAuth2Integration/OAuth2Integration.csproj index 675259f21a..770189ea6b 100644 --- a/test/WebSites/OAuth2Integration/OAuth2Integration.csproj +++ b/test/WebSites/OAuth2Integration/OAuth2Integration.csproj @@ -9,21 +9,15 @@ - - - - - - - - + + - - + + diff --git a/test/WebSites/TestFirst.IntegrationTests/CreateUserTests.cs b/test/WebSites/TestFirst.IntegrationTests/CreateUserTests.cs index ca86043a76..7a0ba9b792 100644 --- a/test/WebSites/TestFirst.IntegrationTests/CreateUserTests.cs +++ b/test/WebSites/TestFirst.IntegrationTests/CreateUserTests.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.OpenApi.Models; using Newtonsoft.Json; +using Swashbuckle.AspNetCore; using Swashbuckle.AspNetCore.ApiTesting.Xunit; using Xunit; @@ -30,11 +31,11 @@ public CreateUserTests( { Schema = new OpenApiSchema { - Type = "object", + Type = JsonSchemaTypes.Object, Properties = new Dictionary { - [ "email" ] = new OpenApiSchema { Type = "string" }, - [ "password" ] = new OpenApiSchema { Type = "string" }, + [ "email" ] = new OpenApiSchema { Type = JsonSchemaTypes.String }, + [ "password" ] = new OpenApiSchema { Type = JsonSchemaTypes.String }, }, Required = new SortedSet { "email", "password" } } @@ -52,7 +53,7 @@ public CreateUserTests( [ "Location" ] = new OpenApiHeader { Required = true, - Schema = new OpenApiSchema { Type = "string" } + Schema = new OpenApiSchema { Type = JsonSchemaTypes.String } } } }, @@ -100,4 +101,4 @@ await TestAsync( ); } } -} \ No newline at end of file +} diff --git a/test/WebSites/TestFirst.IntegrationTests/TestFirst.IntegrationTests.csproj b/test/WebSites/TestFirst.IntegrationTests/TestFirst.IntegrationTests.csproj index 86d88d1482..d1b511f3d8 100644 --- a/test/WebSites/TestFirst.IntegrationTests/TestFirst.IntegrationTests.csproj +++ b/test/WebSites/TestFirst.IntegrationTests/TestFirst.IntegrationTests.csproj @@ -4,6 +4,10 @@ net9.0;net8.0 + + + + diff --git a/test/WebSites/WebApi/WebApi.csproj b/test/WebSites/WebApi/WebApi.csproj index 7b7e13bf21..458b06d8f6 100644 --- a/test/WebSites/WebApi/WebApi.csproj +++ b/test/WebSites/WebApi/WebApi.csproj @@ -18,8 +18,12 @@ + + + + - +