OpenAPI v3 parser
Project description
OpenAPI Parser
A simple package to parse your OpenAPI 3 documents into Python object to work with.
How to install
To install package run the following command
pip install openapi3-parser
How to use
Example of parser usage
>>> from openapi_parser import parse
>>> content = parse('swagger.yml')
>>> print(content)
Get application servers
from openapi_parser import parse
specification = parse('data/swagger.yml')
print("Application servers")
for server in specification.servers:
print(f"{server.description} - {server.url}")
# Output
#
# >> Application servers
# >> production - https://users.app
# >> staging - http://stage.users.app
# >> development - http://users.local
Get list of application URLs
from openapi_parser import parse
specification = parse('tests/data/swagger.yml')
urls = [x.pattern for x in specification.paths]
print(urls)
# Output
#
# >> ['/users', '/users/{uuid}']
Get operation with supported HTTP methods
from openapi_parser import parse
specification = parse('tests/data/swagger.yml')
for operation in specification.paths:
pattern = operation.pattern
supported_methods = ','.join([x.name for x in operation.item.operations])
print(f"Operation: {pattern}, methods: {supported_methods}")
# Output
#
# >> Operation: /users, methods: GET,POST
# >> Operation: /users/{uuid}, methods: GET,PUT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
openapi3-parser-0.0.6.tar.gz
(12.4 kB
view hashes)
Built Distribution
Close
Hashes for openapi3_parser-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04d583b73b36dfdf28c6c51a552877b92576d1bd9813dcb44dae9b5d946f10aa |
|
MD5 | 7281de9f67c4447a6af9c8e2cefcf13d |
|
BLAKE2b-256 | b36e6a388fa6f78773dbb84a749bfb0cc6294ac24a6a55490761024a3426778d |