Skip to content

Conversation

rvarunrathod
Copy link

@rvarunrathod rvarunrathod commented Feb 13, 2025

Describe the PR
Add new flag ExcludeFromUI, This will remove API and definitions from only doc.go file so it won't be visible on Swagger UI.

Additional context
Hi Team, For long time I wanted this feature which just remove API from UI, so users can't access it from UI, but it will be there in swagger.json/yaml so I can share this with other developers.

Usage:

// ShowAccount godoc
//
//	@Summary		Show an account
//	@Description	get string by ID
//	@Tags			accounts
//	@Accept			json
//	@Produce		json
//	@Param			id	path		int	true	"Account ID"
//	@Success		200	{object}	model.Account
//	@Failure		500	{object}	httputil.HTTPError
//	@Router			/accounts/{id} [get]
//      @x-hidden               true
go run cmd/swag/main.go init -d example/celler --excludeFromUI hidden

It will remove the API from UI which have this hidden annotation.

@sdghchj
Copy link
Member

sdghchj commented Mar 21, 2025

As I know, there is already a similar feature which uses Tags to filter.

@rvarunrathod
Copy link
Author

Tags will remove this API definitions from swagger.json also, here use case is only remove it from UI code.

@sdghchj
Copy link
Member

sdghchj commented Mar 24, 2025

Tags will remove this API definitions from swagger.json also, here use case is only remove it from UI code.

Sorry, I am confused why this feature needed?

@rvarunrathod
Copy link
Author

Hi @sdghchj, For long time I wanted this feature which just remove API from UI, so users can't access it from UI, but it will be there in swagger.json/yaml so I can share this with other developers.

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

Successfully merging this pull request may close these issues.

2 participants