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.8.tar.gz
(14.7 kB
view details)
Built Distribution
File details
Details for the file openapi3-parser-1.1.8.tar.gz
.
File metadata
- Download URL: openapi3-parser-1.1.8.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b55d4634cc35e64e6b974fc24a12965172d8f1a519b6d1f7c888777460070542 |
|
MD5 | 7d08a6a5ef8c5ac6b2389ddbc54475a9 |
|
BLAKE2b-256 | c5b3d60544303f99464a07f098bee7b1949e3a54a58b2da5ef204cb25b8a0ea2 |
File details
Details for the file openapi3_parser-1.1.8-py3-none-any.whl
.
File metadata
- Download URL: openapi3_parser-1.1.8-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f5b5ebf268570f37047047461c7e81b61dcac48ad0eb03750eaa85fb778009b |
|
MD5 | a91674a91a2fbdff7403c8095362805e |
|
BLAKE2b-256 | 96ff47d67b5ea74c644054ee9b86eca1f53b2c1c59e3038be2083172cedbb75f |