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.0.0.tar.gz
(11.3 kB
view details)
Built Distribution
File details
Details for the file openapi3-parser-1.0.0.tar.gz
.
File metadata
- Download URL: openapi3-parser-1.0.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2076f33eeaee5c1a23571c7c25d7f7798da7ff7342cb319723188eabbe8df66 |
|
MD5 | 1e33d62d2001a38ba1bcbc32618dd9c2 |
|
BLAKE2b-256 | 908a1061d8164d7360b9d743328650a0024ec805edfa8755cc488e27a06866d3 |
File details
Details for the file openapi3_parser-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: openapi3_parser-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c6eee227bd86c1ab2baf34fe565f96c34c846378e325012d42b154fd783053c |
|
MD5 | 08b7f81803e5a778d01484b86a6424bc |
|
BLAKE2b-256 | 6582e0d48ff09e975b17863531ec6ffdae07d11938eb24630dbea5b6c6c09fb8 |