How to generate XSD file from OpenAPI 3.0 specification?
Asked Answered
S

0

7

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:

  1. 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.

  2. 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.

Septivalent answered 2/9, 2019 at 14:48 Comment(5)
If you've time, we can create a generator to convert the openapi model definitions into XSD file. Please let us know if you've time for the contribution by opening an issue via github.com/OpenAPITools/openapi-generator/issues/newNiles
Could you manage to find an answer for your needs?Mide
@MuratÇorlu unfortunately I haven't managed to find any solution for that yet. If I had one in the future, I will update this thread.Septivalent
Atlassian's Swagger Request Validator is a right tool for your needs, but for now it does not support validation xml payload. There is an issue requesting xml support.Humbug
Vote for it here: bitbucket.org/atlassian/swagger-request-validator/issues/147/…Humbug

© 2022 - 2024 — McMap. All rights reserved.