Coder Social home page Coder Social logo

bcdevlucas / openapi-py-client-generator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 89 KB

This CLI tool generates a custom Python OpenAPI 2.0 or 3.0 client for a given yaml / json OpenApi spec using the official OpenAPI docker images.

Shell 2.27% HTML 97.73%

openapi-py-client-generator's Introduction

openapi-py-client-generator

This CLI tool generates a custom Python OpenAPI 2.0 or 3.0 client for a given yaml / json OpenApi spec using the official OpenAPI docker images and configurable mustache templates.

Using the generated OpenAPI / Swagger client

To use the generated client in your application just include the package in your requirements:

git+https://github.com/<your-handle>/<your-repo>.git#egg=swagger_client

Then import the client like any other package:

from swagger_client import MyApi

Re-building the OpenAPI / Swagger Client

These are the build steps for re-generating the OpenAPI / Swagger Client.

Pre-requisites:

  • You need to have Docker installed locally and running.
  • You will need an OpenAPI / Swagger yaml or json spec file OR the URL to that spec.
  • If you want to use an OpenApi / Swagger spec FILE on your computer, place the file in the /generator/specs folder.

Generating an Updated API Client

Open up a new terminal window. From the root folder of this project, run bash ./generate-client.sh.

This will utility will generate an updated API client. Usage is simple, just follow the prompts:

  • Enter the URL / file name for the OpenApi spec to use
  • Choose a version of OpenApi to use: [2 / 3]
  • What format is the spec in?: [yml / json]
  • Choose a template to use: [oapi2 / oapi3 / ]
  • Would you like to push the client to a remote repository? [yes / no]
  • Enter a git repository URL or press enter to use the defaults
  • Enter the name of the branch you would like to commit to

And that's it!

Customizing Defaults

You can configure the defaults by adding a .env file in the /generator folder. See sample.env in the root folder of this project for a template you can use.

You can configure the following defaults:

  • API_CLIENT_REPO_URL
  • API_SPEC_URL
  • OAPI2_TEMPLATE_DIR (Default: oapi2)
  • OAPI3_TEMPLATE_DIR (Default: oapi3)
  • DEFAULT_OPEN_API_VERSION (Default: 3)
  • DEFAULT_SPEC_FORMAT (Default: yml)
  • DEFAULT_TEMPLATE_DIR (Default: oapi3)

Modifying the Templates

openapi-py-client-generator's People

Contributors

bcdevlucas avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.