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.6.tar.gz
(6.7 kB
view details)
Built Distribution
File details
Details for the file openapi-specgen-0.0.6.tar.gz
.
File metadata
- Download URL: openapi-specgen-0.0.6.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b27ae7132705ca37317b7396f00729b6d1a029805dd28c5eb1cf9a74fa5fe35 |
|
MD5 | 65e0c814686e7e47be22e73f1a5a86ce |
|
BLAKE2b-256 | 3ffb520fca7a7a223e103048e228d28b0974c4151be351302f7c38dd49e6c306 |
File details
Details for the file openapi_specgen-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: openapi_specgen-0.0.6-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c3b74648200a06c01001abe92c51d3954c216edc963241451eb40c8781a3291 |
|
MD5 | 22bd2affd8c6aef5e1a89c7067618211 |
|
BLAKE2b-256 | 9f28c0bfcc54b314ad5f244af486a8da76a71d1e0bba8b1e3ed7988e8f9be336 |