You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No simple way to convert formats while keeping OpenAPI spec version the same #172
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.
We would need to add a property to the OpenApiDiagnostic object to store the "detected input version". This could then be used to select the output format. I'm not sure how to make that completely transparent though.
I like the idea. I don't like the name of OpenApiDiagnostic since not all of the data is "diagnostic" data. OpenApiMetadata might be better since it's data that helps describe the OpenApiDocument generated.
Also, what do you mean by, "I'm not sure how to make that completely transparent though"?
Scott Lin (@scott-lin) I mean that you would need to take the value from the "diagnostic" object and the pass it into the Serialize method manually.
I'm not a big fan of the name diagnostic either but metadata is not much better. We need a word that means meta-results but is less ugly.
I will start coding the fix we all have agreed on (parse the version from the document as an OpenApiSpecVersion and assign it as a property on OpenApiDiagnostic).
Activity
darrelmiller commentedon Jan 10, 2018
We would need to add a property to the OpenApiDiagnostic object to store the "detected input version". This could then be used to select the output format. I'm not sure how to make that completely transparent though.
scott-lin commentedon Jan 10, 2018
I like the idea. I don't like the name of OpenApiDiagnostic since not all of the data is "diagnostic" data. OpenApiMetadata might be better since it's data that helps describe the OpenApiDocument generated.
Also, what do you mean by, "I'm not sure how to make that completely transparent though"?
darrelmiller commentedon Jan 10, 2018
Scott Lin (@scott-lin) I mean that you would need to take the value from the "diagnostic" object and the pass it into the Serialize method manually.
I'm not a big fan of the name diagnostic either but metadata is not much better. We need a word that means meta-results but is less ugly.
PerthCharern commentedon Jan 10, 2018
Maybe something like OpenApiReaderMetadata / OpenApiReadingMetadata since it's a metadata of the reading process?
scott-lin commentedon Jan 10, 2018
I will start coding the fix we all have agreed on (parse the version from the document as an
OpenApiSpecVersionand assign it as a property onOpenApiDiagnostic).