Skip to content

OpenAPI Python client generator that follows the KISS principle.

Notifications You must be signed in to change notification settings

gacou54/openapi-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Open API Client generator

This project was made to generate a simple client (async or not) from an openapi specifications (unlike other client generators, which typically produce code that is difficult for python beginners to use). It aims to produce a single file that contains the Client class.

Notes

This project is in alpha and has probably bugs. Issues/bugfixes/additions are welcome.

Installation

$ pip install simple-openapi-client

Usage

This package is usage from a Python script. Simply load the openapi file (from local file or url) and make the client.

For instance:

from simple_openapi_client import parse_openapi, make_client, Config

config = Config(client_name='Orthanc', package_name='client')
document = parse_openapi(url_or_path='https://api.orthanc-server.com/orthanc-openapi.json')
client_str = make_client(document, config, use_black=True)

with open(f'./{config.package_name}.py', 'w') as file:
    file.write(client_str)

Or, for an async client:

from simple_openapi_client import parse_openapi, make_client, Config

config = Config(client_name='AsyncOrthanc', package_name='async_client')
document = parse_openapi(url_or_path='https://api.orthanc-server.com/orthanc-openapi.json')
client_str = make_client(document, config, async_mode=True, use_black=True)

with open(f'./{config.package_name}.py', 'w') as file:
    file.write(client_str)

About

OpenAPI Python client generator that follows the KISS principle.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Jinja 60.0%
  • Python 40.0%