Forum Discussion

kawad1's avatar
kawad1
New Member
26 days ago

I can't see the "add item" button in swagger UI

I have this 

 name: deviceIds
      description: |-
        Comma separated list of  resource device IDs and ranges. Multiple ranges can be provided using the abbreviations **GT** (greater than), **LT** (less than), **GTE** (greater than or equal to) and **LTE** (less than or equal to). For ranges with two limits, **::** is used as the delimiter.


        The general range format is:

        **[symbol-abbreviation][string/numeric-value]** [OR]

        **[symbol-abbreviation][string/numeric-value]::[symbol-abbreviation][string/numeric-value]**
      in: query
      required: false
      style: form
      explode: true
      schema:
        oneOf:
          - type: array
            items:
              type: string
          - type: string
      examples:
        numbersIDs:
          summary: Example of a list of numbers for IDs
          value: 1, 2, 3, 4
        rangeIDs:
          summary: Example of a range of IDs
          value: 'GTE1::LT5'
        mixedIDs:
          summary: Example of a mix of ranges and specific IDs
          value: 1, 2, 3, 4, 'GTE5::LTE10', 11, 12, 'GT13'

and yet it doesn't show in the UI with the "add item" button , shows in a text box. I have swagger 3.0.0

Thanks!

1 Reply

  • kawad1 The rendering of `oneOf` in query parameters as you expect is not currently supported in SwaggerUI. Feel free to register an issue at https://github.com/swagger-api/swagger-ui/issues

    However, based on your use case, you should achieve all that you need by just having the `deviceIds` as an array.

            - name: deviceIds
              in: query
              required: false
              style: form
              explode: true
              schema:
                type: array
                items:
                  type: string

    If you really want to have two separate schemas for a single string and an array of strings, then split into two parameters.

            - name: deviceId
              in: query
              description: "Single device ID"
              required: false
              schema:
                type: string
    
            - name: deviceIds
              in: query
              description: "Multiple device IDs"
              required: false
              style: form
              explode: true
              schema:
                type: array
                items:
                  type: string

    Hope this helps.