Skip to content
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

A way to override default example #110

Open
HermanPierre opened this issue Feb 5, 2024 · 0 comments
Open

A way to override default example #110

HermanPierre opened this issue Feb 5, 2024 · 0 comments

Comments

@HermanPierre
Copy link

HermanPierre commented Feb 5, 2024

Hello,
I am currently writing my API swagger doc so for example on this route:

router.GET("/tl/:id", []fizz.OperationOption{
		fizz.ID("get_by_id"),
		fizz.Description("Get by its id."),
		fizz.Response("200",
			"Example of a successful call by id.<br>",
			dedicated.TlResponse{}, nil, GetByIdSuccessExemple),
	}, tonic.Handler(handler.GetById, http.StatusOK))

But if do that I get an error because examples for status 200 are already generated by tonic, so I've added example tags to my response struct:
image
image

but some fields of my struct are type interface{} because I can't know the exact type of object I'm getting from my API.
So if I use the example tag on an interface{} type, in my swaggers the example for this field says "string"
image

But it's not clear for someone who reads this and don't know the project, so I tried using the fizz.Response on another status and I can put some object example values in those interface{} fields...
I could use "default" status code but I think its still not clear in the swagger to have status 200 example with "string" for a field and under it, having an object for the same field :/

Is their a way to override the 200 status/default example ?
Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant