swagger-spec-express

Allows you to programatically annotate your express routes with swagger info and then generate and validate your json spec file

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
swagger-spec-express
33372.0.234 years ago8 years agoMinified + gzip package size for swagger-spec-express in KB

Readme

swagger-spec-express
Programmatically generate your Swagger specification (JSON) file.

NPM
Build status
A library that allows you to programmatically annotate your existing express api with swagger info and then generate and validate your json spec file. All without completely starting over or changing the structure of your express routes.

Why

There are already a few libraries out there to add Swagger documentation to your express api, like swagger-node-express and swagger-node which work really well, however they require you to either start from scratch or change your routes to work with their format. This libary is different and can easily be added to an existing and established express api using the normal patterns you are used to.
\##Installation Requires Express 4.x
Install the package:
npm install swagger-spec-express --save-exact

Basic code example:
var express = require('express');
var swagger = require('swagger-spec-express');
var packageJson = require('./package.json');

var app = express();
var options = {
    title: packageJson.title,
    version: packageJson.version
};
swagger.initialise(app, options);

app.get('/swagger.json', function (err, res) {
    res.status(200).json(swagger.json());
}).describe({
    responses: {
        200: {
            description: "Returns the swagger.json document"
        }
    }
});

swagger.compile();
var port = 3000;
app.listen(port, appListening);
function appListening() {
    console.info(packageJson.name + ' is listening on port ' + port);
}

This will create a very basic express app that serves up the swagger.json document when you navigate to
The JSON Schema file that will be used to validate the supplied metadata on the route can be found here in addition the fields are detailed below. Wherever possible the library tries to adhear to the official Swagger Specification so that is a good place to look for extra information about what you can specify.

Describing Your Routes

As seen above, once you have called initialise on your app, the describe method is automatically added and can be added to routes you declare directly on your app object.
But what if you want to use the router object? In the above example code above add the following to the top of the page:
var exampleRouter = require('./example-route');

And then after calling swagger.initialise(app, options); add the following:
app.use(exampleRouter);

Code for the example router:
'use strict';
var express = require('express');
var swagger = require('swagger-spec-express');
var router = new express.Router();
swagger.swaggerize(router);
module.exports = router;

router.get('/one', function (req, res) {
    res.status(200).json({example: 1})
}).describe({
    responses: {
        200: {
            description: "Returns example 1"
        }
    }
});

Adding the UI

Simply follow the instructions for the official Swagger UI project. or use your favourite, alternative Swagger UI theme.

API

Table of Contents

initialise

lib/initialise.js:120-136
Will initialise your app with the required swaggers-spec information. In addition you can pass in some options which will be used when generating the swagger JSON document later on. Both British and American spelling supported.
Parameters
  • app object The express app class that you want to describe using swagger
  • options.externalDocs.url string Required. The URL for the target documentation. Value MUST be in the format of a URL.
  • options.document \object An existing or manually created swagger document to use as a base document and expanded upon. Note that the other options will override the base items in this supplied document. See for info on how to manually construct a document.
  • options.title \string The title of the application.
  • options.description \string A short description of the application. GFM syntax can be used for rich text representation.
  • options.termsOfService \string The Terms of Service for the API.
  • options.contact \object The contact information for the exposed API. See Contact Object.
