Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-swagger

Package Overview
Dependencies
Maintainers
1
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-swagger - npm Package Compare versions

Comparing version 7.5.0 to 7.6.0

.editorconfig

2

examples/dot-grouping.js

@@ -96,3 +96,3 @@ 'use strict';

// Add a versioned route - which is actually two routes with prefix '/v1' and '/v2'. Not only the
// handlers are different, but also the route defintion itself (like here with response validation).
// handlers are different, but also the route definition itself (like here with response validation).
server.route({

@@ -99,0 +99,0 @@ method: 'GET',

@@ -131,3 +131,3 @@ 'use strict';

// Add a versioned route - which is actually two routes with prefix '/v1' and '/v2'. Not only the
// handlers are different, but also the route defintion itself (like here with response validation).
// handlers are different, but also the route definition itself (like here with response validation).
server.route({

@@ -134,0 +134,0 @@ method: 'GET',

@@ -47,2 +47,3 @@ 'use strict';

tags: Joi.any(),
cors: Joi.boolean(),
externalDocs: Joi.object({

@@ -246,3 +247,4 @@ description: Joi.string(),

'pathReplacements',
'log'
'log',
'cors'
].forEach((element) => {

@@ -249,0 +251,0 @@

@@ -149,3 +149,3 @@ 'use strict';

/**
* returns weather a collection already has a definition, returns key if found
* returns whether a collection already has a definition, returns key if found
*

@@ -152,0 +152,0 @@ *

@@ -38,2 +38,3 @@ 'use strict';

connectionLabel: Joi.array().items(Joi.string()).single().allow(null),
cors: Joi.boolean(),
pathReplacements: Joi.array().items(Joi.object({

@@ -96,2 +97,3 @@ replaceIn: Joi.string().valid(['groups', 'endpoints', 'all']),

auth: settings.auth,
cors: settings.cors,
handler: (request, reply) => {

@@ -195,3 +197,3 @@

method: 'GET',
path: settings.documentationPath + Path.sep + 'debug',
path: Path.join(settings.documentationPath, Path.sep, 'debug').split(Path.sep).join('/'),
config: {

@@ -198,0 +200,0 @@ auth: settings.auth

@@ -182,5 +182,6 @@ 'use strict';

let method = route.method;
let path = internals.removeBasePath(route.path, this.settings.basePath, this.settings.pathReplacements);
let out = {
'summary': route.description,
'operationId': route.id || Utilities.createId(route.method, route.path),
'operationId': route.id || Utilities.createId(route.method, path),
'description': route.notes,

@@ -191,3 +192,2 @@ 'parameters': [],

};
let path = internals.removeBasePath(route.path, this.settings.basePath, this.settings.pathReplacements);

@@ -194,0 +194,0 @@ // tags in swagger are used for grouping

@@ -1,2 +0,2 @@

# 7.2.0 Options Reference
# 7.6.0 Options Reference

@@ -8,3 +8,4 @@ ## Plugin Options

* `host`: (string) The host (name or IP) serving the API including port if any i.e. `localhost:8080`
* `auth`: (boolean, string or object) defines security strategy to use for plugin resouces - default: `false`,
* `auth`: (boolean, string or object) defines security strategy to use for plugin resources - default: `false`,
* `cors`: (boolean) weather the swagger.json routes is servered with cors support - default: `false`,
* `connectionLabel`: (string) A label used to document an API on a different HAPI server connection

@@ -17,3 +18,3 @@

* `pathPrefixSize`: (number) Selects what segment of the URL path is used to group endpoints - default: `1`
* `pathReplacements` : (array) methods for modifing path and group names in documenetation - default: `[]`
* `pathReplacements` : (array) methods for modifying path and group names in documentation - default: `[]`
* `info`

@@ -63,7 +64,7 @@ * `title` (string) The title of the application - default: `API documentation`

* `query` : (JOI object) allows you to `query` route documentation outside of HAPI validation
* `haeders` : (JOI object) allows you to `haeders` route documentation outside of HAPI validation
* `headers` : (JOI object) allows you to `headers` route documentation outside of HAPI validation
* `payload` : (JOI object) allows you to `payload` route documentation outside of HAPI validation
* `security` : Hoek.reach(routeOptions, 'security') || null,
* `order`: (int) The order in which endpoints are displayed, works with options.sortEndpoints = 'ordered'
* `deprecated`: (boolean) Weather a endpoint has been deprecated - default: false
* `deprecated`: (boolean) Whether a endpoint has been deprecated - default: false

@@ -137,3 +138,3 @@

payload: {
a: Joi.number().required().description('thefirstnumber')
a: Joi.number().required().description('the first number')
}

@@ -140,0 +141,0 @@ }

{
"name": "hapi-swagger",
"description": "A swagger documentation UI generator plugin for hapi",
"version": "7.5.0",
"version": "7.6.0",
"author": "Glenn Jones",

@@ -6,0 +6,0 @@ "repository": {

@@ -310,2 +310,64 @@ 'use strict';

lab.test('enable cors settings, should return headers with origin settings', (done) => {
swaggerOptions = {
'cors': true
};
Helper.createServer(swaggerOptions, routes, (err, server) => {
expect(err).to.equal(null);
server.inject({ method: 'GET', url: '/swagger.json' }, function (response) {
expect(response.statusCode).to.equal(200);
expect(response.headers.vary).to.equal('origin,accept-encoding');
expect(response.result.paths['/store/'].post.parameters.length).to.equal(1);
expect(response.result.paths['/store/'].post.parameters[0].name).to.equal('body');
done();
});
});
});
lab.test('disable cors settings, should return headers without origin settings', (done) => {
swaggerOptions = {
'cors': false
};
Helper.createServer(swaggerOptions, routes, (err, server) => {
expect(err).to.equal(null);
server.inject({ method: 'GET', url: '/swagger.json' }, function (response) {
expect(response.statusCode).to.equal(200);
expect(response.headers.vary).to.not.equal('origin,accept-encoding');
expect(response.result.paths['/store/'].post.parameters.length).to.equal(1);
expect(response.result.paths['/store/'].post.parameters[0].name).to.equal('body');
done();
});
});
});
lab.test('default cors settings as false, should return headers without origin settings', (done) => {
swaggerOptions = {
};
Helper.createServer(swaggerOptions, routes, (err, server) => {
expect(err).to.equal(null);
server.inject({ method: 'GET', url: '/swagger.json' }, function (response) {
expect(response.statusCode).to.equal(200);
expect(response.headers.vary).to.not.equal('origin,accept-encoding');
expect(response.result.paths['/store/'].post.parameters.length).to.equal(1);
expect(response.result.paths['/store/'].post.parameters[0].name).to.equal('body');
done();
});
});
});
lab.test('payloadType = form global', (done) => {

@@ -312,0 +374,0 @@

@@ -1,2 +0,2 @@

# 7.4.0 Usage Guide
# 7.6.0 Usage Guide

@@ -126,5 +126,5 @@ ### Content

Swagger provides a tag object which allows you to group your endpoints in the swagger-ui interface. The name of the tag needs
to match path of your endpoints, so in the example below all enpoints with the path `/users`, `/store` and `/sum` will be
group togther. Find out more about the [Tag Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#tagObject) on the OpenAPI spec site.
```Javascript
to match the path of your endpoints, so in the example below all endpoints with the path `/users`, `/store` and `/sum` will be
let options = {

@@ -164,3 +164,3 @@ info: {

The endpoints within the UI groups can be order with the property `options.sortEndpoints`, by default the are ordered
A-Z using the `path` information. Can also order them by `method`. Finnally if you wish to enforce you own order then
A-Z using the `path` information. Can also order them by `method`. Finally if you wish to enforce you own order then
you added route option `order` to each endpoint and switch the plugin options to `options.sortEndpoints = 'ordered'`.

@@ -188,4 +188,4 @@ ```Javascript

# Rewriting paths and groupings
There are time you may wish to modified now groups and endpoint paths are displayed within the documentation.
Ther are two ways to change to do this:
There are time you may wish to modify how groups and endpoint paths are displayed within the documentation.

@@ -266,4 +266,3 @@ ### Option 1 `basePath` and `pathPrefixSize`

it is added as a plugin configuration. The status codes need to be added as an array of objects with an error
code and description. The `description` is required, the schema is optional and unlike added response object the
example above this method does not validate the API response.
code and description. The `description` is required. The schema is optional, and unlike the example above, the schema object does not validate the API response.

@@ -487,3 +486,3 @@ ```Javascript

The JSON output for OpenAPI(Swagger) is based on the JSONSchema standard which allows for the internal referencing of object
structures using `$ref`. If you wish to simplifying the JSON you can use plugin option `options.deReference = true`. This can
structures using `$ref`. If you wish to simplify the JSON you can use plugin option `options.deReference = true`. This can
be useful if your are using codegen tools against the JSON

@@ -699,3 +698,3 @@

* [`options.js`](examples/options.js) - how to use many of the plug-ins options
* [`promises.js`](examples/promises.js) - how to setup the plug-in using promises
* [`promise.js`](examples/promise.js) - how to setup the plug-in using promises
* [`swagger-client.js`](examples/swagger-client.js) - how use the plug-in to build an lib interface with `swagger-client`

@@ -712,4 +711,4 @@ * [`upload-file.js`](examples/upload-file.js) - how create documenation for a file upload

Both these example use a custom HTML page
* [`be-more-hapi`](https://github.com/glennjones/be-more-hapi) - talk from Asyncjs on the October 2013 - old `hapi-swagger` example project, but keep update
* [`be-more-hapi`](https://github.com/glennjones/be-more-hapi) - talk from Async.js on the October 2013 - old `hapi-swagger` example project, but keep update
* [`hapi-token-docs`](https://github.com/glennjones/hapi-token-docs) - A example site using HAPI, JWT tokens and swagger documentation
* [`time-to-be-hapi`](https://github.com/glennjones/time-to-be-hapi) - Londonjs talk March 2016 has many example uses of HAPI and one using `hapi-swagger`
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc