Skip to main content

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


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.8.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

openapi3_parser-0.0.8-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file openapi3-parser-0.0.8.tar.gz.

File metadata

  • Download URL: openapi3-parser-0.0.8.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

Hashes for openapi3-parser-0.0.8.tar.gz
Algorithm Hash digest
SHA256 ce8b7d496cccf5a62d7f4752f6ba09761a5053932bce618841f90ddce9e867ae
MD5 e2971feed96cdd4fce255785e26a1b2e
BLAKE2b-256 a304f3e07abb4f990a32613667ee7c9bd89d629d806b1c752950156517ac07bf

See more details on using hashes here.

File details

Details for the file openapi3_parser-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: openapi3_parser-0.0.8-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

Hashes for openapi3_parser-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 506633a1fb2b14bf53b13ee902d03a55549e890062780a3121e4e47ade21139a
MD5 9774e05e7d188b0ea9d8b1bc67502c7c
BLAKE2b-256 eb75aa89ff66048e7f58c0cced01bf564734d73adf44a629ae45e05d868948e5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page