Initial Release
This validator is based on the openapi-schema-validator Python project and can check inbound JSONs for compliance with the OpenAPI (Swagger) specification. It is fully compatible with the recommended InterSystems specification-first way in REST API development.
If you want to integrate request validation in your project, by default, this means that you already have some API developed according to the specification-first way, described here. First, you need to set a vendor-specific content type in the consumes property of the OpenAPI specification for your endpoint. Which one must look something like this: vnd.<company>.<project>.<api>.<request_type>+json. In the included sample, I use:
"paths":{
"post":{
"consumes":[
"application/vnd.validator.sample_api.test_post_req+json"
],
...
Next steps:
SwaggerValidator packagedisp.cls Extends section from %CSP.REST to SwaggerValidator.Core.RESTopenapi-schema-validator Python library as described hereThe project includes a sample API, look at SwaggerValidator.Sample.API.* package. To run the sample, you need:
/csp/api, set the dispatch class as SwaggerValidator.Sample.API.disp and grand it a %All role (don’t repeat on productive)curl --location 'http://localhost:52773/csp/api/test' \
--header 'Content-Type: application/vnd.validator.sample_api.test_post_req+json' \
--data '{
"input": "10"
}'
That’s all folks! Thanks for your attention.