Skip to content

Generating a spec from code for a full service #79

Closed Answered by vearutop
ppipada asked this question in Q&A
Discussion options

You must be logged in to vote

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 a go run ./cmd/gen-openapi.

In some cases it can be feasible to automate spec collection with route walking (examples for gorilla/mux and gin).

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.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ppipada
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants