by janfoeh · 3y ago · 0 comments
What I have seen is endpoints trying to corral their responses into one-size-fits-all schemas in the situation you're describing, with predictable outcomes. Lots of overhead in most situations, tricky documentation, lots of optionals.
Under that premise, I have to say that at least for generic APIs with many differing clients, the idiosyncrasies of typed-language clients would not rank too highly on my list of design considerations — not when they are in the way of simpler, easier to understand responses.
> I have to say that at least for generic APIs with many differing clients, the idiosyncrasies of typed-language clients would not rank too highly on my list of design considerations
Hey, would you like to consume an exchange format that has meaningful distinction between strings and atoms? Those come from the dynamically-typed languages area!
GET /api/object/<id>?withAdditionalMetadata=1&expandChildren=1&.....
So then the OpenAPI schema has to be something like: schema:
oneOf:
- $ref: '#/components/schemas/Object'
- $ref: '#/components/schemas/ObjectWithMetadata'
- $ref: '#/components/schemas/ObjectWithChildren'
- $ref: '#/components/schemas/ObjectWithChildrenAndMetadata
So inevitably the client ends up being quite complex to handle this.