3 ms·
To tell the truth, there is json-schema[1], and a number of implementations of it which work pretty well. You can use it to validate your JSON inputs, much lik
by nine_k 6y ago
To tell the truth, there is json-schema[1], and a number of implementations of it which work pretty well.
You can use it to validate your JSON inputs, much like you would with XSD (I've used both).
There is OpenAPI, née Swagger [2], which allows you to describe your API in human- and machine-readable form and generate code for it [3].
But validation is but one step. A robust API needs rate-limiting, injection protection (does your language has tainted strings?), easy enough authz/authn story, etc, etc, all different and non-trivial things.
[1]: http://json-schema.org/ http://json-schema.org/
[2]: https://en.wikipedia.org/wiki/OpenAPI_Specification https://en.wikipedia.org/wiki/OpenAPI_Specification
[3]: https://openapi-generator.tech/ https://openapi-generator.tech/
- Sherl 6y agoThe openAPI uses Python flask but to be frank, it makes sense to use the schema to generate client rather then server. FastAPI and Pydantic can generate openAPI schema from datamodel which does the type parsing for you, if parsing is the use case. Writing server code with a library that can generate schema is a pro for me rather then keeping up with updates from schema to code.