Skip to main content

Useful OpenAPI parser for d42 universe

Project description

OpenAPI Parser

Useful for d42 universe and schemax lib.

Installation

python3 -m pip install schemax-openapi

Usage

import yaml
import schemax_openapi
from schemax_openapi import SchemaData

from typing import List

# Also could be JSON OpenAPI file
with open('my_openapi.yaml') as schema_file:
    raw_schema = yaml.load(schema_file, yaml.FullLoader)
    
    parsed_data: List[SchemaData] = schemax_openapi.collect_schema_data(raw_schema)
    for item in parsed_data:
        print(item.path)
        print(item.response_schema_d42)
        ...

All the data is stored in SchemaData object, which has the following fields:

  • http_method: HTTP method of the request.
  • path: URL path of the request.
  • converted_path: URL path converted to the camel-case for usage in schemax generation.
  • args: Arguments of the request.
  • queries: Query parameters of the request. Currently unsupported and always empty list: [].
  • interface_method: Interface name for usage in schemax generation.
  • interface_method_humanized: Interface 'humanized' name for usage in schemax generation.
  • schema_prefix: Schema prefix name for usage in schemax generation.
  • schema_prefix_humanized: Schema prefix 'humanized' name for user in schemax generation.
  • response_schema: Normalized response schema (without $ref).
  • response_schema_d42: Converted to d42 response_schema.
  • request_schema: Normalized request schema (without $ref).
  • request_schema_d42: Converted to d42 request_schema.
  • tags: Tags of the request from OpenAPI schema.

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

schemax_openapi-0.0.5.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

schemax_openapi-0.0.5-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

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