GithubHelp home page GithubHelp logo

sdkgen's Introduction

sdkgen

Generate openapi 3 spec from json request and responses of REST APIs.

Docker Setup

Pre-requisites

Install docker

For macOS -> https://docs.docker.com/docker-for-mac/install/

Build

  1. Git clone the repo.
    mkdir -p go

    cd go

    git clone [email protected]:alokic/sdkgen.git

    cd sdkgen
  1. Build docker image
    docker build -t sdkgen .
  1. Generates openapi specs

    In following example, openapi specs for jsons in ./examples/inputs/nested are generated in /tmp/openapi.

    docker run -v ${PWD}/examples:/examples -v /tmp:/tmp sdkgen  openapi -i /examples/inputs/nested -o /tmp/openapi
  1. Generates SDK

    In following example sdk in python is generated in /tmp/sdk/python directory from /tmp/openapi/main.yaml generated in step 7.

    docker run -v ${PWD}/examples:/examples -v /tmp:/tmp sdkgen  sdk -i /tmp/openapi/main.yaml -o /tmp/sdk -g python

In following example, sdk is generated with configs defined in ./examples/config/python.json.

    docker run -v ${PWD}/examples:/examples sdkgen  sdk -i /tmp/openapi/main.yaml -o /tmp/sdk -g python -c /examples/config/python.json

Local Setup

Pre-requisites

    # Install go
    $ brew install [email protected]

    # Install dep (golang package manager)
    $ brew install dep

    # install openapi generator. Refer
    $ brew install openapi-generator

Build

  1. Make sure GOPATH is properly set. If you are new to golang then,
    makdir -p $HOME/go 
    echo 'export GOPATH=$HOME/go' >>~/.bash_profile
    mkdir -p $GOPATH/src $GOPATH/pkg $GOPATH/bin
  1. Set PATH
    export PATH=$PATH:$GOPATH/bin
  1. Git clone the repo.
    mkdir -p $GOPATH/src/github.com/alokic

    cd $GOPATH/src/github.com/alokic

    git clone [email protected]:alokic/sdkgen.git

    cd sdkgen
  1. Check all deps are there by running below
   dep ensure
  1. Build the app
   make build

ctl gets installed in $GOPATH/bin

  1. Help
    ctl --help
  1. Generates openapi specs

    In following example, openapi specs for jsons in ./examples/inputs/nested are generated in /tmp/openapi.

    ctl openapi -i ./examples/inputs/nested -o /tmp/openapi
  1. Generates SDK

    In following example sdk in python is generated in ./examples/sdk/python directory from /tmp/output/main.yaml generated in step 7.

    ctl sdk -i /tmp/openapi/main.yaml -o /tmp/sdk -g python

In following example, sdk is generated with configs defined in .examples/config/python.

    ctl sdk -i /tmp/openapi/main.yaml -o /tmp/sdk -g python -c ./examples/config/python.json

Tests

    make test

Openapi generator commands

For details check: Openapi Codegen

Config options for a language

    openapi-generator  config-help -g python

Generate code

    openapi-generator generate   -i <input_file_path> -g python -o <output_folder> --enable-post-process-file

sdkgen's People

Contributors

sandy247 avatar alokic avatar kunalganglani avatar

Watchers

 avatar  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.