feat: faker api: swagger
This commit is contained in:
100
app.py
100
app.py
@@ -3,11 +3,12 @@ import config
|
||||
import utils.response as response
|
||||
import service.faker_data as faker
|
||||
from base import db
|
||||
from model import SexEnum
|
||||
from flasgger import Swagger, swag_from
|
||||
|
||||
app = Flask(__name__)
|
||||
config.init_config(app)
|
||||
db.init_app(app)
|
||||
swagger = Swagger(app)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
@@ -17,43 +18,138 @@ def hello_world():
|
||||
|
||||
@app.route("/faker/railway/<number>")
|
||||
def faker_railway(number):
|
||||
"""Faker Railway Datas
|
||||
---
|
||||
parameters:
|
||||
- name: number
|
||||
in: path
|
||||
type: number
|
||||
required: true
|
||||
description: the number of to be generated
|
||||
responses:
|
||||
200:
|
||||
description: A list of railway
|
||||
"""
|
||||
return response.succ(faker.faker_railways(int(number)))
|
||||
|
||||
|
||||
@app.route("/faker/hotel/<number>")
|
||||
def faker_hotel(number):
|
||||
"""Faker Hotel Datas
|
||||
---
|
||||
parameters:
|
||||
- name: number
|
||||
in: path
|
||||
type: number
|
||||
required: true
|
||||
description: the number of to be generated
|
||||
responses:
|
||||
200:
|
||||
description: A list of hotel
|
||||
"""
|
||||
return response.succ(faker.faker_hotels(int(number)))
|
||||
|
||||
|
||||
@app.route("/faker/contacts/<num_hotel>/<num_railway>")
|
||||
def faker_contacts(num_hotel, num_railway):
|
||||
"""Faker Contacts Datas
|
||||
---
|
||||
parameters:
|
||||
- name: num_hotel
|
||||
in: path
|
||||
type: number
|
||||
required: true
|
||||
description: the number of hotel to be generated
|
||||
- name: num_railway
|
||||
in: path
|
||||
type: number
|
||||
required: true
|
||||
description: the number of railway to be generated
|
||||
responses:
|
||||
200:
|
||||
description: the contacts and patient
|
||||
"""
|
||||
return response.succ(faker.faker_contacts(int(num_hotel), int(num_railway)))
|
||||
|
||||
|
||||
@app.route("/query/patient")
|
||||
def query_patient():
|
||||
"""Query Patients
|
||||
---
|
||||
responses:
|
||||
200:
|
||||
description: A list of patients
|
||||
"""
|
||||
return response.succ(faker.query_patients())
|
||||
|
||||
|
||||
@app.route("/query/contacts/hotel/<identification>")
|
||||
def query_contacts_hotel(identification):
|
||||
"""Query Hotel Contacts by Patient's Identification
|
||||
---
|
||||
parameters:
|
||||
- name: identification
|
||||
in: path
|
||||
type: number
|
||||
required: true
|
||||
description: the identification of patient
|
||||
responses:
|
||||
200:
|
||||
description: A list of contacts
|
||||
"""
|
||||
return response.succ(faker.query_contacts_hotel(identification))
|
||||
|
||||
|
||||
@app.route("/query/contacts/railway/<identification>")
|
||||
def query_contacts_railway(identification):
|
||||
"""Query Railway Contacts by Patient's Identification
|
||||
---
|
||||
parameters:
|
||||
- name: identification
|
||||
in: path
|
||||
type: number
|
||||
required: true
|
||||
description: the identification of patient
|
||||
responses:
|
||||
200:
|
||||
description: A list of contacts
|
||||
"""
|
||||
return response.succ(faker.query_contacts_railway(identification))
|
||||
|
||||
|
||||
@app.route("/query/contacts/classify/<identification>")
|
||||
def query_contacts_classify(identification):
|
||||
"""Query Classified Hotel and Railway Contacts by Patient's Identification
|
||||
---
|
||||
parameters:
|
||||
- name: identification
|
||||
in: path
|
||||
type: number
|
||||
required: true
|
||||
description: the identification of patient
|
||||
responses:
|
||||
200:
|
||||
description: A list of contacts
|
||||
"""
|
||||
return response.succ(faker.query_contacts_classify(identification))
|
||||
|
||||
|
||||
@app.route("/query/contacts/<identification>")
|
||||
def query_contacts(identification):
|
||||
"""Query All Contacts by Patient's Identification
|
||||
---
|
||||
parameters:
|
||||
- name: identification
|
||||
in: path
|
||||
type: number
|
||||
required: true
|
||||
description: the identification of patient
|
||||
responses:
|
||||
200:
|
||||
description: A list of contacts
|
||||
"""
|
||||
return response.succ(faker.query_contacts(identification))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
app.run(debug=True)
|
||||
|
||||
Reference in New Issue
Block a user