-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swaggo's boolean params cause rendering errors in the UI #1307
Comments
If the body is a JSON payload, please explain how boolean should be marshaled. |
Worst case, just display it as text: https://www.w3schools.com/js/js_json_datatypes.asp |
How to solve it, I don't understand where the problem is |
Does anyone know how to solve this problem? |
I'm having the same issue with Any updates or ideas here? |
I just ran into this so I hope this helps someone in the future. The issue seems to be confusion around how to document a body parameter. Our model has 3 members and they were documented like this: // @Param ids body []string true "ids of objects"
// @Param labels body map[string]string true "labels to update"
// @Param overwrite body boolean false "overwrite labels if true" It produced reasonable documentation for the first 2 but when the boolean was added we encountered this error. It appears that the correct way is to document the body is as a single parameter like this: // @Param body body model.LabelsPayload true "request body containing ids and labels" And then where // @Description Body of the request to update labels
type LabelsPayload struct {
// IDs of objects
IDs []string `json:"ids" example:"agent1,agent2"`
// Labels to update
Labels map[string]string `json:"labels" example:"env:production,region:us-west-1,team:"`
// Overwrite labels if true
Overwrite bool `json:"overwrite"`
} |
I ran into same issue today. Any param with data type
Web browser reports error:
Change data type from
|
There can be only one body param. |
Describe the bug
I was attempting to add one field to my set of parameters as a boolean - for the data type I tried both
bool
andboolean
. If I change the same param to a string type, it renders without issue. When the field is set to bool, it causes the rendering of all parameters for that endpoint to fail to render.To Reproduce
Steps to reproduce the behavior:
@param hold_gateway_ip body bool (or boolean) false "comment"
swag init -d services/http,services/http/handlers -g http_server.go --parseInternal --parseDependency --md services/http/handlers
Expected behavior
I expect the parameter fields to render.
Screenshots
This screenshot is what it looks like when I use
bool
orboolean
and stops the whole set of params from renderingParams enders without issue when I change the type from
bool
tostring
If it's helpful, here's the rough stack trace. I'm happy to get more information if specifically directed, but I don't know much about javascript.
Your swag version
1.8.4 (latest as of writing)
Your go version
1.18.2 darwin/amd64
Desktop (please complete the following information):
Additional context
The error message in the UI is "could not render n, see the console"
The text was updated successfully, but these errors were encountered: