|
| 1 | +# openapi-core |
| 2 | + |
| 3 | +<a href="https://pypi.python.org/pypi/openapi-core" target="_blank"> |
| 4 | + <img src="https://img.shields.io/pypi/v/openapi-core.svg" alt="Package version"> |
| 5 | +</a> |
| 6 | +<a href="https://travis-ci.org/python-openapi/openapi-core" target="_blank"> |
| 7 | + <img src="https://travis-ci.org/python-openapi/openapi-core.svg?branch=master" alt="Continuous Integration"> |
| 8 | +</a> |
| 9 | +<a href="https://codecov.io/github/python-openapi/openapi-core?branch=master" target="_blank"> |
| 10 | + <img src="https://img.shields.io/codecov/c/github/python-openapi/openapi-core/master.svg?style=flat" alt="Tests coverage"> |
| 11 | +</a> |
| 12 | +<a href="https://pypi.python.org/pypi/openapi-core" target="_blank"> |
| 13 | + <img src="https://img.shields.io/pypi/pyversions/openapi-core.svg" alt="Python versions"> |
| 14 | +</a> |
| 15 | +<a href="https://pypi.python.org/pypi/openapi-core" target="_blank"> |
| 16 | + <img src="https://img.shields.io/pypi/format/openapi-core.svg" alt="Package format"> |
| 17 | +</a> |
| 18 | +<a href="https://pypi.python.org/pypi/openapi-core" target="_blank"> |
| 19 | + <img src="https://img.shields.io/pypi/status/openapi-core.svg" alt="Development status"> |
| 20 | +</a> |
| 21 | + |
| 22 | +## About |
| 23 | + |
| 24 | +Openapi-core is a Python library that adds client-side and server-side support |
| 25 | +for the [OpenAPI v3.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md) |
| 26 | +and [OpenAPI v3.1](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md) specification. |
| 27 | + |
| 28 | + |
| 29 | +## Key features |
| 30 | + |
| 31 | +- **Validation** and **unmarshalling** of request and response data (including webhooks) |
| 32 | +- **Integration** with popular libraries (Requests, Werkzeug) and frameworks (Django, Falcon, Flask, Starlette) |
| 33 | +- Customization with media type **deserializers** and format **unmarshallers** |
| 34 | +- **Security** data providers (API keys, Cookie, Basic and Bearer HTTP authentications) |
| 35 | + |
| 36 | + |
| 37 | +## Documentation |
| 38 | + |
| 39 | +Check documentation to see more details about the features. All documentation is in the "docs" directory and online at [openapi-core.readthedocs.io](https://openapi-core.readthedocs.io) |
| 40 | + |
| 41 | + |
| 42 | +## Installation |
| 43 | + |
| 44 | +Recommended way (via pip): |
| 45 | + |
| 46 | +``` console |
| 47 | +pip install openapi-core |
| 48 | +``` |
| 49 | + |
| 50 | +Alternatively you can download the code and install from the repository: |
| 51 | + |
| 52 | +``` console |
| 53 | +pip install -e git+https://github.com/python-openapi/openapi-core.git#egg=openapi_core |
| 54 | +``` |
| 55 | + |
| 56 | + |
| 57 | +## First steps |
| 58 | + |
| 59 | +Firstly create your OpenAPI object. |
| 60 | + |
| 61 | +``` python |
| 62 | +from openapi_core import OpenAPI |
| 63 | + |
| 64 | +openapi = OpenAPI.from_file_path('openapi.json') |
| 65 | +``` |
| 66 | + |
| 67 | +Now you can use it to validate and unmarshal against requests and/or responses. |
| 68 | + |
| 69 | +``` python |
| 70 | +# raises error if request is invalid |
| 71 | +result = openapi.unmarshal_request(request) |
| 72 | +``` |
| 73 | + |
| 74 | +Retrieve validated and unmarshalled request data |
| 75 | + |
| 76 | +``` python |
| 77 | +# get parameters |
| 78 | +path_params = result.parameters.path |
| 79 | +query_params = result.parameters.query |
| 80 | +cookies_params = result.parameters.cookies |
| 81 | +headers_params = result.parameters.headers |
| 82 | +# get body |
| 83 | +body = result.body |
| 84 | +# get security data |
| 85 | +security = result.security |
| 86 | +``` |
| 87 | + |
| 88 | +Request object should implement OpenAPI Request protocol. Check [Integrations](https://openapi-core.readthedocs.io/en/latest/integrations.html) to find officially supported implementations. |
| 89 | + |
| 90 | +For more details read about [Unmarshalling](https://openapi-core.readthedocs.io/en/latest/unmarshalling.html) process. |
| 91 | + |
| 92 | +If you just want to validate your request/response data without unmarshalling, read about [Validation](https://openapi-core.readthedocs.io/en/latest/validation.html) instead. |
| 93 | + |
| 94 | + |
| 95 | +## Related projects |
| 96 | + |
| 97 | +- [openapi-spec-validator](https://github.com/python-openapi/openapi-spec-validator) |
| 98 | + : Python library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger), OpenAPI 3.0 and OpenAPI 3.1 specification. The validator aims to check for full compliance with the Specification. |
| 99 | +- [openapi-schema-validator](https://github.com/python-openapi/openapi-schema-validator) |
| 100 | + : Python library that validates schema against the OpenAPI Schema Specification v3.0 and OpenAPI Schema Specification v3.1. |
| 101 | +- [bottle-openapi-3](https://github.com/cope-systems/bottle-openapi-3) |
| 102 | + : OpenAPI 3.0 Support for the Bottle Web Framework |
| 103 | +- [pyramid_openapi3](https://github.com/niteoweb/pyramid_openapi3) |
| 104 | + : Pyramid addon for OpenAPI3 validation of requests and responses. |
| 105 | +- [tornado-openapi3](https://github.com/correl/tornado-openapi3) |
| 106 | + : Tornado OpenAPI 3 request and response validation library. |
| 107 | + |
| 108 | +## License |
| 109 | + |
| 110 | +The project is under the terms of BSD 3-Clause License. |
0 commit comments