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
Copy file name to clipboardExpand all lines: README.md
+72-42
Original file line number
Diff line number
Diff line change
@@ -1,38 +1,28 @@
1
-
# Serverless OpenAPI v3 Documentation Plugin
2
1
3
-
This plugin generates OpenAPI v3 documentation from serverless configuration files. OpenAPI is formerly known as Swagger. The configuration is extends the format specified by [serverless-aws-documentation](https://www.npmjs.com/package/serverless-aws-documentation).
Next you need to add the plugin to the `plugins` section of your `serverless.yml` file.
6
+
# Serverless OpenAPI Documentation Plugin
23
7
24
-
```yml
25
-
plugins:
26
-
- serverless-openapi-documentation
27
-
```
8
+
Generates [**OpenAPI 3.0 RC2**](https://github.com/OAI/OpenAPI-Specification/tree/OpenAPI.next) documentation from serverless configuration files. OpenAPI is formerly known as Swagger. The configuration is inspired by the format used in [serverless-aws-documentation](https://www.npmjs.com/package/serverless-aws-documentation).
28
9
29
-
You can confirm the plugin is correctly installed by running:
To configure this plugin to generate valid OpenAPI documentation there are two places you'll need to modify in your `serverless.yml` file, the `custom` variables section and the `http` event section for each given function in your service.
59
51
60
-
This plugin is compatible with the same documentation configuration as per[serverless-aws-documentation](https://www.npmjs.com/package/serverless-aws-documentation) and can run beside it.
52
+
This plugin is compatible with the same documentation configuration structure in[serverless-aws-documentation](https://www.npmjs.com/package/serverless-aws-documentation) and can run beside it.
61
53
62
54
The `custom` section of your `serverless.yml` can be configured as below:
63
55
@@ -67,18 +59,27 @@ custom:
67
59
version: '1'
68
60
summary: 'My API'
69
61
description: 'This is my API'
62
+
models: {}
70
63
```
71
64
72
-
If you find this configuration too verbose, you can separate it out into it's own file, such as `serverless.doc.yml` by replacing it with the following:
65
+
These configurations can be quite verbose; you can separate it out into it's own file, such as `serverless.doc.yml` as below:
And instead putting the `documentation` section directly into `serverless.doc.yml`.
80
+
For more info on `serverless.yml` syntax, see their docs.
80
81
81
-
#### Defining models
82
+
#### Models
82
83
83
84
Models contain additional information that you can use to define schemas for endpoints. You must define the *content type* for each schema that you provide in the models.
84
85
@@ -114,7 +115,7 @@ custom:
114
115
type: "string"
115
116
```
116
117
117
-
### Function event specific documentation
118
+
#### Functions
118
119
119
120
To define the documentation for a given function event, you need to create a `documentation` attribute for your http event in your `serverless.yml` file.
120
121
@@ -182,7 +183,7 @@ functions:
182
183
application/json: "ErrorResponse"
183
184
```
184
185
185
-
#### queryParams
186
+
#### `queryParams`
186
187
187
188
Query parameters can be described as follow:
188
189
@@ -200,7 +201,7 @@ queryParams:
200
201
type: "string"
201
202
```
202
203
203
-
#### pathParams
204
+
#### `pathParams`
204
205
205
206
Path parameters can be described as follow:
206
207
@@ -216,7 +217,7 @@ pathParams:
216
217
type: "string"
217
218
```
218
219
219
-
#### cookieParams
220
+
#### `cookieParams`
220
221
221
222
Cookie parameters can be described as follow:
222
223
@@ -234,7 +235,7 @@ cookieParams:
234
235
type: "string"
235
236
```
236
237
237
-
#### requestModels
238
+
#### `requestModels`
238
239
239
240
The `requestModels` property allows you to define models for the HTTP Request of the function event. You can define a different model for each different `Content-Type`. You can define a reference to the relevant request model named in the `models` section of your configuration (see [Defining Models](#defining-models) section).
240
241
@@ -244,7 +245,7 @@ requestModels:
244
245
application/xml: "CreateRequestXML"
245
246
```
246
247
247
-
#### methodResponses
248
+
#### `methodResponses`
248
249
249
250
You can define the response schemas by defining properties for your function event.
250
251
@@ -263,7 +264,7 @@ methodResponse:
263
264
application/xml: "CreateResponseXML"
264
265
```
265
266
266
-
##### responseModels
267
+
##### `responseModels`
267
268
268
269
The `responseModels` property allows you to define models for the HTTP Response of the function event. You can define a different model for each different `Content-Type`. You can define a reference to the relevant response model named in the `models` section of your configuration (see [Defining Models](#defining-models) section).
269
270
@@ -273,7 +274,7 @@ responseModels:
273
274
application/xml: "CreateResponseXML"
274
275
```
275
276
276
-
##### responseHeaders
277
+
##### `responseHeaders`
277
278
278
279
The `responseHeaders` section of the configuration allows you to define the HTTP response headers for the function event.
279
280
@@ -295,8 +296,37 @@ responseHeaders:
295
296
296
297
Please view the example [serverless.yml](test/serverless.yml).
297
298
298
-
## Contribution
299
-
`Insert: information on contibution here`
299
+
## Install
300
+
301
+
This plugin works for Serverless 1.x and up. Serverless 0.5 is not supported.
0 commit comments