-   `options.contact.name` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The identifying name of the contact person/organization.
-   `options.contact.url` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The URL pointing to the contact information. MUST be in the format of a URL.
-   `options.contact.email` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The email address of the contact person/organization. MUST be in the format of an email address.
-   `options.license.name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Required. The license name used for the API.
-   `options.license.url` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A URL to the license used for the API. MUST be in the format of a URL.
  • options.version \string Provides the version of the application API.
  • options.host \string The host (name or ip) serving the API. This MUST be the host only and does not include the scheme nor sub-paths. It MAY include a port. If the host is not included, the host serving the documentation is to be used (including the port). The host does not support Path Templating.
  • options.basePath \string The base path on which the API is served, which is relative to the host. If it is not included, the API is served directly under the host. The value MUST start with a leading slash (/). The basePath does not support Path Templating. (optional, default /)
  • options.schemes \Array<string> The transfer protocol of the API. Values MUST be from the list: "http", "https", "ws", "wss". If the schemes is not included, the default scheme to be used is the one used to access the Swagger definition itself.
  • options object The options object, used to control how the swagger document will be generated
-   `options.produces` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** A list of MIME types the APIs can produce. This is global to all APIs but can be overridden on specific API calls. Value MUST be as described under [Mime Types](http://swagger.io/specification/#mimeTypes).
-   `options.paths` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** The available paths and operations for the API. See [Paths Object](http://swagger.io/specification/#pathsObject).
-   `options.definitions` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** An object to hold data types produced and consumed by operations. See [Definitions Object](http://swagger.io/specification/#definitionsObject).
-   `options.parameters` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** An object to hold parameters that can be used across operations. This property does not define global parameters for all operations. See [Parameter Definitions Object](http://swagger.io/specification/#parametersDefinitionsObject).
-   `options.responses` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** An object to hold responses that can be used across operations. This property does not define global responses for all operations. See [Response Definitions Object](http://swagger.io/specification/#responsesDefinitionsObject).
-   `options.securityDefinitions` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Security scheme definitions that can be used across the specification. See [Security Definitions Object](http://swagger.io/specification/#securityDefinitionsObject).
-   `options.security` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** A declaration of which security schemes are applied for the API as a whole. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). Individual operations can override this definition. See [Security Requirement Object](http://swagger.io/specification/#securityRequirementObject).
-   `options.defaultSecurity` **\[([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>)]** The default security schema to use on a route when the security parameter is set to **true**. Must be a single [Security Requirement Object](http://swagger.io/specification/#securityRequirementObject).
-   `options.tags` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](swagger.io/specification/#operationObject) must be declared. The tags that are not declared may be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. See [Tag Object](http://swagger.io/specification/#tagObject).
    -   `options.tags.name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Required. The name of the tag.
    -   `options.tags.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A short description for the tag. GFM syntax can be used for rich text representation.
    -   `options.tags.externalDocs` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Additional external documentation for this tag.
        -   `options.tags.externalDocs.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A short description of the target documentation. GFM syntax can be used for rich text representation.
        -   `options.tags.externalDocs.url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Required. The URL for the target documentation. Value MUST be in the format of a URL.
-   `options.externalDocs` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Additional external documentation. See [External Documentation Object](http://swagger.io/specification/#externalDocumentationObject).
    -   `options.externalDocs.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A short description of the target documentation. GFM syntax can be used for rich text representation.
