discord/discord-api-spec

Add identifier for oneOf [...] operation responses

Chaosdave34 opened this issue · 3 comments

Add a way to identify the Schema of operation responses. For example the get_channel operation, when successfull, can return 1 of 4 different schemas.
If you take a look at the schemas you see, that they can be identified by the type property, but there is no convinient way (at least I dont see any) to get this parameter from the response field of an operation.
Maybe add a identifiedBy field to the response content.

There is already a standard way to do this in OpenAPI 3 using the descriminator property of a schema
https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/
Would definitely be nice to have any fields which act as descriminators be documented

That's not in OpenAPI 3.1 though? And can't the descriminator just be calculated by the thing going from specification -> deserialization code?

OpenAPI 3.1 allows for discriminator: https://spec.openapis.org/oas/latest.html#discriminator-object
We considered this approach and may implement discriminators in the future. It's somewhat problematic given most of the fields we'd discriminate against are int enums, and the mapping keys are strings.