swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.24k stars 1.17k forks source link

Include field in schema but hide from examples #1823

Open Ulrar opened 1 month ago

Ulrar commented 1 month ago

Is your feature request related to a problem? Please describe. I'd like to be able to keep specific fields in a struct as part of the schema, but hide / omit them from the generated examples.

Describe the solution you'd like Either have an explicit tag swaggerhide: true, or maybe just some logic to hide the field if the field's example tag is empty and json has omitempty ? Just a couple of ideas.

Describe alternatives you've considered For now I just swaggerignore, but that hides it from the schema too which isn't ideal.

Additional context This would allow technically documenting fields we have to support, without broadcasting their existence which could drive up their usage.

Apologies if that exists and I missed it, I did search and I also posted here.

novaldebbyp commented 3 weeks ago

I also need this feature maybe can change swaggerignore to int (default 0) mean show example and response 1 hide on example and response 2 only hide on example