-   `options.consumes` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** A list of MIME types the APIs can consume. This is global to all APIs but can be overridden on specific API calls. Value MUST be as described under [Mime Types](http://swagger.io/specification/#mimeTypes).
Examples
Minimal
var express = require('express');
var swagger = require('swagger-spec-express');
var packageJson = require('./package.json');
var app = express();

swagger.initialise(app, options);

Extensive
var express = require('express');
var swagger = require('swagger-spec-express');
var packageJson = require('./package.json');
var app = express();
var options = {
   document: {
       // An existing swagger json spec file that you may want to build on
   },
   title: packageJson.title,
   description: packageJson.description,
   termsOfService: 'You may only use this api for reasons!',
   contact: {
       name: '',
       url: '',
       email: ''
   },
   license: {
       name: '',
       url: ''
   },
   version: packageJson.version,
   host: 'localhost',
   basePath: '/',
   schemes: ['http', 'https'],
   consumes: ['application/json'],
   produces: ['application/json'],
   paths: {
       //manual paths here if desired, not required.
   },
   definitions: {
       //manual definitions here if desired, not required.
   },
   parameters: {
       //manual definitions here if desired, not required.
   },
   responses: {
       //manual responses here if desired, not required.
   },
   securityDefinitions: {
       basicAuth: {
           type: "basic",
           description: "HTTP Basic Authentication. Works over HTTPS"
       }
   },
   security: [{basicAuth: []}],
   defaultSecurity: "basicAuth",
   tags: [
       {
           name: 'My Manual Tag',
           description: 'Manually added to swagger',
           externalDocs: {
               description: 'This doc describes how to make tags',
               url: 'https://github.com/eXigentCoder/swagger-spec-express'
           }
       }
   ],
   externalDocs: {
       description: 'This doc describes how to use swagger spec express',
       url: 'https://github.com/eXigentCoder/swagger-spec-express'
   }
};
swagger.initialise(app, options);

  • Throws Error if already initialised, should call reset first if reinitialisation required
  • Throws Error if no app object provided
  • Throws Error if no options object provided

Returns void

swaggerise

lib/swaggerise.js:16-68
Adds the .describe function onto the provided object. The object should either be an express app or express router.
Parameters

Examples
var swagger = require('swagger-spec-express');
var express = require('express');
var app = express();
swagger.swaggerize(app);
var router = new express.Router();
swagger.swaggerize(router);

Returns void

describe

lib/swaggerise.js:62-67
Allows you describe an app our router route.
Parameters
  • metaData object Metadata about a route. At least one of metaData.responses or metaData.common.responses must be specified.
-   `metaData.summary` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A brief summary of the operation.
-   `metaData.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A longer description of the operation, GitHub Flavored Markdown is allowed.
-   `metaData.externalDocs` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** information about external documentation
    -   `metaData.externalDocs.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A short description of the target documentation. GFM syntax can be used for rich text representation.
    -   `metaData.externalDocs.url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Required. The URL for the target documentation. Value MUST be in the format of a URL.
-   `metaData.operationId` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A unique identifier of the operation.
-   `metaData.produces` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** A list of MIME types the API can produce.
-   `metaData.consumes` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** A list of MIME types the API can consume.
-   `metaData.parameters` **\[([object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String))]** An object to hold parameters that can be used across operations. This property does not define global parameters for all operations. See [Parameter Definitions Object](http://swagger.io/specification/#parametersDefinitionsObject).
-   `metaData.tags` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](swagger.io/specification/#operationObject) must be declared. The tags that are not declared may be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. See [Tag Object](http://swagger.io/specification/#tagObject).
-   `metaData.schemes` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** The transfer protocol of the API.
-   `metaData.deprecated` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Declares this operation to be deprecated. Usage of the declared operation should be refrained. Default value is false.
-   `metaData.security` **\[([array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) \| [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String))]** A declaration of which security schemes are applied for the API as a whole. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). Individual operations can override this definition. See [Security Requirement Object](http://swagger.io/specification/#securityRequirementObject).
-   `metaData.common` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** A collection of common data to include in this route.
    -   `metaData.common.responses` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** Common responses as added by calling common.addResponse
    -   `metaData.common.parameters` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** A collection of common parameters to use for this route.
        -   `metaData.common.parameters.header` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** A common header parameter as added by calling common.parameters.addHeader
        -   `metaData.common.parameters.body` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** A common body parameter as added by calling common.parameters.addBody
        -   `metaData.common.parameters.query` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** A common query string parameter as added by calling common.parameters.addQuery
        -   `metaData.common.parameters.formData` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** A common form data parameter as added by calling common.parameters.addFormData
-   `metaData.responses` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Response objects names can either be any valid HTTP status code or 'default'.
  • metaData.common.parameters.path \Array<string> A common path parameter as added by calling common.parameters.addPath

Examples
var swagger = require('swagger-spec-express');
var express = require('express');
var router = new express.Router();
swagger.swaggerize(router);
router.get('/', function (req, res) {
    //...
}).describe({
    //...
});

Returns void

compile

lib/index.js:52-59
Will gather together all your described app routes and compile them into a single document to be served up by your api when you call json. Can only be called once initialise has been called. Should only call this once you have completely finished describing your routes.
Examples
var swagger = require('swagger-spec-express');
var express = require('express');
var router = new express.Router();
swagger.swaggerize(router);
router.get('/', function (req, res) {
    //...
}).describe({
    //...
});
swagger.compile();

  • Throws Error Will throw an error if initialise wasn't called or if you don't yet have any routes defined or if there are certain errors in your metadata

Returns void

validate

lib/index.js:83-85
Will validate the internal json document created by calling compile. This is done using the ajv validator against the official JSON schema. \* @throws {Error} Throws an exception if called before compile or initialise.
Examples
var swagger = require('swagger-spec-express');
var express = require('express');
var router = new express.Router();
var os = require('os');
swagger.swaggerize(router);
router.get('/', function (req, res) {
    //...
}).describe({
    //...
});
swagger.compile();
var result = swagger.validate();
if (!result.valid) {
    console.warn("Compiled Swagger document does not pass validation: " + os.EOL + result.message);
}

Returns {valid: boolean, errors: Array<Object>, message: string} The result of the validation

json

lib/index.js:113-117

Returns the swagger specification as a json object.
Examples
var swagger = require('swagger-spec-express');
var express = require('express');
var app = express();
var options = {
    title: packageJson.title,
    version: packageJson.version
};
swagger.initialise(app, options);
app.get('/swagger.json', function (err, res) {
    res.status(200).json(swagger.json());
}).describe({
    responses: {
        200: {
            description: "Returns the swagger.json document"
        }
    }
});
swagger.compile();

  • Throws Error Throws an exception if called before compile or initialise. You do not need to call validate first.

Returns Object The Swagger JSON object describing your api. See .

addTag

lib/common.js:44-51

Adds a common tag for later use.
Parameters
  • tag object Allows adding meta data to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag used there.
-   `tag.name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Required. The name of the tag.
-   `tag.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A short description for the tag. GFM syntax can be used for rich text representation.
-   `tag.externalDocs` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** information about external documentation
    -   `tag.externalDocs.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A short description of the target documentation. GFM syntax can be used for rich text representation.
    -   `tag.externalDocs.url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Required. The URL for the target documentation. Value MUST be in the format of a URL.

Examples
var swagger = require('swagger-spec-express');
swagger.common.addTag({
    name: "Info",
    description: "Info about the api"
});
//...
router.get('/', function (req, res) {
    //...
}).describe({
    //...
    tags: ["Info"],
    //...
});

Returns void

addHeaderParameter

lib/common.js:106-114
Adds a common header for later use.
Parameters
-   `header.format` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The extending format for the previously mentioned [type](http://swagger.io/specification/#parameterType). See [Data Type Formats](http://swagger.io/specification/#dataTypeFormat) for further details.
-   `header.items` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Required if [type](http://swagger.io/specification/#parameterType) is `array`. Describes the type of items in the array.
-   `header.collectionFormat` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Determines the format of the array if type array is used. Possible values are:-   csv comma separated values foo,bar.
    -   ssv space separated values foo bar.
    -   tsv tab separated values foo bar.
    -   pipes pipe separated values foo|bar.
    -   multi corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in `query` or `formData`.Default value is csv.
-   `header.maximum` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor17).
-   `header.exclusiveMaximum` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor17).
-   `header.minimum` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor21).
-   `header.exclusiveMinimum` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor21).
-   `header.type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** **Required.** The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). The value MUST be one of `string`, `number`, `integer`, `boolean`, `array` or `file`. If type is `file`, the [consumes](http://swagger.io/specification/#operationConsumes) MUST be either `multipart/form-data`, `application/x-www-form-urlencoded` or both and the parameter MUST be in `formData`.
-   `header.minLength` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor29).
-   `header.pattern` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor33).
-   `header.maxItems` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor42).
-   `header.minItems` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor45).
-   `header.uniqueItems` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor49).
-   `header.multipleOf` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor14).
-   `header.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A short description of the header.
-   `header.name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name used to refer to this header at a later stage.
-   `header.maxLength` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor26).

