Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
theganyo committed Oct 5, 2015
1 parent 7e8fbaa commit 802fc77
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/swagger-api/swagger-node.svg?branch=master)](https://travis-ci.org/swagger-api/swagger-node)

The `swagger` module provides tools for designing and building Swagger-compliant APIs entirely in Node.js. It integrates with popular Node.js servers, including Express, hapi, restify, and Sails, as well as any Connect-based middleware. With `swagger`, you can specify, build, and test your API from the very beginning, on your laptop. It allows you to change and iterate your design without rewriting the logic of your implementation.
The `swagger` module provides tools for designing and building Swagger-compliant APIs entirely in Node.js. It integrates with popular Node.js servers, including Express, Hapi, Restify, and Sails, as well as any Connect-based middleware. With `swagger`, you can specify, build, and test your API from the very beginning, on your laptop. It allows you to change and iterate your design without rewriting the logic of your implementation.

![alt text](./docs/images/overview2.png)

Expand Down
4 changes: 3 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
* [Introduction](./introduction.md)
* [Installation](./install.md)
* [Quick start](./quick-start.md)
* [Configuration](./configuration.md)
* [CLI reference](./cli.md)
* [About Swagger](./swagger-about.md)
* [About the swagger.yaml file](./swagger-file.md)
* [Adding paths](./adding-paths.md)
* [Writing controllers](./controllers.md)
* [Using mock mode](./mock-mode.md)
* [Modules and dependencies](./modules.md)
* [Reporting issues](./report-issues.md)
* [Reporting issues](./report-issues.md)
* [Release Notes](./release-notes.md)
35 changes: 11 additions & 24 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
## The following is for the BETA version only!

You may install the beta via:

`npm install swagger@beta -g`

## Configuration

Swagger-Node application configuration is driven by the file `default.yaml` in the application's config directory. By
default, the configuration file looks something like this:
** NOTE: The following applies to swagger-node apps replying on swagger-node-runner 0.5.x and better. (ie. Any app using swagger-connect 0.1.0, swagger-express-wm 0.1.0, swagger-hapi 0.1.0, swagger-restify 0.1.0, or swagger-sails 0.1.0 - or higher versions of the same.) **

Swagger-Node application configuration is driven by the file `default.yaml` (by default) in the application's config directory. Configuration is driven by the [config](https://github.com/lorenwest/node-config/wiki/Configuration-Files) module, so reference its documentation to understand how you may set up configuration per environment and perform configuration overrides. By default, the configuration file looks something like this:

```yaml
# swagger configuration file
Expand Down Expand Up @@ -60,7 +55,7 @@ Let's walk through the configuration:

### fittingsDirs

Defines the directories Bagpipes will search for fittings that are defined or used in the bagpipes section below.
Defines the directories Bagpipes will search for fittings that are defined or used in the bagpipes section below. Fittings are extension plugins that can either be installed (eg. https://www.npmjs.com/package/volos-swagger-oauth and https://www.npmjs.com/package/volos-swagger-apply) or written into your application directly.

### defaultPipe

Expand All @@ -73,23 +68,19 @@ extension `x-swagger-router-controller`). We'll look at how that's defined in a

### bagpipes

This block is the configuration passed to the [bagpipes](https://github.com/apigee-127/bagpipes) underlying the
application. As you can see, it defines not only the flow, but configuration of the elements as well. Let's look at
those as well.
This block is the configuration passed to the [bagpipes](https://github.com/apigee-127/bagpipes) underlying the application. As you can see, it defines not only the flow, but also the configuration of the elements.

#### _router

This configures the standard swagger-node router (currently swagger-tools). It tells it how to find your controllers,
your mock controllers, and whether to run in mock mode.
This configures the standard swagger-node router (currently swagger-tools). It tells it how to find your controllers, your mock controllers, and whether to run in mock mode.

#### _swagger_validate

This configures the swagger validator (currently swagger-tools). You can turn response validation on and off here.

#### swagger_controllers

Because this is specified as your controller pipe (in the `swaggerControllerPipe` setting above), this pipe plays
for all paths and operations where you'veare specified a controller extension (`x-swagger-router-controller`).
Because this is specified as your controller pipe (in the `swaggerControllerPipe` setting above), this pipe plays for all paths and operations where you'veare specified a controller extension (`x-swagger-router-controller`).

The default pipe is as follows:

Expand All @@ -101,23 +92,19 @@ The default pipe is as follows:
get, set, status).
6. run the router (currently swagger-tools)

As you can see, you have full control over the pipeline and may add or remove elements you need for your specific
application and environment.
As you can see, you have full control over the pipeline and may add or remove elements you need for your specific application and environment.

#### swagger_raw

This serves your swagger file - on the path that is defined in your `api/swagger/swagger.yaml` and tagged with the
`x-swagger-pipe` extension. It looks like this:
This serves your swagger file - on the path that is defined in your `api/swagger/swagger.yaml` and tagged with the `x-swagger-pipe` extension. It looks like this:

```yaml
/swagger:
x-swagger-pipe: swagger_raw
```
Note: This automatically filters out all sections that are swagger extensions (`x-*`) by using a predefined regular
expression: `/^(?!x-.*)/`.
Note: This automatically filters out all sections that are swagger extensions (`x-*`) by using a predefined regular expression: `/^(?!x-.*)/`.

Naturally, if you don't wish to serve your swagger on this path or at all, you may change or remove this.

This also conveniently serves as an example of how to map a path in your Swagger to a pipe. You may, of course, define
and use any pipes you wish using any of the Bagpipes operations or add your own in your fittings directory.
This also conveniently serves as an example of how to map a path in your Swagger to a pipe. You may, of course, define and use any pipes you wish using any of the Bagpipes operations or add your own in your fittings directory.
33 changes: 33 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Release Notes

### swagger-node 0.7.0, swagger-node-runner 0.5.0

#### New features

* Request handing pipeline is now fully configurable
* Application configuration is now driven by the [config module](https://github.com/lorenwest/node-config/wiki/Configuration-Files) to allow a ton of flexibility in setting up configurations and routes based on environment.
* [Security handlers]() can be declared in config in app.js. Example:

```javascript
config.swaggerSecurityHandlers = {
oauth2: function securityHandler1(req, authOrSecDef, scopesOrApiKey, cb) {
// your security code
cb();
}
};
```

#### Bug Fixes

* json_error_handler should work in all container environments (mapErrorsToJson did not)

#### Breaking Changes

* `mapErrorsToJson` config option is now configured as an onError handler: `onError: json_error_handler`
* `docEndpoints` raw config option is now declared in Swagger and handled via a pipe: `swagger_raw`

#### Converting From Previous Version

1. Update your package.json to use the new middleware versions: "^0.1.0". (eg. "swagger-connect": "^0.1.0")
2. Update your application dependencies: npm update.
3. Existing config should generally work, but you should update your config to the [new format](./configuration.md).

0 comments on commit 802fc77

Please sign in to comment.