Skip to main content

Generate OpenApi json specification

Project description

openapi-specgen

Openapi-Specgen helps you generate OpenApi specification from your python code.

Includes support for automatically generating OpenApi schemas for Dataclasses and Marshamllow Schemas.

Installation

Install using pip

pip install openapi-specgen

Quick Start

Define your objects using dataclasses or marshmallow schemas. Import the required OpenApi classes and define your Api with it`s paths, params and responses.

from typing import List
from dataclasses import dataclass

@dataclass
class DataclassObject():
    str_field: str
    int_field: int
    float_field: float
    boolean_field: bool
    list_field: List[str]

from openapi_specgen import OpenApi, OpenApiParam, OpenApiPath, OpenApiResponse

sample_response = OpenApiResponse('Response description', data_type=DataclassObject)
sample_param = OpenApiParam('param_name', 'query', data_type=str)
sample_path = OpenApiPath('/api_path', 'get', [sample_response], [sample_param])


marshmallow_response = OpenApiResponse('Response description', data_type=MarshmallowSchema)
marshmallow_path = OpenApiPath('/api_path', 'post', [sample_response], requestBody=MarshmallowSchema)

sample_api = OpenApi('Sample Api', [sample_path, marshmallow_path])

sample_api.as_dict()

License

This project is licensed under the MIT License - see the LICENSE file for details

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

openapi-specgen-0.0.3.dev2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

openapi_specgen-0.0.3.dev2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file openapi-specgen-0.0.3.dev2.tar.gz.

File metadata

  • Download URL: openapi-specgen-0.0.3.dev2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for openapi-specgen-0.0.3.dev2.tar.gz
Algorithm Hash digest
SHA256 3ae388611441d1a21758ec8fec6069aa70eb15a43d312ec1ecec4bf3bd6e642e
MD5 5a8bbe4367b6d9eafea942e00955627d
BLAKE2b-256 ebe4fdc4ee9c01162a9b3366f7a5fcebeb24b034d50bcfdea299fc524aad3425

See more details on using hashes here.

File details

Details for the file openapi_specgen-0.0.3.dev2-py3-none-any.whl.

File metadata

  • Download URL: openapi_specgen-0.0.3.dev2-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for openapi_specgen-0.0.3.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 af1052bd9462fe8517362b668b5b22912f5f064c0001ece1eec5be70e86f7d14
MD5 dbfb91f06a836a413fb8e964fb4ef532
BLAKE2b-256 12c83089c5a917937b93e098275d640bf286561df2fbc61ab0ef1f6c908bda7b

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