Skip to content
Merged
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 src/OpenApi/src/Services/OpenApiOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public OpenApiOptions()
}

/// <summary>
/// The version of the OpenAPI specification to use. Defaults to <see cref="OpenApiSpecVersion.OpenApi3_1"/>.
/// The version of the OpenAPI specification to use. Defaults to <see cref="OpenApiSpecVersion.OpenApi3_2"/>.
/// </summary>
public OpenApiSpecVersion OpenApiVersion { get; set; } = OpenApiSpecVersion.OpenApi3_1;
public OpenApiSpecVersion OpenApiVersion { get; set; } = OpenApiSpecVersion.OpenApi3_2;
Comment on lines 35 to +38

/// <summary>
/// The name of the OpenAPI document this <see cref="OpenApiOptions"/> instance is associated with.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.1.2",
"openapi": "3.2.0",
"info": {
"title": "Sample | localized",
"description": "This is a localized OpenAPI document for français (France).",
Expand Down Expand Up @@ -1822,29 +1822,27 @@
}
},
"/query": {
"x-oai-additionalOperations": {
"QUERY": {
"tags": [
"Test"
],
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/CurrentWeather"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/CurrentWeather"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/CurrentWeather"
}
"query": {
"tags": [
"Test"
],
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/CurrentWeather"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/CurrentWeather"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/CurrentWeather"
}
}
}
Expand All @@ -1853,7 +1851,7 @@
}
},
"/unsupported": {
"x-oai-additionalOperations": {
"additionalOperations": {
"FOO": {
"tags": [
"Test"
Expand Down Expand Up @@ -1884,51 +1882,49 @@
}
},
"/query-with-body": {
"x-oai-additionalOperations": {
"QUERY": {
"tags": [
"Test"
],
"requestBody": {
"query": {
"tags": [
"Test"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MvcTodo"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/MvcTodo"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/MvcTodo"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/MvcTodo"
}
},
"text/json": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MvcTodo"
}
},
"application/*+json": {
"text/json": {
"schema": {
"$ref": "#/components/schemas/MvcTodo"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/MvcTodo"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/MvcTodo"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/MvcTodo"
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ private string GetDocument(
{
_reporter.WriteWarning(Resources.FormatInvalidOpenApiVersion(_context.OpenApiVersion));
}
arguments = [documentName, writer, OpenApiSpecVersion.OpenApi3_1];
arguments = [documentName, writer, OpenApiSpecVersion.OpenApi3_2];
}
}
using var resultTask = (Task)InvokeMethod(targetMethod, service, arguments);
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/GetDocumentInsider/src/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
<value>The name of the OpenAPI document to generate. Optional.</value>
</data>
<data name="InvalidOpenApiVersion" xml:space="preserve">
<value>Invalid OpenAPI spec version '{0}' provided. Falling back to default: v3.1.</value>
<value>Invalid OpenAPI spec version '{0}' provided. Falling back to default: v3.2.</value>
</data>
<data name="DocumentNotFound" xml:space="preserve">
<value>Document with name '{0}' not found.</value>
Expand Down
8 changes: 4 additions & 4 deletions src/Tools/GetDocumentInsider/tests/GetDocumentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void GetDocument_Works()
var result = OpenApiDocument.Load(stream, "json");
// TODO: Needs https://github.com/microsoft/OpenAPI.NET/issues/2055 to be fixed
// Assert.Empty(result.Diagnostic.Errors);
Assert.Equal(OpenApiSpecVersion.OpenApi3_1, result.Diagnostic.SpecificationVersion);
Assert.Equal(OpenApiSpecVersion.OpenApi3_2, result.Diagnostic.SpecificationVersion);
Assert.Equal("GetDocumentSample | v1", result.Document.Info.Title);
}

Expand Down Expand Up @@ -89,11 +89,11 @@ public void GetDocument_WithInvalidOpenApiVersion_Errors()
], new GetDocumentCommand(_console), throwOnUnexpectedArg: false);

// Assert that error was produced and files were generated with v3.
Assert.Contains("Invalid OpenAPI spec version 'OpenApi4_0' provided. Falling back to default: v3.1.", _console.GetOutput());
Assert.Contains("Invalid OpenAPI spec version 'OpenApi4_0' provided. Falling back to default: v3.2.", _console.GetOutput());
using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(outputPath.FullName, "Sample.json")));
var result = OpenApiDocument.Load(stream, "json");
Assert.Empty(result.Diagnostic.Errors);
Assert.Equal(OpenApiSpecVersion.OpenApi3_1, result.Diagnostic.SpecificationVersion);
Assert.Equal(OpenApiSpecVersion.OpenApi3_2, result.Diagnostic.SpecificationVersion);
Assert.Equal("GetDocumentSample | v1", result.Document.Info.Title);
}

Expand Down Expand Up @@ -126,7 +126,7 @@ public void GetDocument_WithDocumentName_Works()
using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(outputPath.FullName, "Sample_internal.json")));
var result = OpenApiDocument.Load(stream, "json");
Assert.Empty(result.Diagnostic.Errors);
Assert.Equal(OpenApiSpecVersion.OpenApi3_1, result.Diagnostic.SpecificationVersion);
Assert.Equal(OpenApiSpecVersion.OpenApi3_2, result.Diagnostic.SpecificationVersion);
// Document name in the title gives us a clue that the correct document was actually resolved
Assert.Equal("GetDocumentSample | internal", result.Document.Info.Title);
}
Expand Down
Loading