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.9.tar.gz
(12.5 kB
view details)
Built Distribution
File details
Details for the file openapi3-parser-0.0.9.tar.gz
.
File metadata
- Download URL: openapi3-parser-0.0.9.tar.gz
- Upload date:
- Size: 12.5 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 | a10089df113aba9be2d19ddafe470b838ce1925c733a945068e34820a9d36e1c |
|
MD5 | c5e6654ebbf26c999ee00613b6dbe9e7 |
|
BLAKE2b-256 | c0b372b2258eaf5203c2ff41610e767f2b3ab7008d2238a84ebb2a5bdf9e70aa |
File details
Details for the file openapi3_parser-0.0.9-py3-none-any.whl
.
File metadata
- Download URL: openapi3_parser-0.0.9-py3-none-any.whl
- Upload date:
- Size: 19.2 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 | fc326566a587ae4d2b49b1e92810debd3624721104b131d2f0baf37b00ffa5f0 |
|
MD5 | dc708a02edf9cc2183b71a014c6cae6c |
|
BLAKE2b-256 | acf396b2b1d6fc45fed4b1fb7258f427032a97bca8cab685d6b1603344c59a77 |