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.url 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 path in specification.paths:
supported_methods = ','.join([x.method.value for x in path.operations])
print(f"Operation: {path.url}, 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-1.1.0.tar.gz
(11.6 kB
view details)
Built Distribution
File details
Details for the file openapi3-parser-1.1.0.tar.gz
.
File metadata
- Download URL: openapi3-parser-1.1.0.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22379360f3c08691d2dc851bcfeb05f75684abc75176c9da786e5c210921f62c |
|
MD5 | 4fc1e8181f46104b13b572374959d564 |
|
BLAKE2b-256 | 8d7f0ac452e1cd713c48d663f245380cb988821e7c4d5cb96b56ef7b832d2a55 |
File details
Details for the file openapi3_parser-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: openapi3_parser-1.1.0-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b636a0f7e98d30618daa3133d457e3f6297d7949efe8a280fc2742c9372e9ab |
|
MD5 | 1d7c54a84a9a8c0c59ee6f1fb2b76c1d |
|
BLAKE2b-256 | 73e8ff02cebd2c3e1ba71c981fb9bb63a42e457641c5c2d24cb1fba88358f6ac |