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
Release history Release notifications | RSS feed
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.4.tar.gz
(5.2 kB
view details)
Built Distribution
File details
Details for the file openapi-specgen-0.0.4.tar.gz
.
File metadata
- Download URL: openapi-specgen-0.0.4.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.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a10465016d9f9708788a603191474db89e24906c6ecd291582505a804a7cd961 |
|
MD5 | 8b496f3f57f88b57f3c5c671d6ba98fe |
|
BLAKE2b-256 | 438ddc5e9bdccd3709d1563654bf110cce13c6cbaad5b83beac92a7850bf8013 |
File details
Details for the file openapi_specgen-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: openapi_specgen-0.0.4-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.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f615218767798c6a3e4ab7e242c8cd6a7aa4e70104ad7a5fca76853c8a989c1e |
|
MD5 | 55329853152d654598675dac14aaed34 |
|
BLAKE2b-256 | df82a4a5690e716662756259bd67585e7f48dcdc99a9c8e29a32dd728182a043 |