@ApiHideProperty on crud param still showing up in swagger doc
See original GitHub issueI am trying to use @ApiHideProperty()
for swagger docs https://docs.nestjs.com/recipes/swagger#decorators but a param is always showing up because it is specified in the Crud decorator. My configuration:
@OrganizationGuard
@Crud({
model: {
type: ServicePackage
},
params: {
organization: { // field I want to hide from docs
field: 'org',
type: 'string'
},
...
}
...
})
This is so that I can filter the ServicePackage
entity by organization, but this param is provided by @OrganizationGuard
which intercepts requests and adds the organization
param to the request before Crud executes the query.
@Injectable()
export class OrganizationGuard implements CanActivate {
canActivate (context: ExecutionContext): boolean {
const request = context.switchToHttp().getRequest()
if (request?.user?.org?.id) {
request.params.organization = request.user.org.id
return true
}
return false
}
This means that the endpoints must have organization
required, but I want to communicate to the docs that it is not required.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
ApiHideProperty on crud param still showing up in swagger doc
This means that the endpoints must have organization required, but I want to communicate to the docs that it is not required. Update...
Read more >How to hide property from displaying in Swagger? · Issue #1230
I am using .NET Core 2.2. [DataContract] ends up showing all members anyway; marking attribute as 'internal' or [JsonIgnore] doesn't deserialize ...
Read more >NestJS swagger generated docs do not show param information
It appears as though my custom decorator @RouteLogger() was in some way conflicting with the swagger doc generation.
Read more >Configuration - Swagger Documentation
Swagger UI accepts configuration parameters in four locations. ... Controls how the model is shown when the API is first rendered. (The user...
Read more >OpenAPI (Swagger) | NestJS - A progressive Node.js framework
It accepts: The path to mount the Swagger UI; An application instance; The document object instantiated above; Optional configuration parameter (read more here)....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@zMotivat0r sorry still new to the framework, so was not immediately obvious that persist is able to handle this.
@zMotivat0r wow thank you so much… this makes way more sense and works perfectly.