Code Monkey home page Code Monkey logo

flaskleap's Introduction

Flask RESTful Application Code Generator

Overview

Generates Flask Service blueprint code baded on Swagger Specification

This project is directly modified on: github.com/guokr/swagger-py-codegen

How its different:

Flask Code Gen is completly based on base requirments for standard build and integration. It Automates:
1> Module Creation (flask blueprint) and grouping of API's
2> Abstract API views to support easier API changes
3> Python Project setup (setuptools, tox, pycov, flake8, pydoc integration)
4> Build, Test, Release automation Script
5> Dockerfile with Cherrypi as a wsgi server
6> Swagger UI and Definition creation

Install

Install stable package from dist:

pip install flask-leap

Install from code:

make install flask-leap

Usage

Create all:

flask-leap --swagger-doc api.yml example

Command Options:

flask-leap --help
Usage: flask-leap [OPTIONS] DESTINATION

Options:
-s, --swagger, --swagger-doc TEXT
Swagger doc file.  [required]
-f, --force                     Force overwrite to generated files.
-t, --template-dir TEXT         Path of your custom templates directory.
-g, --group-factor INTEGER      The api groupping factor for creating a
module, zero to disable
-a, --author TEXT               author of the service
-m, --mail TEXT                 mailid of the author
-v, --service-version TEXT      initial service version
--version                       Show current version.
--help                          Show this message and exit.

Examples:

Generate example service from api.yml:

$tree
.
|__ api.yml

//  Group factor value 1 indicates that more than one same 
//  api pattern will create a module
$ flask-leap -s api.yml -g 1 example
$ tree
.
|__ api.yml
|__ example
	├── Dockerfile
	├── MANIFEST.in
	├── Makefile
	├── README.md
	├── config
	│   └── config.py
	├── docker-entrypoint.sh
	├── example
	│   ├── __init__.py
	│   ├── __main__.py
	│   ├── app.py
	│   ├── blueprints.py (R)
	│   ├── common
	│   │   ├── __init__.py
	│   │   └── utils.py
	│   ├── config
	│   │   ├── __init__.py
	│   │   └── config.py
	│   ├── hello
	│   │   ├── __init__.py
	│   │   ├── models.py
	│   │   ├── resources.py (R)
	│   │   ├── routes.py (R)
	│   │   └── views.py
	│   ├── resources.py (R)
	│   ├── routes.py (R)
	│   ├── run.py
	│   ├── schemas.py (R)
	│   ├── swagger.json (R)
	│   └── views.py
	├── requirements.txt
	├── server.py
	├── setup.cfg
	├── setup.py
	├── swagger.yaml (R)(S)
	├── test
	│   ├── __init__.py
	│   └── test.py
	├── tox.ini
	└── wsgi.py
    
(R) File that would be Regenerated for changes in swagger
    For the best practice user should not change the Regenerated Files
(S) Swagger definition file for the Service
    This file would be used by the CI/CD for the service definition

Install Example Service:

$ cd example
$ make install

Start Example Service:

$ python server.py

Create and Run Docker image of Example Service:

$ make install-docker
$ docker run docker run -p 8080:8080 s8sg/example

Service Swagger Ui from apis.yml:

Then you can visit http://127.0.0.1:8080/<base_path>/apidocs in a browser.

flaskleap's People

Contributors

s8sg avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mkobar

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.