discord / discord-api-spec

OpenAPI specification for Discord APIs
MIT License
255 stars 16 forks source link

Add identifier for oneOf [...] operation responses #17

Open Chaosdave34 opened 1 year ago

Chaosdave34 commented 1 year ago

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.

danny-may commented 1 year ago

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

A5rocks commented 1 year ago

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

mbialecka commented 1 year ago

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.