有没有办法将YAML restful定义转换为Python Flask或任何其他Python restful服务代码?
示例YAML: -
basePath: /v2
paths:
/pet/{petId}:
get:
tags:
- pet
summary: Find pet by ID
description: Returns a single pet
operationId: getPetById
produces:
- application/xml
- application/json
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
type: integer
format: int64
responses:
'200':
description: successful operation
schema:
db: 'pets'
'400':
description: Invalid ID supplied
'404':
description: Pet not found
security:
- api_key: []
这应该输出像这样的Python Flask实现
from flask import Flask
app = Flask(__name__)
@app.route("/v2/pet/")
def getpet(petId):
return "Pet having petID"
if __name__ == "__main__":
app.run()