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 0.2.4 to 0.3.0

public/swaggerui/swagger.html

49

lib/index.js

@@ -5,2 +5,3 @@ var Hoek = require('hoek'),

Path = require('path');
Crypto = require('crypto');

@@ -13,2 +14,4 @@ // Declare internals

endpoint: '/docs',
documentationPath: '/documentation',
enableDocumentationPage: true,
auth: false,

@@ -43,2 +46,12 @@ basePath: '',

if (settings.enableDocumentationPage) {
plugin.route({
method: 'GET',
path: settings.documentationPath,
handler: function(request, reply) {
reply.file(Path.join(__dirname, '..', 'public/swaggerui', 'swagger.html'));
}
});
}
if (settings.ui) {

@@ -55,17 +68,2 @@

plugin.route({
method: 'GET',
path: settings.endpoint + '/swaggerui/index.html',
config: {
auth: settings.auth
},
handler: {
view: {
template: 'index.html',
context: {
settings: settings
}
}
}
});

@@ -142,6 +140,6 @@ // add routing for swaggerui library directory ie /docs/swaggerui

// will show routes WITH 'mountains' OR 'beach' OR 'horses'
//
//
// e.g.: ?path=vacations&tags=mountains,beach,+horses
// will show routes WITH ('mountains' OR 'beach') AND 'horses'
//
//
// e.g.: ?path=vacations&tags=mountains,+beach,-horses

@@ -414,2 +412,6 @@ // will show routes WITH 'mountains' AND 'beach' AND NO 'horses'

}
if(responseProperty.items) {
// add these to the api operations
op.items = responseProperty.items;
}
}

@@ -433,2 +435,7 @@

prama = route[name]._inner.children;
} else {
// fix for responseObject array types
if (route[name]._type = 'array') {
prama = route[name];
}
}

@@ -609,8 +616,8 @@ }

property.items = {
'$ref': arrayProperty.type
'type': arrayProperty.type,
'enum': arrayProperty['enum']
};
} else {
property.items = {
'type': arrayProperty.type,
'enum': arrayProperty['enum']
'$ref': arrayProperty.type
};

@@ -748,3 +755,3 @@ }

if (!name) {
name = 'Model_' + Object.keys(params).join('_');
name = 'Model_' + Crypto.createHash('md5').update(JSON.stringify(params)).digest('hex');
}

@@ -751,0 +758,0 @@

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

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

@@ -36,7 +36,12 @@ # hapi-swagger

## Using the documentation page
The plugin adds a page into your site with the route `/documentation`. This page contains Swaggers UI to allow users to explore your API. You can also build custom pages on your own URL paths if you wish, see: Adding custom interface into a page
## Tagging your API routes
As a project may be a mixture of web pages and API endpoints you need to tag the routes you wish Swagger to document. Simply add the `tags: ['api']` property to the route object for any endpoint you want documenting.
You can even specify more tags and then later generate tag-specific documentation. If you specify `tags: ['api', 'foo']`, you can later use `/docs?tags=foo` to load the documentation on the HTML page (see next section).
You can even specify more tags and then later generate tag-specific documentation. If you specify `tags: ['api', 'foo']`, you can later use `/documentation?tags=foo` to load the documentation on the HTML page (see next section).
{

@@ -59,5 +64,7 @@ method: 'GET',

}
## Adding interface into a page
The plugin adds all the resources needed to build the interface into your project. All you need to do is add some javascript into the header of a web page and add two elements into the HTML where you wish it to render.
The plugin adds all the resources needed to build the interface into your any page in your project. All you need to do is add some javascript into the header of a web page and add two elements into the HTML where you wish it to render. The example [be-more-hapi](https://github.com/glennjones/be-more-hapi) project makes use of a custom page where the interface is used with other elements.

@@ -141,5 +148,7 @@

* basePath: the base URL of the API i.e. 'http://localhost:3000'
* endpoint: the documentation endpoint path - the default is: '/docs'
* documentationPath: the path to the default documentation page - the default is: '/documentation',
* enableDocumentationPage: enable the display of the documentation page - the default is: true,
* endpoint: the JSON endpoint that descibes the API - the default is: '/docs'
* pathPrefixSize: selects what segment of the URL path is used to group endpoints - the default is: 1
* payloadType: weather accepts json or form parameters for payload - the default is: 'json'
* payloadType: weather accepts JSON or form parameters for payload - the default is: 'json'
* produces: an array of the output types from your API - the default is: ['application/json']

@@ -255,2 +264,3 @@

* Darin Chambers (https://github.com/darinc)
* Kentaro Wakayama (https://github.com/kwakayama)

@@ -257,0 +267,0 @@

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