Authress-Engineering / openapi-explorer

OpenAPI Web component to generate a UI from the spec.
Apache License 2.0
316 stars 42 forks source link

Support prefixItems in array schemas #208

Open splitbrain opened 12 months ago

splitbrain commented 12 months ago

I am modelling an existing API which uses positional arguments in the request body. According to this stackoverflow answer the correct way to do that is to use prefixItems.

Unfortunately, this seems not to be picked up by openapi-explorer. The model tab just shows [].

Any chance this could be supported properly? Or maybe there's a workaround?

wparad commented 12 months ago

Do you have a link to the oas schema where this is documented.

Of course if it is spec compliant we would accept a PR to implement thine missing functionality. Thanks for finding this missing piece.

splitbrain commented 12 months ago

From what I understand, this comes from JSON-Schema. But digging further into this, it seems it is not fully supported after all. The swagger editor however does display at least some info:

screenshot-editor-next swagger io-2023 11 30-11_07_47

splitbrain commented 12 months ago

https://json-schema.org/understanding-json-schema/reference/array#tupleValidation has some more info on the used syntax.

wparad commented 12 months ago

So it's clearly something in the json schema draft 2020-12 schema that could be added. Given that we'll keep this ticket open. I will share two concerns about using this however:

While I can recommend all day long that this should never be done, that doesn't stop it from having been added to the spec. So if someone spends the time to implement this feature, as per Draft 2020-12, we will accept it, but will caution that this functionality should never exist in an API due to its lack of polymorphism across languages.

Note on the first point and the example, the example uses address, but not every address works that way, so realistically, the example is a really bad one and sets a bad precedent. If you are trying to create an api with properties for an address, see: