0

I have a Swagger file for my endpoints, one of my endpoints has several parameters. How do you handle non-required parameters? I'm having a challenge on how to handle it on my Python file if the non-required parameters have empty value.

Here is my Swagger definition:

/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

and here is my function which is written in Python (using Connexion):

def read_surveydata(startDate, endDate, country, market):
Helen
  • 87,344
  • 17
  • 243
  • 314
GeekyDad
  • 75
  • 1
  • 7

1 Answers1

1

You can add the "Default" tag for example:

      parameters:
        - name: filtros
          in: "query"
          required: false
          description: Filter to query
          type: "string"
          default: "bndu"

Or add a default argument

def read_surveydata(startDate, endDate, country, market='store'):
Kevin Martins
  • 590
  • 7
  • 20