Live data from Hacker News

An OpenAPI proxy that only allows data that matches your swagger.json

github.com

1–10 of 15 posts

Re: An OpenAPI proxy that only allows data that matches your swagger.json

#2
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.

Re: An OpenAPI proxy that only allows data that matches your swagger.json

#3

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.

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.

Re: An OpenAPI proxy that only allows data that matches your swagger.json

#4

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.

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.

Re: An OpenAPI proxy that only allows data that matches your swagger.json

#8

https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-va...

How do you see this as relevant to a REST API?

Many people would need additional tooling to parse JSON into a structured type, especially in dynamic languages where unstructured data types are the norm. And even if you do that, you're still going to have to validate the data and tell the client where they might have messed up the formatting.

Parsing is a totally fine, low-cost, low-risk way to validate chunks of JSON before trying to parse them -- or not trying to parse them, if that's your choice. People who use TypeScript on the server side, for example, will only need to validate.

Re: An OpenAPI proxy that only allows data that matches your swagger.json

#9

Isn't REST just a glorified SOAP at this point? Predefined schema, generate classes from schema, interact with it via HTTP.

Yes. Schemas are useful. What alternative do you propose? The only other option I can imagine is sending the schema along with the object, in which case you should just be using XML instead of JSON.

Re: An OpenAPI proxy that only allows data that matches your swagger.json

#10

Isn't REST just a glorified SOAP at this point? Predefined schema, generate classes from schema, interact with it via HTTP.

I guess the selling point for REST still stands -- if you don't need any of that stuff, you can set up a much simpler API for rapid prototyping.
Post reply on HN