Skip to content
프로젝트

guokr/swagger-py-codegen

GitHub에서 보기

소개

Flask, Tornado, Falcon, Sanic을 지원하는 Python 웹 프레임워크 생성기

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

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

관련 프로젝트 살펴보기

불러오는 중…