天天看點

fastapi四:fastapi接口常用配置參數

當使用 @app.get()、@app.post()··· 聲明接口的時候,除了指定接口位址,是可以指定一些其他參數的

fastapi四:fastapi接口常用配置參數

path: 接口位址,在fastapi中,允許接口位址重複,當為同一請求方式時,将取優先加載的函數,當請求方法不同時,則正常加載

fastapi四:fastapi接口常用配置參數
fastapi四:fastapi接口常用配置參數
fastapi四:fastapi接口常用配置參數

response_model: 響應模型

tags:接口标簽

fastapi四:fastapi接口常用配置參數
fastapi四:fastapi接口常用配置參數

summary:接口概述,沒有指定時,使用接口修飾的函數的名字,首字母大寫

fastapi四:fastapi接口常用配置參數
fastapi四:fastapi接口常用配置參數

description: 接口較長的描述

fastapi四:fastapi接口常用配置參數
fastapi四:fastapi接口常用配置參數

response_description:接口響應描述

fastapi四:fastapi接口常用配置參數
fastapi四:fastapi接口常用配置參數

status_code:指定接口響應狀态碼

fastapi四:fastapi接口常用配置參數
fastapi四:fastapi接口常用配置參數
fastapi四:fastapi接口常用配置參數

deprecated:辨別接口已廢棄,隻是辨別,不影響使用

讨論群:249728408