How to use the @loopback/openapi-spec-builder.anOpenApiSpec function in @loopback/openapi-spec-builder

To help you get started, we’ve selected a few @loopback/openapi-spec-builder 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 / benchmark / src / rest-routing / routing-table.ts View on Github external
function givenNumberOfRoutes(base: string, num: number) {
  const spec = anOpenApiSpec();
  let i = 0;
  while (i < num) {
    // Add 1/4 paths with vars
    if (i % 4 === 0) {
      spec.withOperationReturningString(
        'get',
        `${base}/group${i}/{version}`,
        `greet${i}`,
      );
    } else {
      spec.withOperationReturningString(
        'get',
        `${base}/group${i}/version_${i}`,
        `greet${i}`,
      );
    }
github strongloop / loopback-next / packages / openapi-v3 / src / __tests__ / unit / decorators / operation.decorator.unit.ts View on Github external
it('returns spec defined via @api()', () => {
    const expectedSpec = anOpenApiSpec()
      .withOperationReturningString('get', '/greet', 'greet')
      .build();

    @api(expectedSpec)
    class MyController {
      greet() {
        return 'Hello world!';
      }
    }

    const actualSpec = getControllerSpec(MyController);
    expect(actualSpec).to.eql(expectedSpec);
  });
github strongloop / loopback-next / packages / rest / src / __tests__ / unit / rest.server / rest.server.open-api-spec.unit.ts View on Github external
it('preserves routes specified in app.api()', () => {
    function status() {}
    server.api(
      anOpenApiSpec()
        .withOperation('get', '/status', {
          'x-operation': status,
          responses: {},
        })
        .build(),
    );

    function greet() {}
    server.route('get', '/greet', {responses: {}}, greet);

    const spec = server.getApiSpec();
    expect(spec.paths).to.eql({
      '/greet': {
        get: {
          responses: {},
        },
github strongloop / loopback-next / packages / rest / src / __tests__ / unit / router / routing-table.unit.ts View on Github external
it('finds simple "GET /hello/world" endpoint', () => {
    const spec = anOpenApiSpec()
      .withOperationReturningString('get', '/hello/{msg}', 'greet')
      .withOperationReturningString('get', '/hello/world', 'greetWorld')
      .build();

    class TestController {}

    const table = givenRoutingTable();
    table.registerController(spec, TestController);

    const request = givenRequest({
      method: 'get',
      url: '/hello/world',
    });

    const route = table.find(request);
    expect(route)
github strongloop / loopback-next / packages / rest / src / __tests__ / acceptance / sequence / sequence.acceptance.ts View on Github external
async function givenAppWithController() {
    await givenAnApplication();
    app.bind('application.name').to('SequenceApp');

    const apispec = anOpenApiSpec()
      .withOperation('get', '/name', {
        'x-operation-name': 'getName',
        responses: {
          '200': {
            schema: {
              type: 'string',
            },
            description: '',
          },
        },
      })
      .build();

    @api(apispec)
    class InfoController {
      constructor(@inject('application.name') public appName: string) {}
github strongloop / loopback-next / labs / authentication-passport / src / __tests__ / acceptance / authentication-with-passport-strategy-adapter.acceptance.ts View on Github external
function givenControllerInApp() {
    const apispec = anOpenApiSpec()
      .withOperation('get', '/whoAmI', {
        'x-operation-name': 'whoAmI',
        responses: {
          '200': {
            description: '',
            schema: {
              type: 'string',
            },
          },
        },
      })
      .build();

    @api(apispec)
    class MyController {
      constructor(
github strongloop / loopback-next / extensions / authentication-passport / src / __tests__ / acceptance / authentication-with-passport-strategy-adapter.acceptance.ts View on Github external
function givenControllerInApp() {
    const apispec = anOpenApiSpec()
      .withOperation('get', '/whoAmI', {
        'x-operation-name': 'whoAmI',
        responses: {
          '200': {
            description: '',
            schema: {
              type: 'string',
            },
          },
        },
      })
      .build();

    @api(apispec)
    class MyController {
      constructor(@inject(SecurityBindings.USER) private user: UserProfile) {}
github strongloop / loopback-next / packages / authentication / src / __tests__ / acceptance / basic-auth-extension.acceptance.ts View on Github external
function givenControllerInApp() {
    const apispec = anOpenApiSpec()
      .withOperation('get', '/whoAmI', {
        'x-operation-name': 'whoAmI',
        responses: {
          '200': {
            description: '',
            schema: {
              type: 'string',
            },
          },
        },
      })
      .build();

    @api(apispec)
    class MyController {
      constructor() {}
github strongloop / loopback-next / packages / authentication / src / __tests__ / acceptance / basic-auth.acceptance.ts View on Github external
function givenControllerInApp() {
    const apispec = anOpenApiSpec()
      .withOperation('get', '/whoAmI', {
        'x-operation-name': 'whoAmI',
        responses: {
          '200': {
            description: '',
            schema: {
              type: 'string',
            },
          },
        },
      })
      .build();

    @api(apispec)
    class MyController {
      constructor(

@loopback/openapi-spec-builder

Make it easy to create OpenAPI (Swagger) specification documents in your tests using the builder pattern.

MIT
Latest version published 2 months ago

Package Health Score

84 / 100
Full package analysis