Open bekabaz opened 1 year ago
I'm interested in improving this but need some insights from maintainers 🙏
Right now all the extensions with key-value style is generated as string, otherwise true
... x-example=1,x-nullable
x-example: "1"
x-nullable: true
... x-example={"key": "value"},x-nullable
x-example: "{\"key\": \"value\"}"
x-nullable: true
I believe it generate everything as string because extension fields can be any types, but we lack the placeholder to declare the syntax.
I think there can be 2 solutions
x-example
automatically, by referring to the schema type
For example: with above case, account_id
is specified as int
. We can convert the x-example
value accordingly.x-author=John(string),x-example=1(int)
In either ways I can give a try 🙏
Hi, I'm dealing with this exact issue with the x-order
extension. My struct has more than 10 fields, so after specifying x-order=0
through x-order=9
, I started doing x-order=10
, etc. After init though, it immediately put that 10 in 2nd place because it's trying to sort the order by the string value rather than the expected int value lol.
Issue discussing how the x-order extension works: https://github.com/swaggo/swag/issues/715
Please let me know if I can assist. I think the best option would be to check whether the value contains only digits and auto-parse it to int. If not, maybe something simple like x-order=int(1)
would be intuitive and straightforward.
Describe the bug When setting an example for a path variable via
extensions(x-example=1)
the resulting Swagger doc containsx-example: "1"
even though the parameter is an integer.To Reproduce Here's an example path param definition:
Generate the swag docs, and you will find this in the swagger.yaml file:
Expected behavior I would expect this output:
Your swag version 1.8.12
Your go version go1.19.3 linux/amd64