gin-swagger icon indicating copy to clipboard operation
gin-swagger copied to clipboard

Array parameters with default values

Open aalong opened this issue 6 years ago • 1 comments

The code produced by this line of the Parameter template does not correctly handle default values of type Array, writing the array directly into the template with its values as raw text.

Example YML for a failing parameter:

        - name: Foo
          in: query
          description: >-
            A comma-delimited list of arbitrary values
          type: array
          items:
            type: string
          collectionFormat: csv
          default:
            - Bar
            - Bazz
            - Buzz

This produces the line: defValue := swag.SplitByFormat([Bar Bazz Buzz], "csv")

If I understand the default templates correctly, they seem to be using the JSON parser as a middle man to handle these cases. Would that work for this lib as well?

aalong avatar Mar 01 '18 01:03 aalong

This part of the templates are copied from go-swagger. Looks like this problem was fixed recently in: https://github.com/go-swagger/go-swagger/commit/95766d38e23b428e01b6d165b5947467d71f1c59

So we need to apply these changes to the template used here.

mikkeloscar avatar Mar 07 '18 18:03 mikkeloscar