# @hapiness/swag

> Generate swag documentation for Hapiness' components

Latest version **1.2.0** (published 2018-05-07) · SEE LICENSE IN https://github.com/hapinessjs/swag-module/blob/master/LICENSE.md license · 0 weekly downloads

## Install

```sh
npm install @hapiness/swag
pnpm add @hapiness/swag
yarn add @hapiness/swag
bun add @hapiness/swag
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2018-05-07 |
| First published | 2017-06-09 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN https://github.com/hapinessjs/swag-module/blob/master/LICENSE.md |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 5 |
| Unpacked size | 14.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | hapiness |
| Keywords | HapiJS, Hapi, Hapiness, Framework, NodeJS, Node, HTTP, API, REST, Streams, Async, Decorator, RxJS, Rx, ReactiveX, Observable, Observer, Module, ES2015, ES2016, ES2017, ES6, ES7, ES8, Typescript, Swagger, Documenation |

## Links

- npm: https://www.npmjs.com/package/@hapiness/swag
- Repository: https://github.com/hapinessjs/swag-module
- Homepage: https://github.com/hapinessjs/swag-module#readme
- Issues: https://github.com/hapinessjs/swag-module/issues
- npm.io page: https://npm.io/package/@hapiness/swag

## Dependencies (5)

- [debug](https://npm.io/package/debug.md) ^3.1.0
- [inert](https://npm.io/package/inert.md) ^4.2.1
- [vision](https://npm.io/package/vision.md) ^4.1.1
- [@types/node](https://npm.io/package/@types/node.md) ^9.0.0
- [@reptilbud/hapi-swagger](https://npm.io/package/@reptilbud/hapi-swagger.md) ^2.1.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2018-05-07
- 1.1.0 — 2017-11-20
- 1.0.0 — 2017-10-27
- 1.0.0-rc.7 — 2017-10-02
- 1.0.0-rc.6 — 2017-07-19
- 1.0.0-rc.4 — 2017-07-11
- 1.0.0-beta.6 — 2017-06-09

## README

<img src="http://bit.ly/2mxmKKI" width="500" alt="Hapiness" />

<div style="margin-bottom:20px;">
<div style="line-height:60px">
    <a href="https://travis-ci.org/hapinessjs/swag-module.svg?branch=master">
        <img src="https://travis-ci.org/hapinessjs/swag-module.svg?branch=master" alt="build" />
    </a>
    <a href="https://coveralls.io/github/hapinessjs/swag-module?branch=master">
        <img src="https://coveralls.io/repos/github/hapinessjs/swag-module/badge.svg?branch=master" alt="coveralls" />
    </a>
    <a href="https://david-dm.org/hapinessjs/swag-module">
        <img src="https://david-dm.org/hapinessjs/swag-module.svg" alt="dependencies" />
    </a>
    <a href="https://david-dm.org/hapinessjs/swag-module?type=dev">
        <img src="https://david-dm.org/hapinessjs/swag-module/dev-status.svg" alt="devDependencies" />
    </a>
</div>
<div>
    <a href="https://www.typescriptlang.org/docs/tutorial.html">
        <img src="https://cdn-images-1.medium.com/max/800/1*8lKzkDJVWuVbqumysxMRYw.png"
             align="right" alt="Typescript logo" width="50" height="50" style="border:none;" />
    </a>
    <a href="http://reactivex.io/rxjs">
        <img src="http://reactivex.io/assets/Rx_Logo_S.png"
             align="right" alt="ReactiveX logo" width="50" height="50" style="border:none;" />
    </a>
    <a href="http://hapijs.com">
        <img src="http://bit.ly/2lYPYPw"
             align="right" alt="Hapijs logo" width="75" style="border:none;" />
    </a>
</div>
</div>

# Swag Module

`Swag` module for the [Hapiness](https://github.com/hapinessjs/hapiness).

## Table of contents

* [Using your module inside Hapiness application](#using-your-module-inside-hapiness-application)
    * [Yarn or NPM it in your package.json](#yarn-or-npm-it-in-your-packagejson)
    * [Import SwagModule from the library](#import-swagmodule-from-the-library)
* [Add documentation to your routes](#add-documentation-to-your-routes)
* [Contributing](#contributing)
* [Change History](#change-history)
* [Maintainers](#maintainers)
* [License](#license)

## Using your module inside Hapiness application

### `yarn` or `npm` it in your `package.json`

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

or

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

### import `SwagModule` from the library

```javascript
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](#table-of-contents)

## 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](https://github.com/reptilbud/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](#table-of-contents)

## 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](#table-of-contents)

## 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](#table-of-contents)

## Maintainers

<table>
    <tr>
        <td colspan="4" align="center"><a href="https://www.tadaweb.com"><img src="http://bit.ly/2xHQkTi" width="117" alt="tadaweb" /></a></td>
    </tr>
    <tr>
        <td align="center"><a href="https://github.com/Juneil"><img src="https://avatars3.githubusercontent.com/u/6546204?v=3&s=117" width="117"/></a></td>
        <td align="center"><a href="https://github.com/antoinegomez"><img src="https://avatars3.githubusercontent.com/u/997028?v=3&s=117" width="117"/></a></td>
        <td align="center"><a href="https://github.com/reptilbud"><img src="https://avatars3.githubusercontent.com/u/6841511?v=3&s=117" width="117"/></a></td>
        <td align="center"><a href="https://github.com/njl07"><img src="https://avatars3.githubusercontent.com/u/1673977?v=3&s=117" width="117"/></a></td>
    </tr>
    <tr>
        <td align="center"><a href="https://github.com/Juneil">Julien Fauville</a></td>
        <td align="center"><a href="https://github.com/antoinegomez">Antoine Gomez</a></td>
        <td align="center"><a href="https://github.com/reptilbud">Sébastien Ritz</a></td>
        <td align="center"><a href="https://github.com/njl07">Nicolas Jessel</a></td>
    </tr>
</table>

[Back to top](#table-of-contents)

## License

Copyright (c) 2017 **Hapiness** Licensed under the [MIT license](https://github.com/hapinessjs/empty-module/blob/master/LICENSE.md).

[Back to top](#table-of-contents)

---
_Source: https://npm.io/package/@hapiness/swag · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
