Skip to content

WithMappingFromOpenApiFile - Support for OpenAPI 3.1.0 #1275

@tj-spyro

Description

@tj-spyro

Is your feature request related to a problem? Please describe.
Support for using WireMock.Net.OpenApiParser with an OpenAPI 3.1.0 yaml file. Currently, if you attempt to load an OAS file for v3.1.0 you get the following error:

Unhandled exception. Microsoft.OpenApi.Readers.Exceptions.OpenApiUnsupportedSpecVersionException: OpenAPI specification version '3.1.0' is not supported.
   at Microsoft.OpenApi.Readers.ParsingContext.Parse(YamlDocument yamlDocument)
   at Microsoft.OpenApi.Readers.OpenApiYamlDocumentReader.Read(YamlDocument input, OpenApiDiagnostic& diagnostic)
   at Microsoft.OpenApi.Readers.OpenApiTextReaderReader.Read(TextReader input, OpenApiDiagnostic& diagnostic)
   at Microsoft.OpenApi.Readers.OpenApiStreamReader.Read(Stream input, OpenApiDiagnostic& diagnostic)
   at WireMock.Net.OpenApiParser.WireMockOpenApiParser.FromFile(String path, WireMockOpenApiParserSettings settings, OpenApiDiagnostic& diagnostic)
   at WireMock.Net.OpenApiParser.Extensions.WireMockServerExtensions.WithMappingFromOpenApiFile(IWireMockServer server, String path, WireMockOpenApiParserSettings settings, OpenApiDiagnostic& diagnostic)
   at WireMock.Net.OpenApiParser.Extensions.WireMockServerExtensions.WithMappingFromOpenApiFile(IWireMockServer server, String path, OpenApiDiagnostic& diagnostic)

Describe the solution you'd like
Support for version 3.1.0 of OpenAPI has been introduced into version 2.x of the Microsoft.OpenApi.* nuget packages, still in preview. The Microsoft.OpenApi.Readers project has been renamed to Microsoft.OpenApi.YamlReader, see microsoft/OpenAPI.NET#2166.

Upgrading the package may have breaking changes, I've yet to check. It's also still in preview, would WireMock publish a package that contained a preview dependency or wait for a stable version?

Describe alternatives you've considered
Other solutions would be more time-consuming than being able to take a provider's 3.1.0 OpenAPI Spec and passing it into WireMock.

Is your feature request supported by WireMock (java version)? Please provide details.
n/a

Additional context
n/a

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions