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.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


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

Uploaded Source

Built Distribution

openapi3_parser-1.1.7-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

Hashes for openapi3-parser-1.1.7.tar.gz
Algorithm Hash digest
SHA256 d24d144ef322262d9f996439a068ded35a972551b4180bebc21e97643b4c735c
MD5 8f4e5b0d1cce83abfdb86149e20f861f
BLAKE2b-256 c0d8db6c5658c744ce1ba6eedadcf30c8a6a0f80642242bafa6b5fdec545c0ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openapi3_parser-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 886c431d98969cde589d6b1ce91b6b75421ed4d9d45c733d7055fa06167e135d
MD5 7d87dad6040176701dc697b1cc0af9cb
BLAKE2b-256 5b5ec70a6e0952380c042ee5b1d6b06848b6d98a0a143816d0d402c31e1f267d

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