You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -21,13 +21,36 @@ The idea is to place the proxy between a client (e.g. a frontend app) and a web
21
21
</picture>
22
22
</p>
23
23
24
+
## Requirements
25
+
26
+
We run all tests with Node.js versions 10 and 12. Higher versions could possibly work but are not currently
27
+
supported.
28
+
24
29
## Installation
25
30
26
-
Do `npm install -g openapi-cop`, or `npm install openapi-cop` to install locally.
31
+
To install the CLI globally:
32
+
```npm install -g openapi-cop```
33
+
34
+
To install the package locally (inside an existing NPM package) and run the proxy programatically:
35
+
```npm install openapi-cop```
36
+
37
+
We also publish a Docker image [lxlu/openapi-cop](https://hub.docker.com/r/lxlu/openapi-cop) that you can use for your
38
+
convenience. This means you can also run openapi-cop with
39
+
something like
40
+
```docker run --rm -p 8888:8888 lxlu/openapi-cop```
41
+
42
+
## Usage
43
+
44
+
There are three ways to run openapi-cop:
27
45
28
-
## CLI Usage
46
+
1. Start it with the CLI.
47
+
2. Run it programatically inside Node.js.
48
+
3. Start a container based on the Docker image.
29
49
30
-
The *openapi-cop* node package installs itself as an executable linked as `openapi-cop`. Run the command with the `--help` flag to get information about the CLI:
50
+
### CLI Usage
51
+
52
+
The *openapi-cop* node package installs itself as an executable linked as `openapi-cop`. Run the command with
53
+
the `--help` flag to get information about the CLI:
31
54
32
55
```txt
33
56
Usage: openapi-cop [options]
@@ -46,92 +69,93 @@ Options:
46
69
-h, --help output usage information
47
70
```
48
71
49
-
The proxy validates the requests and responses in the communication with a target server. By default, the proxy will respond with a 500 status code when the validation fails.
72
+
The proxy validates the requests and responses in the communication with a target server. By default, the proxy will
73
+
respond with a 500 status code when the validation fails.
@@ -160,7 +184,7 @@ Two headers are added to the response:
160
184
```
161
185
162
186
</details>
163
-
187
+
164
188
-`openapi-cop-source-request`: contains a simplified version of the original request sent by the client as JSON.
165
189
166
190
<details><summary>Interface</summary>
@@ -181,11 +205,13 @@ Two headers are added to the response:
181
205
182
206
</details>
183
207
184
-
See the references of [OpenAPI Backend](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md) and [Ajv](https://ajv.js.org/) for more information.
208
+
See the references of [OpenAPI Backend](https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md)
209
+
and [Ajv](https://ajv.js.org/) for more information.
185
210
186
-
When the `--silent` is provided, the proxy will forward the server's response body without modification. In this case, the validation headers are still added.
211
+
When the `--silent` is provided, the proxy will forward the server's response body without modification. In this case,
212
+
the validation headers are still added.
187
213
188
-
####Module Usage
214
+
### Module Usage
189
215
190
216
To run the proxy programatically use `runProxy`, which returns a `Promise<http.Server>`:
191
217
@@ -202,7 +228,6 @@ const server = await runProxy({
0 commit comments