swagger.example

在swagger頁面顯示example

class QueryWithWhereStringBody(BaseModel):
    qWhere: str
    
@app.post("/queryWithWhereString")
def query_with_where_string(
      query_body: QueryWithWhereStringBody = Body(
          examples={
              "1data": {
                  "summary": "1data",
                  "description": "查獲指定一筆",
                  "value": {
                      "qWhere": "ID='xxxxx'"
                  }
              }
          }
      )
):
    ...

參考 https://fastapi.tiangolo.com/tutorial/schema-extra-example/

Last updated