How to add multiple example values in swagger properties?

前端 未结 2 1652
慢半拍i
慢半拍i 2020-11-28 16:09

I am using Swagger OpenAPI Specification tool, I have a string array property in one of the definitions as follows :

cities:
        type: array
        item         


        
相关标签:
2条回答
  • 2020-11-28 16:43

    To display an array example with multiple items, add the example on the array level instead of item level:

    cities:
      type: array
      items:
        type: string
      example:
        - Pune
        - Mumbai
        - Bangaluru
    
      # or
      # example: [Pune, Mumbai, Bangaluru]
    
    0 讨论(0)
  • 2020-11-28 16:45

    For openapi version - 3.0.0+

      major:
          type: array
          items:
            type: string
            enum:
              - Accounting
              - Business Contacts
              - Economy
              - Finance
              - Graphic Design
              - International Business Administration
              - International Relations
              - Law
              - Marketing
              - others
              - Political Science
              - Statistics
    
    0 讨论(0)
提交回复
热议问题