Dynamically generate "examples" #1865
Replies: 1 comment
-
|
This is exactly my problem. I am using Fiber with a custom handler to emit the JSON for a My "workaround" is not really correct or satisfying because it has consequences that I don't like. What I did was created a "mirror" struct that had the same definition, just to provide the different example for each. While this solves the problem of generating the example output the way I want, this also means I'm generating new schema types when it's really the same object. Also, it makes it redundant because the code always matches the name. So if any generators create a client based on this, it will seem unnecessary, confusing, and poorly done. 🙃 What I really need is exactly what's being called for here. I need to be able to specify the response type as |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Imagine that we have the following Error response when there is an error in our application
When I generate the documentation with swag, I get a "proper" example in swagger.
But now I want to reuse that ErrorResponse for different error scenarios, and I want to use a different "example"
But I can't have different "examples" for the same Go struct. What I am doing right now, it's to create different structs to cover the different examples that I want to show.
So, something like this:
But, is it possible to do it in a different way? Is it possible to dynamically generate the examples in any way?
Beta Was this translation helpful? Give feedback.
All reactions