JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q28900F
  • License MIT

Processes openapi v2 related metadata

Package Exports

  • @loopback/openapi-v2

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@loopback/openapi-v2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@loopback/openapi-v2

This package contains:

  • Decorators that describe LoopBack artifacts as OpenAPI v2 (Swagger) metadata.
  • Utilities that transfer LoopBack metadata to OpenAPI v2 (Swagger) swagger specifications.

Overview

The package has functions described above for LoopBack controller classes. Decorators apply REST api mapping metadata to controller classes and their members. And utilities that inspect controller classes to build OpenAPI v2 (Swagger) specifications from REST api mapping metadata.

Functions for more artifacts will be added when we need.

Installation

$ npm install --save @loopback/openapi-v2

Basic use

Currently this package only has spec generator for controllers. It generates swagger paths and basePath specs for a given decorated controller class.

Here is an example of calling function getControllerSpec to generate the swagger spec:

import {api, getControllerSpec} from '@loopback/openapi-v2';

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

const myControllerSpec = getControllerSpec(MyController);

then the myControllerSpec will be:

{
    swagger: '2.0',
    basePath: '/',
    info: { title: 'LoopBack Application', version: '1.0.0' },
    paths: { 
        '/greet': { 
            get: {
                responses:  { 
                    '200': { 
                        description: 'The string result.', 
                        schema: { type: 'string' } 
                    } 
                },
                'x-operation-name': 'greet' 
            }
        } 
    } 
}

For details of how to apply controller decorators, please check http://loopback.io/doc/en/lb4/Decorators.html#route-decorators

See https://www.openapis.org/ and version 2.0 of OpenAPI Specification.

Contributions

IBM/StrongLoop is an active supporter of open source and welcomes contributions to our projects as well as those of the Node.js community in general. For more information on how to contribute please refer to the Contribution Guide.

Tests

run npm test from the root folder.

Contributors

See all contributors.

License

MIT