Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,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.0.0</MicrosoftOpenApiVersion>
<MicrosoftOpenApiYamlReaderVersion>3.0.0</MicrosoftOpenApiYamlReaderVersion>
<!-- dotnet tool versions (see also auto-updated DotnetEfVersion property). -->
<DotnetDumpVersion>6.0.322601</DotnetDumpVersion>
<DotnetServeVersion>1.10.93</DotnetServeVersion>
Expand Down
10 changes: 8 additions & 2 deletions src/OpenApi/gen/XmlCommentGenerator.Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
}
foreach (var mediaType in content)
{
mediaType.Example = jsonString.Parse();
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = jsonString.Parse();
}
}
}
}
Expand Down Expand Up @@ -476,7 +479,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
{
mediaType.Example = parsedExample;
if (mediaType is OpenApiMediaType concrete)
{
concrete.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 @@ -412,7 +412,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 @@ -570,7 +570,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 @@ -744,7 +744,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 @@ -397,7 +397,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
}
foreach (var mediaType in content)
{
mediaType.Example = jsonString.Parse();
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = jsonString.Parse();
}
}
}
}
Expand Down Expand Up @@ -458,7 +461,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
{
mediaType.Example = parsedExample;
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = parsedExample;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
}
foreach (var mediaType in content)
{
mediaType.Example = jsonString.Parse();
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = jsonString.Parse();
}
}
}
}
Expand Down Expand Up @@ -487,7 +490,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
{
mediaType.Example = parsedExample;
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = parsedExample;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
}
foreach (var mediaType in content)
{
mediaType.Example = jsonString.Parse();
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = jsonString.Parse();
}
}
}
}
Expand Down Expand Up @@ -585,7 +588,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
{
mediaType.Example = parsedExample;
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = parsedExample;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
}
foreach (var mediaType in content)
{
mediaType.Example = jsonString.Parse();
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = jsonString.Parse();
}
}
}
}
Expand Down Expand Up @@ -462,7 +465,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
{
mediaType.Example = parsedExample;
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = parsedExample;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
}
foreach (var mediaType in content)
{
mediaType.Example = jsonString.Parse();
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = jsonString.Parse();
}
}
}
}
Expand Down Expand Up @@ -506,7 +509,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
{
mediaType.Example = parsedExample;
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = parsedExample;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
}
foreach (var mediaType in content)
{
mediaType.Example = jsonString.Parse();
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = jsonString.Parse();
}
}
}
}
Expand Down Expand Up @@ -488,7 +491,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
{
mediaType.Example = parsedExample;
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = parsedExample;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
}
foreach (var mediaType in content)
{
mediaType.Example = jsonString.Parse();
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = jsonString.Parse();
}
}
}
}
Expand Down Expand Up @@ -467,7 +470,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
{
mediaType.Example = parsedExample;
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = parsedExample;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
}
foreach (var mediaType in content)
{
mediaType.Example = jsonString.Parse();
if (mediaType is OpenApiMediaType concrete)
{
concrete.Example = jsonString.Parse();
}
}
}
}
Expand Down Expand Up @@ -459,7 +462,10 @@ public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransform
var parsedExample = jsonString.Parse();
foreach (var mediaType in content)
{
mediaType.Example = parsedExample;
if (mediaType is OpenApiMediaType concrete)
{
concrete.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
@@ -1,5 +1,5 @@
{
"openapi": "3.1.1",
"openapi": "3.1.2",
"info": {
"title": "Sample | controllers",
"version": "1.0.0"
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 | forms",
"version": "1.0.0"
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 | responses",
"version": "1.0.0"
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 | schemas-by-ref",
"version": "1.0.0"
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 | v1",
"version": "1.0.0"
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 | v2",
"contact": {
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 | xml",
"version": "1.0.0"
Expand Down
Loading
Loading