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.6.tar.gz
(12.4 kB
view details)
Built Distribution
File details
Details for the file openapi3-parser-1.1.6.tar.gz
.
File metadata
- Download URL: openapi3-parser-1.1.6.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69b27eb052ef3344b399ad8888446bbefdcdd028ae570e1407f2302654031b2e |
|
MD5 | 7bd0b8ed9b0f7e13ed1be8e780273908 |
|
BLAKE2b-256 | ddc6be44759cf0c203531bef75d372842faeea30f0d60e9dbc3c89512a1debe7 |
File details
Details for the file openapi3_parser-1.1.6-py3-none-any.whl
.
File metadata
- Download URL: openapi3_parser-1.1.6-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3dfae276883d6e4d65da4c4e4b4dac4ab5af98008076e8bdfc486513f7a6a16 |
|
MD5 | 9d983e4826a85b66df25cdfe2a800aff |
|
BLAKE2b-256 | 7ef6085db20e4bc230be4af34f570f90a40e298d146618389abfe3647c12a0c4 |