question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@ApiHideProperty on crud param still showing up in swagger doc

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
darrenjenningscommented, May 21, 2020

@zMotivat0r sorry still new to the framework, so was not immediately obvious that persist is able to handle this.

1reaction
darrenjenningscommented, May 20, 2020

@zMotivat0r wow thank you so much… this makes way more sense and works perfectly.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found