Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for route are not being created #1736

Closed
KevM opened this issue Jan 10, 2024 · 2 comments
Closed

Docs for route are not being created #1736

KevM opened this issue Jan 10, 2024 · 2 comments

Comments

@KevM
Copy link

KevM commented Jan 10, 2024

Generating docs for a Gin web application work great but today I added a new set of routes and one of them is not being added to the docs. I am not sure how best to diagnose this problem. It feels like the scanner is ignoring the troubled project file /cmd/server/handlers/portfolio/get_portfolio_by_id.go while other sibling files are found without problem e.g get_portfolio.go in the same folder.

Swag version: v1.16.2
Go version: 1.21.5
OS: macOS Sonoma 14.2.1

Reproduce

In a typical Gin web application, I build the docs with this command:
swag init --parseDependency --parseDepth 3 -o ./docs -g ./main.go

Details

Looking at the swagger.yaml and no docs are present for one of our new routes. In the same project folder, there are many routes properly generated. Worried that it was some spacing issue. I copied the comments from a working route and edited only the relevant details. No luck. I tried to include Just the title and summary and Id with no luck. It feels like the scanner is skipping this file for some reason.

Route document comments

filepath of the non-working route: /cmd/server/handlers/portfolio/get_portfolio_by_id.go

// Get Portfolio By Id
//
//	@Summary GET Portfolio
//	@ID getPortfolioByUser
//	@Tags portfolios
//	@Description Retrieve user portfolio by id
//	@Produce json
//	@Param userId path string true "User who owns the portfolio"
//	@Param portfolioId path string	true "Portfolio Id to be returned"
//	@Success 200 {object} sdk.Portfolio "Portfolio"
//	@Failure 400 {object} error "missing argument"
//	@Failure 403 {object} error "JWT is likely expired"
//	@Failure 500 {object}	error
//	@Router	/user/{userId}/portfolios/{portfolioId} [PUT]
func GetPortfolio(c *gin.Context) {
	sUserId := c.Param("userId")
	userId, err := uuid.Parse(sUserId)
	if err != nil {
		auth_middleware.BadRequestError(c, fmt.Errorf("userid should be a uuid. Error: %w", err))
		return
	}
   // ....
}
@KevM
Copy link
Author

KevM commented Jan 10, 2024

Heads up. My colleague ran the docs gen on his computer and did not have this problem. So I guess this is a my box issue but I have no idea why.

@KevM
Copy link
Author

KevM commented Jan 10, 2024

Closing as this problem seems to have disappeared. Likely user error or another tangential problem that was resolved.

@KevM KevM closed this as completed Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant