node.jstypescriptloopbackopenapiloopback4

How to hide open-api spec for one route using loopback 4


Is there a way in Loopback 4 to use the @get() decorator (or any another one), passing the path but not generating the open api spec for this route?
By passing a special param / using the @operation or anything?
Thank you.


Solution

  • There is an undocumented spec option 'x-visibility': 'undocumented' for the operation decorators @get, @post, etc. which might fit your needs. Here is an simplified example:

    @get('/test', {
      responses: {},
      'x-visibility': 'undocumented',
    })
    async test() {
      // business logic
    }
    

    Here are some references where it is used: