-
Hi, Do you support generating spec from code for a full service? General usecase is similar to the one that goswagger supports here: https://goswagger.io/generate/spec.html (doesnt support openapi 3, 3.1 and json schema) Basically: annotate actual go structs with comments and tags like you have specified here, run a go generate command and get a schema doc (yaml or json) out. The doc can be used in servers/clients etc as detailed in other places like swagest/rest, etc Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
There is no tool to read magic comments and generate the spec with their help. However, it is possible to write a helper app for a particular service, that would contain spec generation code. This helper app could then later be invoked via In some cases it can be feasible to automate spec collection with route walking (examples for So far, I don't have a good idea how spec generation can be implemented with a standalone tool. Magic comments might be an option, but I feel they lack precision and reliability, being very easy to misuse. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response. |
Beta Was this translation helpful? Give feedback.
There is no tool to read magic comments and generate the spec with their help.
However, it is possible to write a helper app for a particular service, that would contain spec generation code. This helper app could then later be invoked via
go generate
,make docs
or any other way that would call something like ago run ./cmd/gen-openapi
.In some cases it can be feasible to automate spec collection with route walking (examples for
gorilla/mux
andgin
).So far, I don't have a good idea how spec generation can be implemented with a standalone tool. Magic comments might be an option, but I feel they lack precision and reliability, being very easy to misuse.