gin-swagger
gin-swagger copied to clipboard
Array parameters with default values
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?
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.