Skip to content
This repository has been archived by the owner on Jan 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #110 from tlivings/master
Browse files Browse the repository at this point in the history
use hapi-openapi instead of swaggerize-hapi
  • Loading branch information
tlivings committed Apr 28, 2018
2 parents 5994499 + 65a3e06 commit cef4441
Show file tree
Hide file tree
Showing 8 changed files with 5,409 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
# v4.1.0

- Use `hapi-openapi` instead of `swaggerize-hapi`.

# v4.0.0

- Support latest swaggerize-hapi.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -13,7 +13,7 @@ Generates projects for:

See also:
- [swaggerize-express](https://github.com/krakenjs/swaggerize-express)
- [swaggerize-hapi](https://github.com/krakenjs/swaggerize-hapi)
- [hapi-openapi](https://github.com/krakenjs/hapi-openapi) (formerly `swaggerize-hapi`)

### Usage

Expand Down
6 changes: 3 additions & 3 deletions generators/app/templates/hapi/server.js
@@ -1,14 +1,14 @@
'use strict';

const Hapi = require('hapi');
const Swaggerize = require('swaggerize-hapi');
const HapiOpenAPI = require('hapi-openapi');
const Path = require('path');

const init = async function() {
const server = new Hapi.Server();

await server.register({
plugin: Swaggerize,
plugin: HapiOpenAPI,
options: {
api: Path.resolve('<%=apiPathRel.replace(/\\/g,'/')%>'),
handlers: Path.resolve('<%=handlerPath.replace(/\\/g,'/')%>')
Expand All @@ -21,7 +21,7 @@ const init = async function() {
};

init().then((server) => {
server.plugins.swagger.setHost(server.info.host + ':' + server.info.port);
server.plugins.openapi.setHost(server.info.host + ':' + server.info.port);

server.log(['info'], `Server running on ${server.info.host}:${server.info.port}`);
});
2 changes: 1 addition & 1 deletion generators/app/templates/package.json
Expand Up @@ -18,7 +18,7 @@
"swaggerize-express": "^4.0.0"<%}%><% if (framework === 'hapi') {%>
"hapi": "^17.0.0",
"boom": "^7.1.1",
"swaggerize-hapi": "^4.1.0-"<%}%><% if (framework === 'restify') {%>
"hapi-openapi": "^1.0.0"<%}%><% if (framework === 'restify') {%>
"swaggerize-restify": "^2.0.0",
"restify": "^3.0.3"<%}%><% if (framework !== 'hapi') {%>,
"swagmock": "~0.0.2"<%}%>
Expand Down
8 changes: 4 additions & 4 deletions generators/test/templates/hapi/test.js
Expand Up @@ -2,15 +2,15 @@

const Test = require('tape');
const Hapi = require('hapi');
const Swaggerize = require('swaggerize-hapi');
const HapiOpenAPI = require('hapi-openapi');
const Path = require('path');
const Mockgen = require('<%=mockgenPath.replace(/\\/g,'/')%>');

/**
* Test for <%=path%>
*/
Test('<%=path%>', function (t) {

<%operations.forEach(function (operation, i) {
const mt = operation.method.toLowerCase();
%>/**
Expand All @@ -25,7 +25,7 @@ Test('<%=path%>', function (t) {
const server = new Hapi.Server();

await server.register({
plugin: Swaggerize,
plugin: HapiOpenAPI,
options: {
api: Path.resolve(__dirname, '<%=apiPathRel.replace(/\\/g,'/')%>'),
handlers: Path.join(__dirname, '<%=handlerDir.replace(/\\/g,'/')%>'),
Expand Down Expand Up @@ -66,7 +66,7 @@ Test('<%=path%>', function (t) {
if (mock.request.headers && mock.request.headers.length > 0) {
options.headers = mock.request.headers;
}

const response = await server.inject(options);

t.equal(response.statusCode, <%=(operation.response === 'default') ? 200 : operation.response%>, 'Ok response status');
Expand Down

0 comments on commit cef4441

Please sign in to comment.