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

Uploaded Source

Built Distribution

openapi3_parser-1.1.4-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openapi3-parser-1.1.4.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for openapi3-parser-1.1.4.tar.gz
Algorithm Hash digest
SHA256 f362d211624461456d4f42535e6ecb3ebea22db5887ade4596e427434105b288
MD5 8e3e9578533dbad36c58a9375c95a6e0
BLAKE2b-256 80b35d4515e208227ebdbd27a844bff6974f78bd5c5c4496c8d5b7fe877657db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openapi3_parser-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2f463c59e05da9470131e9bf14abe9e96e68e71cd69f0c6c8e8d69e897160da6
MD5 732c03343f7ecad6b7501753d18d59dd
BLAKE2b-256 ce6c58981f951da1abc2d7213f5ae47b2950f7b44a57c5c8d7d977c358a40c79

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