I create XML API specification using OpenAPI 3.0 with additional xml metadata, as described in Swagger docs. During development phase I would like to automatically test my endpoint's XML response against OpenAPI 3.0 specification.
What is the best way to validate endpoint's XML response against OpenAPI 3.0 schema? By validation I mean:
- verification that each XML tag or tag's attribute is compliant with specs,
- all the elements required by specification are present,
- data is successfully validated against types declared in response content schema.
I imagine that such a test could be done with following steps:
During project build, generate XSD file from schema definition for each path in OpenAPI specification, if that path has specified
application/xml
content type and response schema is defined.In tests, fetch the response of specific endpoint and validate it against XSD file.
Unfortunately it seems there are currently no tools that could generate XSD from OpenAPI specs to create above pipeline.
How could you achieve this goal? Is it possible with some combination of OpenAPI/Swagger Tools? Are there any other reliable ways to validate XML response without creating XSD manually?
The problem is not programming language specific.