How to validate API-Document (swagger.json)'s compatibility with OpenAPI Spec? #4326
Unanswered
KuldeepSinh
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Many a times our API Specification docs (swagger.json) are malformed and that being the reason our generated C# Client code does not compile.
To catch such issues before the code generation, we need to validate our API Specification (swagger.json)'s correctness and compatibility with the OpenAPI 3.1 specification.
I am not aware if NSwag's C# Client Generator has a way to validate swagger.json out of the box. I tried achieving same using NJsonSchema library.
I am getting following error, when it tries to read openApiSpecification (at line :
var schema = await JsonSchema.FromJsonAsync(schemaData);
)My code looks like this.
Is there any example/code I can refer to? I admit that JSonSchema
!=
OpenApiSchema and I was not able to figure out appropriate solution.Thank you.
Beta Was this translation helpful? Give feedback.
All reactions