How to define Swagger 2.0 JSON to populate default body parameter object in Swagger UI?

前端 未结 2 1696
悲&欢浪女
悲&欢浪女 2021-01-13 23:44

Our current deployment patterns require me to manually write my swagger json output that will be consumed by the Swagger-based UI in use at my company. I\'d like the json I

2条回答
  •  再見小時候
    2021-01-13 23:59

    To have example values, you just have to add an "example" property where needed:

    exampleDefinition:
      type: object
      description: Request details for Example Definition
      properties:
        action:
          type: string
          description: Specifies the action to be taken
          example: An action value
        applyToBase:
          type: string
          description: >-
            A boolean value that defines the behaviour of the request against the base
          example: An apply to base value
        addOnIDs:
          type: string
          description: The identifiers for the add-ons
          example: an ID
    

    Unfortunately the online editor don't propose them but SwaggerUI does:

提交回复
热议问题