WithMappingFromOpenApiFile - Support for OpenAPI 3.1.0 #684

Closed
opened 2025-12-29 15:30:47 +01:00 by adam · 4 comments
Owner

Originally created by @tj-spyro on GitHub (Apr 14, 2025).

Originally assigned to: @StefH on GitHub.

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 https://github.com/microsoft/OpenAPI.NET/pull/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

Originally created by @tj-spyro on GitHub (Apr 14, 2025). Originally assigned to: @StefH on GitHub. **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 https://github.com/microsoft/OpenAPI.NET/pull/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)](https://www.wiremock.org)? Please provide details.** n/a **Additional context** n/a
adam added the feature label 2025-12-29 15:30:47 +01:00
adam closed this issue 2025-12-29 15:30:47 +01:00
Author
Owner

@StefH commented on GitHub (Apr 14, 2025):

@tj-spyro
I just started upgrading to the new Microsoft.OpenApi in another project, and there are indeed some breaking changes.

I'll take a look for WireMock...

@StefH commented on GitHub (Apr 14, 2025): @tj-spyro I just started upgrading to the new Microsoft.OpenApi in another project, and there are indeed some breaking changes. I'll take a look for WireMock...
Author
Owner

@StefH commented on GitHub (Apr 15, 2025):

https://github.com/StefH/RamlToOpenApiConverter/pull/22

@StefH commented on GitHub (Apr 15, 2025): https://github.com/StefH/RamlToOpenApiConverter/pull/22
Author
Owner

@StefH commented on GitHub (Apr 17, 2025):

https://github.com/WireMock-Net/WireMock.Net/pull/1279

@StefH commented on GitHub (Apr 17, 2025): https://github.com/WireMock-Net/WireMock.Net/pull/1279
Author
Owner

@StefH commented on GitHub (May 2, 2025):

https://github.com/WireMock-Net/WireMock.Net/pull/1290

@StefH commented on GitHub (May 2, 2025): https://github.com/WireMock-Net/WireMock.Net/pull/1290
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#684