Skip to main content

hydra-openapi-parser

This library contains the OpenAPI parser implemntaion in Python to be used with hydrus and hydra-python-agent.

Currently the library consists of openapi_parser module which helps hydrus parse OpenAPI standard docs.

To install the library:

pip install git+https://github.com/HTTP-APIs/hydra-openapi-parser.git#egg=hydra_openapi_parser

Note :- If using hydrus, the library doesn't need to be installed separately as it is already a part of requirements.txt for hydrus. Usage

To import the modules:

from hydra_openapi_parser import openapi_parser

Porting out from hydrus the hydraspecs directory

Sample use-cases of openapi_parser module

Once the OpenAPI YAML document is assigned into the variable doc as a Python dictionary, you can do the following:

  • Parse the OpenAPI doc into a HydraDoc
parsed_dict = openapi_parser.parse(doc)
  • Generate an empty object
object = openapi_parser.generate_empty_object()
  • Test if an endpoint is valid
path = 'A/B/{id}/C/D'
openapi_parser.valid_endpoint(path)
# False
path = 'A/B/{id}'
openapi_parser.valid_endpoint(path)
# Collection
path = 'A/B/C'
openapi_parser.valid_endpoint(path)
# True
  • Extract class name from the path
path = "A/B/C/Pet"
path_list = path.split('/')
openapi_parser.get_class_name(path_list)
# Pet
  • Fetch data from location
path = '#/definitions/Order'
path_list = path.split('/')
data = openapi_parser.get_data_at_location(path_list, doc)
# data is of type dict
  • Remove variables from path
path = "A/B/C/{id}"
output = openapi_parser.sanitise_path(path)
  • Identify if an object is a collection
schema_block = {
    'type': 'array',
    'items': {
        '$ref': '#/definitions/Pet'
    }
}
method = "/Pet"
openapi_parser.check_collection(schema_block, method)
# True

Metadata

Release files for hydra-openapi-parser 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hydra-openapi-parser 0.2.0
File Size Uploaded Provenance Actions
hydra_openapi_parser-0.2.0.tar.gz 7.6 kB Without provenance Details for hydra_openapi_parser-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hydra-openapi-parser 0.2.0
File Interpreter ABI Platform Actions
hydra_openapi_parser-0.2.0-py3-none-any.whl Python 3 none any Details for hydra_openapi_parser-0.2.0-py3-none-any.whl

Total release size: 17.2 kB

Release files / hydra_openapi_parser-0.2.0.tar.gz

Download URL hydra_openapi_parser-0.2.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7fd1ca6892ec014f3285bd7a19de03bb94c9d4fee49e3815c2714ac133b70468
BLAKE2b-256 checksum
How to use checksums
f3f9bea8a3130f6a9bacb71144d1f0a55e3de0194633caf88e843c3660b4a1a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.9

Release files / hydra_openapi_parser-0.2.0-py3-none-any.whl

Download URL hydra_openapi_parser-0.2.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef23190c3022a6eab068b8e7695255b35b6b4ef8fffe948be2ee1460623a9e71
BLAKE2b-256 checksum
How to use checksums
6b1fe3d571df353c29391af175297ed291a86787c2345a72bc18afad684ec7c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.9

Security for hydra-openapi-parser 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page