dracor-org/dracor-api

XML examples are not rendered in OpenAPI Spec

Opened this issue · 1 comments

I loaded the OpenAPI Spec into the Swagger Editor https://editor.swagger.io (while documenting #172) . The XML examples of the responses are not rendered, Swagger Editor displays an error

<?xml version="1.0" encoding="UTF-8"?>
<!-- XML example cannot be generated; root element name is undefined -->

This also affects Swagger UI, e.g. https://dracor.org/doc/api#/public/play-tei

Bildschirmfoto 2024-04-17 um 11 03 41
cmil commented

I think the problem is that we don't define a schema for the response.

For the example endpoint and response (/corpora/{corpusname}/plays/{playname}/tei) we don't actually provide a literal XML. But for /corpora/{corpusname}/plays/{playname}/relations/gexf we actually do and if I'm not completely mistaken this used to render just fine in the past. (Maybe it broke when upgrading Swagger UI in dracor-org/dracor-frontend@7af2edc)

Anyway, the OpenAPI documentation on how to specify XML responses at https://swagger.io/docs/specification/data-models/representing-xml/ seems to require a JSON schema. Which would seem to be quite challenge to come up with for TEI and other complex XML vocabularies. Is there a way to reference other existing schemas?