swaggo / swag

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

Generate schema.example based on golang struct and x-example extensions tags #1731

Closed LukasDeco closed 8 months ago

LukasDeco commented 8 months ago

Is your feature request related to a problem? Please describe. I want the schema.example for the swagger.yaml and possibly swagger.json to be automatically generated based on extension tags. This would allow for some really nice applications with the Dredd swagger testing framework. It uses this field to automatically build request bodies. Right now, I would have to manually write these schema.example bodies. And I think it would be much neater to just write the x-example extensions and have swaggo/swag do the rest.

Describe the solution you'd like I want the schema.example for the swagger.yaml and possibly swagger.json to be automatically generated based on extension tags.

Describe alternatives you've considered Manually typing out the json

Additional context I can submit an MR! Or if this feature already exists, then that's cool too!

LukasDeco commented 8 months ago

Actually, after examining the code I see that you can just use the example struct tag to accomplish something very similar that Dredd supports. I will close.