Loopback-next: Authorized button in docs

Created on 27 May 2020  路  5Comments  路  Source: strongloop/loopback-next

So I was trying to get the Authorized button
image
So I look at this docs https://loopback.io/doc/en/lb4/Authentication-Tutorial.html So On getting scroll down they mention to import the import {SECURITY_SCHEME_SPEC} from './utils/security-spec'; and
image
for more refer the this file But there is no such import and moreover when I check the security-spec.ts in the utils folder there is nothing with SECURITY_SCHEME_SPEC. Here

I resolve this error by the direct import of the SECURITY_SCHEME_SPEC

import {SECURITY_SCHEME_SPEC} from '@loopback/authentication-jwt';

Please let me know what's the problem here. wether I am doing it wrong or bug in docs.

Docs bug

All 5 comments

@HrithikMittal, from my understanding, there's a change that will enable the Authorize button out of the box (no code change), but this has not been released yet. @jannyHou, could you please confirm that?

In the meanwhile, what you can do is go to src/application.ts.

  1. Add this function
addSecuritySpec(): void {
    this.api({
      openapi: '3.0.0',
      info: {
        title: 'test application',
        version: '1.0.0',
      },
      paths: {},
      components: {securitySchemes: SECURITY_SCHEME_SPEC},
      security: [
        {
          // secure all endpoints with 'jwt'
          jwt: [],
        },
      ],
      servers: [{url: '/'}],
    });
  }
  1. Inside the constructor of the Application class, add this line to call the newly added function:
this.addSecuritySpec();

Hope it helps.

I have the following import statement:

import {
  JWTAuthenticationComponent,
  SECURITY_SCHEME_SPEC,
  UserServiceBindings,
} from '@loopback/authentication-jwt';

@dhmlau yes i am doing it in this way only but i was just asking and updating you that there is a bug in docs. Please update it because it create a lot of confusion for us means developers.

Using the latest release (we just published few hours ago), this issue no longer exist. It happened because both the documentation and the related code changes are in master but they are not released yet.

@dhmlau Thank you

Was this page helpful?
0 / 5 - 0 ratings