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.7.tar.gz
(12.4 kB
view details)
Built Distribution
File details
Details for the file openapi3-parser-0.0.7.tar.gz
.
File metadata
- Download URL: openapi3-parser-0.0.7.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec6c1decb3dd282ac7b7850f1d662498cfe6d617a21c4c81dcc71434fb20ca97 |
|
MD5 | 98d318471cfeb61fdb3b7cd20f088c31 |
|
BLAKE2b-256 | ffe6c34ae931147a0f83d0b2d48e6cc9ed3b521548ebfb24348d0942227b026f |
File details
Details for the file openapi3_parser-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: openapi3_parser-0.0.7-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9733cfadbb281304839b0e7519f531931b1982917c060d0da611b5e2b49a6e50 |
|
MD5 | 9a946cd441cc9e26ccc3c11fc47103ab |
|
BLAKE2b-256 | 2a145b509c5f5d8741aa520ea9ceaed761aa252a1207101be37257da7d9554d3 |