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
Built Distribution
Close
Hashes for openapi-specgen-0.0.3.dev1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46d3cbffb11986465473cdeb03e478409928ce36a12accb0406d4a068330fb27 |
|
MD5 | d48adbfb67eb50370d7b3f4941fa1b3c |
|
BLAKE2b-256 | 1d3dd3dd172d19a26a63f271a9d492b757bc1bec283a2603a1b032f97713f7f7 |
Close
Hashes for openapi_specgen-0.0.3.dev1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5e413b27a459c6db6b6477e63a12a43429caf148b5a1378fe6c747ed62d5316 |
|
MD5 | 783c4a3f5ead3d08b4dc51676a2a5b75 |
|
BLAKE2b-256 | 6a6b36454431f0bb91e45991360ae6257d6648933eb4b2e1654e20962dcad426 |