OpenAPI Type for Python¶
openapi-type provides the OpenAPI Specification as a Python type.
pip install openapi-type
from openapi_type import OpenAPI, parse_spec, serialize_spec
spec: OpenAPI = parse_spec({
"your OpenAPI Spec as Python dictionary": "will be parsed into a proper Python type"
})
assert parse_spec(serialize_spec(spec)) == spec
Quickstart Guide¶
Installation¶
$ pip install openapi-type
Using CLI tool¶
Once installed, openapi-type
provides you with a CLI tool that allows you to generate a
Python client derived from a JSON/YAML specification.
For example, try the following snippet in your shell:
$ curl -s https://<specs-location> | openapi-type gen -o <new-client-dir>