Examples
var swagger = require('swagger-spec-express');
swagger.common.parameters.addHeader({
    name: "Originator-Id",
    description: "Tells the server where the request originated from",
    required: true,
    type: "string"
});
//...
router.get('/', function (req, res) {
    //...
}).describe({
    //...
    common: {
        //...
        parameters: {
            header: ["Originator-Id"]
        }
        //...
    }
    //...
});

Returns void

addBodyParameter

lib/common.js:159-167
Adds a common body parameter for later use.
Parameters
  • body object The payload that's appended to the HTTP request. Since there can only be one payload, there can only be one body parameter. The name of the body parameter has no effect on the parameter itself and is used for documentation purposes only. Since Form parameters are also in the payload, body and form parameters cannot exist together for the same operation.
-   `body.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A brief description of the parameter. This could contain examples of use.  GitHub Flavored Markdown is allowed.
-   `body.name` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The name of the parameter.
-   `body.in` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Determines the location of the parameter.
-   `body.required` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Determines whether or not this parameter is required or optional.
-   `body.schema` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** A deterministic version of a JSON Schema object.
-   `body.model` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The name of the model produced or consumed.
-   `body.arrayOfModel` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The name of the model produced or consumed as an array.

Examples
var swagger = require('swagger-spec-express');
swagger.common.parameters.addBody({
    name: "process",
    description: "Kicks off the process function on the server at the rest endpoint using the options provided",
    required: true,
    schema : {
        type: "object",
        properties: {
            "async": {
                "type": "boolean"
            }
        }
        additionalProperties: true
    }
});
//...
router.get('/', function (req, res) {
    //...
}).describe({
    //...
    common: {
        //...
        parameters: {
            body: ["process"]
        }
        //...
    }
    //...
});

Returns void \*

addQueryParameter

lib/common.js:225-233
Adds a common query parameter for later use.
Parameters
  • query object Parameters that are appended to the URL. For example, in /items?id=###, the query parameter is id
-   `query.in` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Determines the location of the parameter.
-   `query.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A brief description of the parameter. This could contain examples of use.  GitHub Flavored Markdown is allowed.
-   `query.name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the parameter.
-   `query.allowEmptyValue` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** allows sending a parameter by name only or with an empty value.
-   `query.type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** **Required.** The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). The value MUST be one of `string`, `number`, `integer`, `boolean`, `array` or `file`. If type is `file`, the [consumes](http://swagger.io/specification/#operationConsumes) MUST be either `multipart/form-data`, `application/x-www-form-urlencoded` or both and the parameter MUST be in `formData`.
-   `query.format` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The extending format for the previously mentioned [type](http://swagger.io/specification/#parameterType). See [Data Type Formats](http://swagger.io/specification/#dataTypeFormat) for further details.
-   `query.items` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Required if [type](http://swagger.io/specification/#parameterType) is `array`. Describes the type of items in the array.
-   `query.collectionFormat` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Determines the format of the array if type array is used. Possible values are:-   csv comma separated values foo,bar.
    -   ssv space separated values foo bar.
    -   tsv tab separated values foo bar.
    -   pipes pipe separated values foo|bar.
    -   multi corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in `query` or `formData`.Default value is csv.
-   `query.maximum` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor17).
-   `query.required` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Determines whether or not this parameter is required or optional.
-   `query.minimum` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor21).
-   `query.exclusiveMinimum` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor21).
-   `query.maxLength` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor26).
-   `query.minLength` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor29).
-   `query.pattern` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor33).
-   `query.maxItems` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor42).
-   `query.minItems` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor45).
-   `query.uniqueItems` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor49).
-   `query.multipleOf` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor14).
-   `query.exclusiveMaximum` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor17).

