Hacker News new | ask | show | jobs
by _asummers 2301 days ago
I've found OpenAPI is very poor for more dynamic resource-based APIs where the mechanics of interactions between the resources is standard but the resources themselves differ, e.g. a JSONAPI API. Does anyone know of tooling that more accurately fits that use case? I have hand rolled (well, generated) JSON Schemas in the past and published those, but that felt unsatisfying and too ad hoc.
3 comments

I don't know a tool for it, but I often find from experience that dynamic API's are usually not the right tool for the job. However if it is required and you have a declarative API, it will make the process much easier I would imagine.

EDIT: `declarative API` as in some kind of proxy layer which you can better isolate.

OpenAPI v3 can handle what you describe, although it's a pain to write it by hand and tooling in your language may be missing support for edge cases (i.e. incomplete spec implementation).

My suggestion would be to define your APIs in a neutral, flexible format (such as Spot[1]) and then generate OAS 3 or whatever other formats you need. That helps you avoid lock-in and any tedium required to handle less-capable formats.

1. https://github.com/airtasker/spot

If I'm understanding you correctly, this is what discriminators are supposed to solve, but I've never used them and don't know the state of the tooling for them.