Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Updated OpenAPI specification links
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesMessinger committed Aug 24, 2019
1 parent 517fdaa commit 2774fbb
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/exports/Middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Methods
Initializes the middleware with the given Swagger API. This method can be called again to re-initialize with a new or modified API.

* __swagger__ (_optional_) - `string` or `object`<br>
The file path or URL of a Swagger 2.0 API spec, in YAML or JSON format. Or a valid [Swagger object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object). Any `$ref` pointers to other files/URLs will be interpreted as relative to the main Swagger file.
The file path or URL of a Swagger 2.0 API spec, in YAML or JSON format. Or a valid [Swagger object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object). Any `$ref` pointers to other files/URLs will be interpreted as relative to the main Swagger file.

* __callback__ (_optional_) - `function(err, middleware)`<br>
A callback function that will be called once the Swagger API is fully parsed, dereferenced, and validated. The second parameter is the same `Middleware` object.
Expand Down
2 changes: 1 addition & 1 deletion docs/exports/createMiddleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ API
The `createMiddleware` function is the main export of Swagger Express Middleware &mdash; it's what you get when you `require('swagger-express-middleware')`. It's just a convenience function that creates a [Middleware](Middleware.md) object and calls its [init method](Middleware.md#initswagger-callback).

* __swagger__ (_optional_) - `string` or `object`<br>
The file path or URL of a Swagger 2.0 API spec, in YAML or JSON format. Or a valid [Swagger object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object). Any `$ref` pointers to other files/URLs will be interpreted as relative to the main Swagger file.
The file path or URL of a Swagger 2.0 API spec, in YAML or JSON format. Or a valid [Swagger object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object). Any `$ref` pointers to other files/URLs will be interpreted as relative to the main Swagger file.

* __router__ (_optional_) - `express.App` or `express.Router`<br>
An [Express Application](http://expressjs.com/4x/api.html#application) or [Router](http://expressjs.com/4x/api.html#router) that will be used to determine settings (such as case-sensitivity and strict routing) and to register path-parsing middleware.
Expand Down
10 changes: 5 additions & 5 deletions docs/middleware/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ A `swagger` property is added to the [Request object](http://expressjs.com/4x/ap

| Property | Type | Description |
|:-----------------|:-----------------|:------------|
| `api` | [Swagger Object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object) | The complete Swagger API object. If the Swagger API has a `basePath` and the current request is not within that path, then this property is `null`.
| `api` | [Swagger Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object) | The complete Swagger API object. If the Swagger API has a `basePath` and the current request is not within that path, then this property is `null`.
| `pathName` | string | The Swagger path that corresponds to the current HTTP request. If the current request does not match any paths in the Swagger API, then this property is an empty string.<br><br> For example, the "_/pets/{petName}/photos/{id}_" Swagger path would match a request to "_/pets/Fido/photos/123_".
| `path` | [Path Object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#path-item-object) | The Swagger path object that corresponds to the current HTTP request, or `null` if the request does not match any path in the Swagger API.
| `operation` | [Operation Object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#operation-object) | The Swagger operation object that corresponds to the current HTTP request, or `null` if the request does not match any operation in the Swagger API.
| `params` | array of [Parameter Objects](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#parameter-object) | The Swagger parameter objects that correspond to the current HTTP request. The array is empty if there are no parameters. These are just the parameter _definitions_ from the API, not the _values_ for the current request. See the [Parse Request middleware](parseRequest.md) for parameter values.
| `security` | array of [Security Requirement Objects](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#securityRequirementObject) | The security requirement objects that correspond to the current HTTP request. The array is empty if there are no security requirements. These are just the security _definitions_ from the API, not any validated or authenticated values. See the [Validate Request middleware](validateRequest.md) for security validation.
| `path` | [Path Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#path-item-object) | The Swagger path object that corresponds to the current HTTP request, or `null` if the request does not match any path in the Swagger API.
| `operation` | [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#operation-object) | The Swagger operation object that corresponds to the current HTTP request, or `null` if the request does not match any operation in the Swagger API.
| `params` | array of [Parameter Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameter-object) | The Swagger parameter objects that correspond to the current HTTP request. The array is empty if there are no parameters. These are just the parameter _definitions_ from the API, not the _values_ for the current request. See the [Parse Request middleware](parseRequest.md) for parameter values.
| `security` | array of [Security Requirement Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#securityRequirementObject) | The security requirement objects that correspond to the current HTTP request. The array is empty if there are no security requirements. These are just the security _definitions_ from the API, not any validated or authenticated values. See the [Validate Request middleware](validateRequest.md) for security validation.
2 changes: 1 addition & 1 deletion docs/middleware/parseRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The first phase performs basic parsing of the HTTP request using third-party lib
### Phase 2 - Swagger parsing
The second phase performs Swagger-specific parsing. During this phase, every parameter defined in your Swagger API is checked against the HTTP request. If a Swagger parameter is missing from the request, and there's a `default` value specified in the Swagger API, then that default value is used, just as if the request contained that value. If a _required_ Swagger parameter is missing from the request, and there's no `default` value, then an error is thrown.

Any Swagger parameters that _are_ included in the request are parsed and validated according to the [parameter definition](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#parameter-object). If the value doesn't adhere to the parameter definition for any reason (such as improper data type, min/max length, min/max value, RegEx pattern, etc.), then an error is thrown.
Any Swagger parameters that _are_ included in the request are parsed and validated according to the [parameter definition](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameter-object). If the value doesn't adhere to the parameter definition for any reason (such as improper data type, min/max length, min/max value, RegEx pattern, etc.), then an error is thrown.

Finally, if everything is valid, then the HTTP request values are converted to the proper JavaScript data types. For example, if you define a Swagger parameter as `{type: "string", format: "date-time"}`, then it will be converted to a JavaScript `Date` object. If you define a parameter as `{type: "integer", format: "int32"}`, then it will be converted to a JavaScript `Number` with a whole value.

Expand Down
6 changes: 3 additions & 3 deletions docs/middleware/validateRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The Validate Request middleware checks each HTTP request for several different t


### HTTP 401 (Unauthorized)
If your Swagger API has [security requirements](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#securityRequirementObject) defined, then the Validate Request middleware will check to make sure each request contains the necessary security info. For example, if you're using `basic` security, then it will verify that the `Authorization` HTTP header is present. If you're using `apiKey` security, then it will verify that the corresponding HTTP header or query parameter exists.
If your Swagger API has [security requirements](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#securityRequirementObject) defined, then the Validate Request middleware will check to make sure each request contains the necessary security info. For example, if you're using `basic` security, then it will verify that the `Authorization` HTTP header is present. If you're using `apiKey` security, then it will verify that the corresponding HTTP header or query parameter exists.

If the request doesn't contain the necessary security information, then it will throw an [HTTP 401 (Unauthorized)](http://httpstatusdogs.com/401-unauthorized) error. For `basic` security, it will also set the `WWW-Authenticate` response header.

Expand All @@ -89,15 +89,15 @@ In addition, the `Allow` response header will be set to the methods that _are_ a


### HTTP 406 (Not Acceptable)
If your Swagger API includes a `produces` list of [MIME types](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#mimeTypes) that your API can produce, then the Validate Request middleware will check the `Accept` header of incoming requests to make sure the client accepts at least one of your MIME types. If none of your MIME types are accepted, then an [HTTP 406 (Not Acceptable)](http://httpstatusdogs.com/406-not-acceptable) error is thrown.
If your Swagger API includes a `produces` list of [MIME types](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#mimeTypes) that your API can produce, then the Validate Request middleware will check the `Accept` header of incoming requests to make sure the client accepts at least one of your MIME types. If none of your MIME types are accepted, then an [HTTP 406 (Not Acceptable)](http://httpstatusdogs.com/406-not-acceptable) error is thrown.


### HTTP 413 (Request Entity Too Large)
If the request includes a payload (an HTTP body or form-data), and your Swagger operation does not have any `body` or `formData` parameters defined, then an [HTTP 413 (Request Entity Too Large)](http://httpstatusdogs.com/413-request-entity-too-large) error is thrown.


### HTTP 415 (Unsupported Media Type)
If your Swagger API includes a `consumes` list of [MIME types](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#mimeTypes) that your API can consume, then the Validate Request middleware will check the `Content-Type` header of incoming requests to make sure it matches one of your MIME types. If the content does not match any of your MIME types, then an [HTTP 415 (Unsupported Media Type)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415) is thrown.
If your Swagger API includes a `consumes` list of [MIME types](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#mimeTypes) that your API can consume, then the Validate Request middleware will check the `Content-Type` header of incoming requests to make sure it matches one of your MIME types. If the content does not match any of your MIME types, then an [HTTP 415 (Unsupported Media Type)](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415) is thrown.


### HTTP 500 (Internal Server Error)
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const util = require("./helpers/util");
*
* @param {string|object} [swagger]
* - The file path or URL of a Swagger 2.0 API spec, in YAML or JSON format.
* Or a valid Swagger API object (see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object).
* Or a valid Swagger API object (see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object).
*
* @param {express#Router} [router]
* - An Express Application or Router that will be used to determine settings (such as case-sensitivity and strict routing)
Expand Down
2 changes: 1 addition & 1 deletion lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function Middleware (sharedRouter) {
*
* @param {string|object} [swagger]
* - The file path or URL of a Swagger 2.0 API spec, in YAML or JSON format.
* Or a valid Swagger API object (see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object).
* Or a valid Swagger API object (see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object).
*
* @param {function} [callback]
* - It will be called when the API has been parsed, validated, and dereferenced, or when an error occurs.
Expand Down
10 changes: 5 additions & 5 deletions lib/request-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function swaggerMetadata (req, res, next) {
req.swagger = {
/**
* The complete Swagger API object.
* (see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object)
* (see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object)
* @type {SwaggerObject|null}
*/
api: null,
Expand All @@ -104,28 +104,28 @@ function swaggerMetadata (req, res, next) {

/**
* The Path object from the Swagger API.
* (see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#pathItemObject)
* (see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#pathItemObject)
* @type {object|null}
*/
path: null,

/**
* The Operation object from the Swagger API.
* (see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#operationObject)
* (see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#operationObject)
* @type {object|null}
*/
operation: null,

/**
* The Parameter objects that apply to this request.
* (see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#parameter-object-)
* (see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameter-object-)
* @type {object[]}
*/
params: [],

/**
* The Security Requirement objects that apply to this request.
* (see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#securityRequirementObject)
* (see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#securityRequirementObject)
* @type {object[]}
*/
security: []
Expand Down

0 comments on commit 2774fbb

Please sign in to comment.