• Stars
    star
    554
  • Rank 80,342 (Top 2 %)
  • Language
    Python
  • Created over 9 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a Python web framework generator supports Flask, Tornado, Falcon, Sanic

Python RESTful Web Framework Generator

Build Status PyPi Version

Overview

Swagger Py Codegen is a Python web framework generator, which can help you generate a Python web framework automatically based on a given Swagger Specification doc. Currently, the following languages/frameworks are supported:

Alpha version for now, it may not handle all validation properly. If you found a bug, feel free to contact us.

Install

pip install swagger-py-codegen

Usage

Create all:

swagger_py_codegen --swagger-doc api.yml example-app

Command Options:

-s, --swagger-doc               Swagger doc file.  [required]
-f, --force                     Force overwrite.
-p, --package                   Package name / application name.
-t, --template-dir              Path of your custom templates directory.
--spec, --specification         Generate online specification json response.
--ui                            Generate swagger ui.
--validate                      Validate swagger file.
-tlp, --templates               gen flask/tornado/falcon templates, default flask.
--version                       Show current version.
--help                          Show this message and exit.

Examples:

Generate example-app from api.yml:

Flask Example

$ swagger_py_codegen -s api.yml example-app -p demo
$ tree (flask-demo)
.
|__ api.yml
|__ example-app
   |__ demo
   |  |__ __init__.py
   |  |__ v1
   |     |__ api
   |     |  |__ __init__.py
   |     |  |__ pets.py
   |     |  |__ pets_petId.py
   |     |__ __init__.py
   |     |__ routes.py
   |     |__ schemas.py
   |     |__ validators.py
   |__ requirements.txt

Tornado Example

$ swagger_py_codegen -s api.yml example-app -p demo -tlp=tornado
$ tree (tornado-demo)
.
|__ api.yml
|__ example-app
   |__ demo
   |  |__ __init__.py
   |  |__ core
   |     |__ __init.py
   |  |__ v1
   |     |__ api
   |     |  |__ __init__.py
   |     |  |__ pets.py
   |     |  |__ pets_petId.py
   |     |__ __init__.py
   |     |__ routes.py
   |     |__ schemas.py
   |     |__ validators.py
   |__ requirements.txt

Falcon Example

$ swagger_py_codegen -s api.yml example-app -p demo -tlp=falcon
$ tree (falcon-demo)
.
|__ api.yml
|__ example-app
   |__ demo
   |  |__ __init__.py
   |  |__ v1
   |     |__ api
   |     |  |__ __init__.py
   |     |  |__ pets.py
   |     |  |__ pets_petId.py
   |     |__ __init__.py
   |     |__ routes.py
   |     |__ schemas.py
   |     |__ validators.py
   |__ requirements.txt

Sanic Example

$ swagger_py_codegen -s api.yml example-app -p demo -tlp=sanic
$ tree (sanic-demo)
.
|__ api.yml
|__ example-app
   |__ demo
   |  |__ __init__.py
   |  |__ v1
   |     |__ api
   |     |  |__ __init__.py
   |     |  |__ pets.py
   |     |  |__ pets_petId.py
   |     |__ __init__.py
   |     |__ routes.py
   |     |__ schemas.py
   |     |__ validators.py
   |__ requirements.txt

Run Web Server

Install example-app requirements:

$ cd example-app
$ pip install -r requirements.txt

Start example-app:

$ cd demo
$ python __init__.py

And generate example-app-ui from api.yml with ui:

$ swagger_py_codegen -s api.yml  example-app-ui -p demo-ui --ui --spec

Then you can visit http://127.0.0.1:5000/static/swagger-ui/index.html in a browser.

OAuth2 Scopes Usage

See the wiki

Compatibility

component compatibility
OpenAPI Spec 2.0
Python 2.*, 3.*(Sanic only 3.*)

Authors

See the AUTHORS.

License

MIT

More Repositories

1

gkseg

Yet another Chinese word segmentation package based on character-based tagging heuristics and CRF algorithm
C
243
star
2

simbase

A vector similarity database
Java
230
star
3

stan-cn-nlp

stan-cn-nlp: an API wrapper based on Stanford NLP packages for the convenience of Chinese users
Java
56
star
4

Brief

In a nutshell, this is a Text Summarizer
Python
42
star
5

Caver

Caver: a toolkit for multilabel text classification.
Python
39
star
6

redis-namespace

namespaced subset of your redis keyspace
Python
22
star
7

G.js

A simple javascript module loader from Guokr.com
JavaScript
20
star
8

corpus

An open corpus for Chinese NLP study
16
star
9

TorchCTR

CTR Prediction on PyTorch
Python
14
star
10

stan-cn-ner

A Chinese naming entity recognization package in stan-cn-* family
Java
14
star
11

guokr-build

A build tool for frontend developer from guokr.com
JavaScript
10
star
12

guokr

guokr modules
JavaScript
9
star
13

asynx

An open source, distributed, and web / HTTP oriented taskqueue & scheduler service inspired by GAE
Python
6
star
14

stan-cn-seg

A Chinese word segmentation package in stan-cn-* family
ActionScript
6
star
15

clj-cn-nlp

A clojure wrapper for Stanford CoreNLP package based on stan-cn-nlp Java wrapper for Simplified Chinese users
Clojure
6
star
16

neuseg

An experimental Chinese word segmentation tool based on vector model and neurual networks
Java
5
star
17

simbase-clj

A clojure client for simbase
Clojure
5
star
18

wikicrawl

A crawler to achieve the category structure of wikipedia
Clojure
4
star
19

tsuru-postgresapi

A PostgreSQL API for tsuru PaaS
4
star
20

hebo

A dataflow scheduler based on cascalog for hadoop tasks
Java
3
star
21

stan-cn-tag

A Chinese POS tagging package in stan-cn-* family
Java
3
star
22

stan-cn-com

A common base for stan-cn-* package family.
Java
3
star
23

string-demon

Python
2
star
24

usher-heartbeat

register to the usher and keep the heartbeat
Python
1
star