JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q33218F
  • License SEE LICENSE IN https://github.com/hapinessjs/swag-module/blob/master/LICENSE.md

Generate swag documentation for Hapiness' components

Package Exports

  • @hapiness/swag

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 (@hapiness/swag) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Hapiness

Swag Module

Swag module for the Hapiness.

Table of contents

Using your module inside Hapiness application

yarn or npm it in your package.json

$ npm install --save @hapiness/core @hapiness/swag rxjs

or

$ yarn add @hapiness/core @hapiness/swag rxjs
"dependencies": {
    "@hapiness/core": "^1.2.2",
    "@hapiness/swag": "^1.1.0",
    //...
}
//...

import SwagModule from the library

import { Hapiness, HapinessModule, HttpServerExt, Route, OnGet } from '@hapiness/core';
import { SwagModule } from '@hapiness/swag';
@Route({
  method: 'GET',
  path: '/todo',
  config: {
    plugins: {
        'hapi-swagger': {
            'x-custom-values': {
              'scope': 'todo.read',
            },
            'x-toto': 'tata'
        }
    },
    description: 'Get todo',
    notes: 'Returns todo item',
    tags: ['api', 'todo']
  }
})
class GetTodo implements OnGet {
  onGet(request, reply) {
    reply('I am a todo');
  }
}

@HapinessModule({
  version: '1.0.0',
  imports: [
    SwagModule.setConfig({ info: { title: 'Todo Service' } })
  ],
  declarations: [ GetTodo ]
})
class HapinessModuleApp {

}

Hapiness.bootstrap(HapinessModuleApp, [
    HttpServerExt.setConfig({ host: '0.0.0.0', port: 4443 })
]);

Back to top

Add documentation to your routes

To get a complete list of allowed configuration for your route, you can follow what has been there hapi-swagger

To get the JSON format of your documentation, just go to the url YOUR_SERVICE_HOST:YOUR_SERVICE_PORT/swagger.json

To access the swagger interface of your documented endpoints, just go to the url YOUR_SERVICE_HOST:YOUR_SERVICE_PORT/documentation and you will be able to test them

Back to top

Contributing

To set up your development environment:

  1. clone the repo to your workspace,
  2. in the shell cd to the main folder,
  3. hit npm or yarn install,
  4. run npm or yarn run test.
    • It will lint the code and execute all tests.
    • The test coverage report can be viewed from ./coverage/lcov-report/index.html.

Back to top

Change History

  • v1.1.0 (2017-11-20)
    • Latest packages' versions.
    • Documentation.
    • Change packaging process.
  • v1.0.0 (2017-10-27)
    • Add possibility to have x-* as values
    • Documentation
    • First stable version

Back to top

Maintainers

tadaweb
Julien Fauville Antoine Gomez Sébastien Ritz Nicolas Jessel

Back to top

License

Copyright (c) 2017 Hapiness Licensed under the MIT license.

Back to top