Skip to content

No simple way to convert formats while keeping OpenAPI spec version the same #172

@scott-lin

Description

@scott-lin

I'd like to simply convert between OpenApiFormat while keeping OpenApiSpecVersion the same across the conversion, however, there is no way of doing this that avoids me having to parse the OpenApiSpecVersion from the string payload myself.

For example, below is some basic code to demonstrate the scenario and issue. In this example, we'd be converting YAML string -> OpenApirDocument model -> JSON string.

string documentYaml = "some YAML OpenApi document payload";

var openApiStringReader = new OpenApiStringReader();
OpenApiDocument openApiDocument = openApiStringReader.Read( documentYaml, out 
OpenApiDiagnostic openApiDiagnostic );

string documentJson = openApiDocument.SerializeAsJson(???);

What is the recommended way of getting to know the OpenApiSpecVersion to pass to SerializeAsJson (respresented by ??? above) in order to keep the version consistent.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions