Package: oasapi
Python library for Web APIs leveraging OpenAPI/Swagger specification, enabling you to:validate an OAS 2.0 documentprune an OAS 2.0 document of its unused elementsfilter endpoints of an OAS 2.0 document to generate a subset of the API[todo] detect changes between two OAS 2.0 documents (what’s new, changed, deprecated, removed)[todo] merge multiple OAS 2.0 documents together[todo] rate/score quality of an OAS 2.0 document (documentation coverage, good practices,…)[todo] transform an OAS 2.0 document (add x-… items, rename paths, rewrite basePath, …)[todo] add/remove securityDefinitions on an OAS 2.0 documentFree software license: BSD 3-Clause LicenseQuickstartInstall oasapi from PyPI with:pip install oasapiYou can also install the in-development version with:pip install https://github.com/sdementen/oasapi/archive/master.zipOAS Document validationValidate an OAS 2.0 Document (in JSON or YAML format) with:python -m oasapi validate samples/swagger_petstore.jsonor if you prefer with the oasapi script:oasapi validate samples/swagger_petstore.jsonor with thesdementen/oasapiDocker image (available on Docker Hub):docker run sdementen/oasapi validate http://petstore.swagger.io/v2/swagger.jsonYou can also pipe a swagger to the command (if oasapi cannot retrieve the file by itself):type samples/swagger_petstore.json | oasapi validate -
type samples/swagger_petstore.json | docker run -i sdementen/oasapi validate -
curl http://petstore.swagger.io/v2/swagger.json | oasapi validate -
curl -s http://petstore.swagger.io/v2/swagger.json | docker run -i sdementen/oasapi validate -OAS Document filteringSimilarly, you can use the filter command to filter an OAS 2.0 document and keep only specific operations.
For instance, to keep only operations with the tag ‘pet’, the security scope at most ‘read:pets’ and the operations matching
the regepx “(GET|PUT) .*petid.*” (all paths containing ‘petid’ with verb GET or PUT), run:oasapi filter http://petstore.swagger.io/v2/swagger.json -o new_swagger.json --tag pet --security-scope read:pets --path "(GET|PUT) .*petid.*"(you will see that the new_swagger.json has only one operation leftGET/pet/{petId}).OAS Document pruningAnother useful command is pruning, which takes an OAS 2.0 document and prune it of its unused elements as:oasapi prune http://petstore.swagger.io/v2/swagger.json -o new_swagger.jsonDocumentationhttps://oasapi.readthedocs.io/Developmenthttps://oasapi.readthedocs.io/en/latest/contributing.html#developmentChangelog0.1.17   (2020-03-03)fix integer response code raising exception (closes #14)0.1.16   (2020-02-08)add documentation of filter in prune + cleanup doc0.1.15   (2020-02-08)add filtering of swaggersupport outputting swagger in yaml formatsupport silencing the CLI[dev] refactor CLI0.1.13 (2020-01-25)add validation of parameters required/defaultadd validation of parameters default value wrt type/format0.1.12 (2020-01-17)add pruning of unused items (definitions, responses, parameters, securityDefinitions/scopes, tags)rename validate_swagger function to validate, add prune function0.1.11 (2020-01-16)[dev] use jsonpath_ng to walk the swaggeradd timing of validation in CLI if verbose0.1.10 (2020-01-10)[dev] fix tag name to remove “v” (for readthedocs latest build)[dev] fix travis ci python version for doc0.1.9 (2020-01-10)Improve validation of array parametersImprove documentation0.1.8 (2020-01-09)Push the sdementen/oasapi docker image to Docker Hub on each releaseUpdate doc on Docker image use and pipeing a swagger to oasapi0.1.7 (2020-01-09)Support URL and stdin (with -) as SWAGGER for the CLI0.1.6 (2020-01-08)[dev] PyPI deployment through Travis CI0.1.5 (2020-01-08)Fix script form of the cli (oasapiinstead ofpython-moasapi)0.1.4 (2020-01-08)Explicit support only for python >= 3.6 (no py35 as use of f-string)[dev] Move local build of docs from dist/docs to docs/dist to avoid cluttering dist0.1.3 (2020-01-08)[dev] Add git pre-commit hooks for black and flake[dev] Do not use isort[dev] Fix black + flake8 issues0.1.2 (2020-01-08)Fix model & reporting of duplicate operationIdsAdd documentation on the CLI Usage0.1.1 (2020-01-08)Add pyyaml dependencies (to support OAS in yaml format)0.1.0 (2020-01-08)First release on PyPI.Implementation of the validation of an OAS 2.0 (aka swagger) file