How to use the @loopback/openapi-v3.post function in @loopback/openapi-v3

To help you get started, we’ve selected a few @loopback/openapi-v3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strongloop / loopback-next / packages / authentication / src / __tests__ / acceptance / jwt-auth-extension.acceptance.ts View on Github external
it('authenticates successfully with valid token', async () => {
    class InfoController {
      constructor(
        @inject(JWTAuthenticationStrategyBindings.TOKEN_SERVICE)
        public tokenService: JWTService,
        @inject(USER_REPO)
        public users: UserRepository,
        @inject(AuthenticationBindings.USER_PROFILE_FACTORY)
        public userProfileFactory: UserProfileFactory,
      ) {}

      @post('/login')
      async logIn() {
        //
        // ...Other code for verifying a valid user (e.g. basic or local strategy)...
        //

        // Now with a valid userProfile, let's create a JSON web token
        return this.tokenService.generateToken(
          this.userProfileFactory(joeUser),
        );
      }

      @get('/whoAmI')
      @authenticate('jwt')
      whoAmI(@inject(SecurityBindings.USER) userProfile: UserProfile) {
        if (!userProfile) return 'userProfile is undefined';
        if (!userProfile[securityId])
github strongloop / loopback-next / packages / rest / src / __tests__ / unit / rest.server / rest.server.open-api-spec.unit.ts View on Github external
it('returns definitions inferred via app.controller()', () => {
    @model()
    class MyModel {
      @property()
      bar: string;
    }
    class MyController {
      @post('/foo')
      createFoo(@requestBody() foo: MyModel) {}
    }
    app.controller(MyController);

    const spec = server.getApiSpec();
    expect(spec.components && spec.components.schemas).to.deepEqual({
      MyModel: {
        title: 'MyModel',
        properties: {
          bar: {
            type: 'string',
          },
        },
        additionalProperties: false,
      },
    });
github strongloop / loopback-next / packages / rest / src / __tests__ / unit / rest.server / rest.server.open-api-spec.unit.ts View on Github external
},
      })
      .withResponse(200, {
        content: {
          'application/json': {
            schema: {
              type: 'object',
            },
          },
        },
        description: '',
      })
      .build();

    class MyController {
      @post('/show-body', expectedOpSpec)
      showBody(body: object) {
        return body;
      }
    }
    app.controller(MyController);

    const spec = server.getApiSpec();
    expect(spec.paths['/show-body'].post).to.containDeep(expectedOpSpec);
  });

@loopback/openapi-v3

Decorators that annotate LoopBack artifacts with OpenAPI v3 metadata and utilities that transform LoopBack metadata to OpenAPI v3 specifications

MIT
Latest version published 25 days ago

Package Health Score

95 / 100
Full package analysis