Reputation: 912
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.
Upvotes: 2
Views: 612
Reputation: 2806
I know this is an older thread, but I came across it in a search and discovered there is a different (better?) way to handle this situation. The @loopback/rest import grants access to 2 objects that can achieve what OP requires. oas and visibility
import { get, oas, visibility } from '@loopback/rest';
//method using oas
@get('/test')
@oas.visibility(OperationVisibility.UNDOCUMENTED)
@response(200, {
description: 'Whatever the test is',
content: {'application/json': {schema: TestSchema}},
})
async test() {
//code
}
//method using visibility
@get('/test2')
@visibility(OperationVisibility.UNDOCUMENTED)
@response(200, {
description: 'Whatever the test2 is',
content: {'application/json': {schema: TestSchema2}},
})
async test2() {
//code
}
You can actually use the oas namespace for your whole API spec if you wanted to as it encompasses all of the OpenApi decorators needed
Documentation: https://loopback.io/doc/en/lb4/Decorators_openapi.html#shortcuts-for-the-openapi-spec-oas-objects
Upvotes: 1
Reputation: 236
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:
Upvotes: 5