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

Uploaded Source

Built Distribution

openapi3_parser-1.1.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openapi3-parser-1.1.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for openapi3-parser-1.1.1.tar.gz
Algorithm Hash digest
SHA256 0a3a79eb3acb82e6a12969835030c84dea720ca3430a22655812fbd3b00dfdfe
MD5 6ff51e9638cd1e6b20743c9af490b4bf
BLAKE2b-256 0639fb5686e9bb154f15f362a252815569eeeebdeed8e35bde1d489e0afb7e3a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: openapi3_parser-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for openapi3_parser-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3853a8c61601eaa5774640e9ba9571e8548d9722f1605dff355a51c7fc78da09
MD5 f5bde7c3503f8dcfe056d007d0e6fd55
BLAKE2b-256 b097427081ee1f0b5e14366cddbcd81f6160419dc679c3b49acbfb416b681d05

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