Examples
var swagger = require('swagger-spec-express');
swagger.common.parameters.addQuery({
    name: "sort",
    description: "The sort order of records e.g. sort=field1,-field2",
    required: false,
    type: "string"
});
//...
router.get('/', function (req, res) {
    //...
}).describe({
    //...
    common: {
        //...
        parameters: {
            query: ["sort"]
        }
        //...
    }
    //...
});

Returns void

addFormDataParameter

lib/common.js:293-301
Adds a common form data parameter for later use.
Parameters
  • formData object Used to describe the payload of an HTTP request when either application/x-www-form-urlencoded, multipart/form-data or both are used as the content type of the request (in Swagger's definition, the consumes property of an operation). This is the only parameter type that can be used to send files, thus supporting the file type. Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation. Form parameters have a different format based on the content-type used (for further details, consult ):- application/x-www-form-urlencoded Similar to the format of Query parameters but as a payload. For example, foo=1&bar=swagger both foo and bar are form parameters. This is normally used for simple parameters that are being transferred.
-   multipart/form-data each parameter takes a section in the payload with an internal header. For example, for the header Content-Disposition: form-data; name="submit-name" the name of the parameter is submit-name. This type of form parameters is more commonly used for file transfers.
-   `formData.in` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Determines the location of the parameter.
-   `formData.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A brief description of the parameter. This could contain examples of use.  GitHub Flavored Markdown is allowed.
-   `formData.name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the parameter.
-   `formData.allowEmptyValue` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** allows sending a parameter by name only or with an empty value.
-   `formData.type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** **Required.** The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). The value MUST be one of `string`, `number`, `integer`, `boolean`, `array` or `file`. If type is `file`, the [consumes](http://swagger.io/specification/#operationConsumes) MUST be either `multipart/form-data`, `application/x-www-form-urlencoded` or both and the parameter MUST be in `formData`.
-   `formData.format` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The extending format for the previously mentioned [type](http://swagger.io/specification/#parameterType). See [Data Type Formats](http://swagger.io/specification/#dataTypeFormat) for further details.
-   `formData.items` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Required if [type](http://swagger.io/specification/#parameterType) is `array`. Describes the type of items in the array.
-   `formData.collectionFormat` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Determines the format of the array if type array is used. Possible values are:-   csv comma separated values foo,bar.
    -   ssv space separated values foo bar.
    -   tsv tab separated values foo bar.
    -   pipes pipe separated values foo|bar.
    -   multi corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in `query` or `formData`.Default value is csv.
-   `formData.maximum` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor17).
-   `formData.required` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Determines whether or not this parameter is required or optional.
-   `formData.minimum` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor21).
-   `formData.exclusiveMinimum` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor21).
-   `formData.maxLength` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor26).
-   `formData.minLength` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor29).
-   `formData.pattern` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor33).
-   `formData.maxItems` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor42).
-   `formData.minItems` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor45).
-   `formData.uniqueItems` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor49).
-   `formData.multipleOf` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor14).
-   `formData.exclusiveMaximum` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor17).

Examples
var swagger = require('swagger-spec-express');
swagger.common.parameters.addFormData({
    name: "csvString",
    description: "The csv string to import",
    required: true,
    type: "string"
});
//...
router.get('/', function (req, res) {
    //...
}).describe({
    //...
    common: {
        //...
        parameters: {
            formData: ["csvString"]
        }
        //...
    }
    //...
});

Returns void

addPathParameter

lib/common.js:358-366
Adds a common path parameter for later use.
Parameters
  • path object Used together with Path Templating, where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in /items/{itemId}, the path parameter is itemId.
-   `path.in` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Determines the location of the parameter.
-   `path.description` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** A brief description of the parameter. This could contain examples of use.  GitHub Flavored Markdown is allowed.
-   `path.name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the parameter.
-   `path.type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** **Required.** The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). The value MUST be one of `string`, `number`, `integer`, `boolean`, `array` or `file`. If type is `file`, the [consumes](http://swagger.io/specification/#operationConsumes) MUST be either `multipart/form-data`, `application/x-www-form-urlencoded` or both and the parameter MUST be in `formData`.
-   `path.format` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The extending format for the previously mentioned [type](http://swagger.io/specification/#parameterType). See [Data Type Formats](http://swagger.io/specification/#dataTypeFormat) for further details.
-   `path.items` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Required if [type](http://swagger.io/specification/#parameterType) is `array`. Describes the type of items in the array.
-   `path.collectionFormat` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Determines the format of the array if type array is used. Possible values are:-   csv comma separated values foo,bar.
    -   ssv space separated values foo bar.
    -   tsv tab separated values foo bar.
    -   pipes pipe separated values foo|bar.
    -   multi corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in `query` or `formData`.Default value is csv.
-   `path.maximum` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor17).
-   `path.required` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Determines whether or not this parameter is required or optional.
-   `path.minimum` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor21).
-   `path.exclusiveMinimum` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor21).
-   `path.maxLength` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor26).
-   `path.minLength` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor29).
-   `path.pattern` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor33).
-   `path.maxItems` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor42).
-   `path.minItems` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor45).
-   `path.uniqueItems` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor49).
-   `path.multipleOf` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor14).
-   `path.exclusiveMaximum` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor17).

Examples
var swagger = require('swagger-spec-express');
swagger.common.parameters.addPath({
    name: "entityId",
    description: "The id of the entity which contains the data we are using",
    required: true,
    type: "string"
});
//...
router.get('/:entityId', function (req, res) {
    //...
}).describe({
    //...
    common: {
        //...
        parameters: {
            path: ["entityId"]
        }
        //...
    }
    //...
});

Returns void

addResponse

lib/common.js:401-408
Adds a common response for later use.
Parameters
  • response object Describes a single response from an API Operation.
-   `response.description` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** **Required.** A short description of the response. [GFM syntax](https://help.github.com/articles/github-flavored-markdown) can be used for rich text representation.
-   `response.schema` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** A definition of the response structure. It can be a primitive, an array or an object. If this field does not exist, it means no content is returned as part of the response. As an extension to the [Schema Object](http://swagger.io/specification/#schemaObject), its root type value may also be `file`. This SHOULD be accompanied by a relevant produces mime-type.
-   `response.headers` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** A list of headers that are sent with the response. See <http://swagger.io/specification/#headersObject>
-   `response.examples` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** An example of the response message. See <http://swagger.io/specification/#exampleObject>
-   `response.name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The name or http status code used to refer to this response at a later stage.
-   `response.model` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The name of the model produced or consumed.
-   `response.arrayOfModel` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The name of the model produced or consumed as an array.

Examples
var swagger = require('swagger-spec-express');
swagger.common.addResponse({
    name: "500",
    description: "Server Error",
    "schema": {
        $ref: "#/definitions/serverError"
    }
});
//...
router.get('/', function (req, res) {
    //...
}).describe({
    //...
    common: {
        //...
        responses: ["500", "400", "401", "404"],
        //...
    }
    //...
});

Returns void

addResponseHeader

lib/common.js:461-469
Adds a common response header for later use.
Parameters
-   `responseHeader.format` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** The extending format for the previously mentioned [type](http://swagger.io/specification/#parameterType). See [Data Type Formats](http://swagger.io/specification/#dataTypeFormat) for further details.
-   `responseHeader.items` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Required if [type](http://swagger.io/specification/#parameterType) is `array`. Describes the type of items in the array.
-   `responseHeader.collectionFormat` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Determines the format of the array if type array is used. Possible values are:-   csv comma separated values foo,bar.
    -   ssv space separated values foo bar.
    -   tsv tab separated values foo bar.
    -   pipes pipe separated values foo|bar.
    -   multi corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in `query` or `formData`.Default value is csv.
-   `responseHeader.maximum` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor17).
-   `responseHeader.exclusiveMaximum` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor17).
-   `responseHeader.minimum` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor21).
-   `responseHeader.exclusiveMinimum` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor21).
-   `responseHeader.type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** **Required.** The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). The value MUST be one of `string`, `number`, `integer`, `boolean`, `array` or `file`. If type is `file`, the [consumes](http://swagger.io/specification/#operationConsumes) MUST be either `multipart/form-data`, `application/x-www-form-urlencoded` or both and the parameter MUST be in `formData`.
-   `responseHeader.minLength` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** See [json-schema.org](http://json-schema.org/latest/json-schema-validation.html#anchor29).
-   `responseHeader.pattern` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** See [json-schema.org](