我的端点有一个Swagger文件,我的一个端点有几个参数。你如何处理不需要的参数?如果非必需参数具有空值,我在如何在我的Python文件上处理它时遇到了挑战。
这是我的Swagger定义:
/surveyData:
get:
operationId: "surveyData.read_surveydata"
summary: Gets the survey data for the client insights tracker.
parameters:
- in: query
name: startDate
type: string
required: true
description: The start date of the survey data.
- in: query
name: endDate
type: string
required: true
description: The end date of the survey data.
- in: query
name: country
type: string
description: The countries from which you would like to filter the survey data.
- in: query
name: market
type: string
这是我的函数,用Python编写(使用Connexion):
def read_surveydata(startDate, endDate, country, market):
您可以添加“默认”标记,例如:
parameters:
- name: filtros
in: "query"
required: false
description: Filter to query
type: "string"
default: "bndu"
或者添加默认参数
def read_surveydata(startDate, endDate, country, market='store'):