Skip to content
Merged
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@
<XunitExtensibilityExecutionVersion>$(XunitVersion)</XunitExtensibilityExecutionVersion>
<XUnitRunnerVisualStudioVersion>3.1.3</XUnitRunnerVisualStudioVersion>
<MicrosoftDataSqlClientVersion>5.2.2</MicrosoftDataSqlClientVersion>
<MicrosoftOpenApiVersion>2.0.0</MicrosoftOpenApiVersion>
<MicrosoftOpenApiYamlReaderVersion>2.0.0</MicrosoftOpenApiYamlReaderVersion>
<MicrosoftOpenApiVersion>3.3.1</MicrosoftOpenApiVersion>
<MicrosoftOpenApiYamlReaderVersion>3.3.1</MicrosoftOpenApiYamlReaderVersion>
<!-- dotnet tool versions (see also auto-updated DotnetEfVersion property). -->
<DotnetDumpVersion>6.0.322601</DotnetDumpVersion>
<DotnetServeVersion>1.10.93</DotnetServeVersion>
Expand Down
4 changes: 2 additions & 2 deletions src/OpenApi/gen/XmlCommentGenerator.Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
{
continue;
}
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = jsonString.Parse();
}
Expand Down Expand Up @@ -475,7 +475,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
continue;
}
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = parsedExample;
}
Expand Down
6 changes: 3 additions & 3 deletions src/OpenApi/src/Services/OpenApiDocumentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ private async Task<OpenApiResponse> GetResponseAsync(
var response = new OpenApiResponse
{
Description = apiResponseType.Description ?? ReasonPhrases.GetReasonPhrase(statusCode),
Content = new Dictionary<string, OpenApiMediaType>()
Content = new Dictionary<string, IOpenApiMediaType>()
};

// ApiResponseFormats aggregates information about the supported response content types
Expand Down Expand Up @@ -576,7 +576,7 @@ private async Task<OpenApiRequestBody> GetFormRequestBody(
// serializing a form collection from an empty body. Instead, requiredness
// must be set on a per-parameter basis. See below.
Required = true,
Content = new Dictionary<string, OpenApiMediaType>()
Content = new Dictionary<string, IOpenApiMediaType>()
};

var schema = new OpenApiSchema { Type = JsonSchemaType.Object, Properties = new Dictionary<string, IOpenApiSchema>() };
Expand Down Expand Up @@ -750,7 +750,7 @@ private async Task<OpenApiRequestBody> GetJsonRequestBody(
var requestBody = new OpenApiRequestBody
{
Required = IsRequired(bodyParameter),
Content = new Dictionary<string, OpenApiMediaType>(),
Content = new Dictionary<string, IOpenApiMediaType>(),
Description = GetParameterDescriptionFromAttribute(bodyParameter)
};

Expand Down
4 changes: 2 additions & 2 deletions src/OpenApi/src/Services/OpenApiGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private static OpenApiResponses GetOpenApiResponses(MethodInfo method, EndpointM

// TODO: Use the discarded response Type for schema generation
var (_, contentTypes) = annotation.Value;
var responseContent = new Dictionary<string, OpenApiMediaType>();
var responseContent = new Dictionary<string, IOpenApiMediaType>();

foreach (var contentType in contentTypes)
{
Expand Down Expand Up @@ -269,7 +269,7 @@ private static void GenerateDefaultResponses(Dictionary<int, (Type?, MediaTypeCo
}

var acceptsMetadata = metadata.GetMetadata<IAcceptsMetadata>();
var requestBodyContent = new Dictionary<string, OpenApiMediaType>();
var requestBodyContent = new Dictionary<string, IOpenApiMediaType>();

if (acceptsMetadata is not null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
{
continue;
}
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = jsonString.Parse();
}
Expand Down Expand Up @@ -457,7 +457,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
continue;
}
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = parsedExample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
{
continue;
}
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = jsonString.Parse();
}
Expand Down Expand Up @@ -486,7 +486,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
continue;
}
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = parsedExample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
{
continue;
}
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = jsonString.Parse();
}
Expand Down Expand Up @@ -584,7 +584,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
continue;
}
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = parsedExample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
{
continue;
}
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = jsonString.Parse();
}
Expand Down Expand Up @@ -458,7 +458,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
continue;
}
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = parsedExample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
{
continue;
}
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = jsonString.Parse();
}
Expand Down Expand Up @@ -461,7 +461,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
continue;
}
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = parsedExample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
{
continue;
}
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = jsonString.Parse();
}
Expand Down Expand Up @@ -505,7 +505,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
continue;
}
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = parsedExample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
{
continue;
}
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = jsonString.Parse();
}
Expand Down Expand Up @@ -487,7 +487,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
continue;
}
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = parsedExample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
{
continue;
}
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = jsonString.Parse();
}
Expand Down Expand Up @@ -466,7 +466,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
continue;
}
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = parsedExample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
{
continue;
}
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = jsonString.Parse();
}
Expand Down Expand Up @@ -458,7 +458,7 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
continue;
}
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
foreach (var mediaType in content.OfType<OpenApiMediaType>())
{
mediaType.Example = parsedExample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public async Task MapOpenApi_ReturnsDefaultDocumentIfNoNameProvided(string expec
Assert.Equal(expectedContentType, context.Response.ContentType);
var responseString = Encoding.UTF8.GetString(responseBodyStream.ToArray());
// String check to validate that generated document starts with YAML syntax
Assert.Equal(isYaml, responseString.StartsWith("openapi: '3.1.1'", StringComparison.OrdinalIgnoreCase));
Assert.Equal(isYaml, responseString.StartsWith("openapi: '3.1.2'", StringComparison.OrdinalIgnoreCase));
responseBodyStream.Position = 0;
await ValidateOpenApiDocumentAsync(responseBodyStream, document =>
{
Expand Down Expand Up @@ -221,7 +221,7 @@ public async Task MapOpenApi_ReturnsDocumentIfNameProvidedInQuery(string expecte
Assert.Equal(expectedContentType, context.Response.ContentType);
var responseString = Encoding.UTF8.GetString(responseBodyStream.ToArray());
// String check to validate that generated document starts with YAML syntax
Assert.Equal(isYaml, responseString.StartsWith("openapi: '3.1.1'", StringComparison.OrdinalIgnoreCase));
Assert.Equal(isYaml, responseString.StartsWith("openapi: '3.1.2'", StringComparison.OrdinalIgnoreCase));
responseBodyStream.Position = 0;
await ValidateOpenApiDocumentAsync(responseBodyStream, document =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static TheoryData<string, OpenApiSpecVersion> OpenApiDocuments()
[
OpenApiSpecVersion.OpenApi3_0,
OpenApiSpecVersion.OpenApi3_1,
OpenApiSpecVersion.OpenApi3_2,
];

var testCases = new TheoryData<string, OpenApiSpecVersion>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,14 +667,13 @@
"content": {
"application/json": {
"schema": {
"type": "object",
"oneOf": [
{
"nullable": true
},
{
"$ref": "#/components/schemas/NullableResponseModel"
}
]
],
"nullable": true
}
}
}
Expand All @@ -691,14 +690,13 @@
"content": {
"application/json": {
"schema": {
"type": "object",
"oneOf": [
{
"nullable": true
},
{
"$ref": "#/components/schemas/NullableRequestModel"
}
]
],
"nullable": true
}
}
}
Expand Down Expand Up @@ -873,14 +871,13 @@
"type": "string"
},
"optionalNested": {
"type": "object",
"oneOf": [
{
"nullable": true
},
{
"$ref": "#/components/schemas/NestedModel"
}
]
],
"nullable": true
},
"requiredNested": {
"$ref": "#/components/schemas/NestedModel"
Expand Down Expand Up @@ -998,14 +995,13 @@
"$ref": "#/components/schemas/TestEnum"
},
"nullableEnum": {
"type": "integer",
"oneOf": [
{
"nullable": true
},
{
"$ref": "#/components/schemas/TestEnum"
}
]
],
"nullable": true
},
"listOfNullableEnums": {
"type": "array",
Expand Down Expand Up @@ -1160,14 +1156,13 @@
"nullable": true
},
"deepNested": {
"type": "object",
"oneOf": [
{
"nullable": true
},
{
"$ref": "#/components/schemas/ComplexType"
}
]
],
"nullable": true
}
}
},
Expand Down Expand Up @@ -1239,14 +1234,13 @@
"nullable": true
},
"nullableComplexProperty": {
"type": "object",
"oneOf": [
{
"nullable": true
},
{
"$ref": "#/components/schemas/ComplexType"
}
]
],
"nullable": true
}
}
},
Expand Down Expand Up @@ -1475,14 +1469,13 @@
"$ref": "#/components/schemas/RefProfile"
},
"secondaryUser": {
"type": "object",
"oneOf": [
{
"nullable": true
},
{
"$ref": "#/components/schemas/RefProfile"
}
]
],
"nullable": true
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.1.1",
"openapi": "3.1.2",
"info": {
"title": "Sample | controllers",
"version": "1.0.0"
Expand Down
Loading
Loading