@hapiness/swag
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

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

Package Sidebar

Install

npm i @hapiness/swag

Weekly Downloads

3

Version

1.2.0

License

SEE LICENSE IN https://github.com/hapinessjs/swag-module/blob/master/LICENSE.md

Unpacked Size

15.1 kB

Total Files

12

Last publish

Collaborators

  • hapiness