serverless-openapi-documenter 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/node.yml +1 -1
- package/README.md +61 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,7 @@ Options:
|
|
|
63
63
|
| externalDocs.url | custom.documentation.externalDocumentation.url |
|
|
64
64
|
| servers[].description | custom.documentation.servers.description |
|
|
65
65
|
| servers[].url | custom.documentation.servers.url |
|
|
66
|
+
| servers[].variables | custom.documentation.servers.variables |
|
|
66
67
|
| tags[].name | custom.documentation.tags.name |
|
|
67
68
|
| tags[].description | custom.documentation.tags.description |
|
|
68
69
|
| tags[].externalDocs.url | custom.documentation.tags.externalDocumentation.url |
|
|
@@ -121,8 +122,15 @@ custom:
|
|
|
121
122
|
url: https://google.com
|
|
122
123
|
description: A link to google
|
|
123
124
|
servers:
|
|
124
|
-
url: https://example.com
|
|
125
|
+
url: https://example.com:{port}/
|
|
125
126
|
description: The server
|
|
127
|
+
variables:
|
|
128
|
+
port:
|
|
129
|
+
enum:
|
|
130
|
+
- 4000
|
|
131
|
+
- 3000
|
|
132
|
+
default: 3000
|
|
133
|
+
description: The port the server operates on
|
|
126
134
|
tags:
|
|
127
135
|
- name: tag1
|
|
128
136
|
description: this is a tag
|
|
@@ -222,6 +230,39 @@ custom:
|
|
|
222
230
|
type: "string"
|
|
223
231
|
```
|
|
224
232
|
|
|
233
|
+
##### Model re-use
|
|
234
|
+
|
|
235
|
+
Through the magic of YAML, you can re-use models:
|
|
236
|
+
|
|
237
|
+
```yml
|
|
238
|
+
custom:
|
|
239
|
+
documentation:
|
|
240
|
+
...
|
|
241
|
+
models:
|
|
242
|
+
- name: "ErrorResponse"
|
|
243
|
+
description: "This is an error"
|
|
244
|
+
content:
|
|
245
|
+
application/json:
|
|
246
|
+
schema: &ErrorItem
|
|
247
|
+
type: object
|
|
248
|
+
properties:
|
|
249
|
+
message:
|
|
250
|
+
type: string
|
|
251
|
+
code:
|
|
252
|
+
type: integer
|
|
253
|
+
|
|
254
|
+
- name: "PutDocumentResponse"
|
|
255
|
+
description: "PUT Document response model (external reference example)"
|
|
256
|
+
content:
|
|
257
|
+
application/json:
|
|
258
|
+
schema:
|
|
259
|
+
type: array
|
|
260
|
+
items: *ErrorItem
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
`&ErrorItem` in the above example creates a node anchor (&ErrorItem) to the `ErrorResponse` schema which then can be used in the `PutDocumentResponse` schema via the reference (*ErrorItem). The node anchor needs to be declared first before it can be used elsewhere via the reference, swapping the above example around would result in an error.
|
|
264
|
+
|
|
265
|
+
|
|
225
266
|
#### Functions
|
|
226
267
|
|
|
227
268
|
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.
|
|
@@ -238,6 +279,7 @@ The `documentation` section of the event configuration can contain the following
|
|
|
238
279
|
* `queryParams`: a list of query parameters (see [queryParams](#queryparams) below)
|
|
239
280
|
* `pathParams`: a list of path parameters (see [pathParams](#pathparams) below)
|
|
240
281
|
* `cookieParams`: a list of cookie parameters (see [cookieParams](#cookieparams) below)
|
|
282
|
+
* `headerParams`: a list of headers (see [headerParams](#headerparams---request-headers) below)
|
|
241
283
|
* `methodResponses`: an array of response models and applicable status codes
|
|
242
284
|
* `statusCode`: applicable http status code (ie. 200/404/500 etc.)
|
|
243
285
|
* `responseBody`: contains description of the response
|
|
@@ -285,12 +327,22 @@ functions:
|
|
|
285
327
|
description: "A Session ID variable"
|
|
286
328
|
schema:
|
|
287
329
|
type: "string"
|
|
330
|
+
headerParams:
|
|
331
|
+
name: "Content-Type"
|
|
332
|
+
description: "The content type"
|
|
333
|
+
schema:
|
|
334
|
+
type: "string"
|
|
288
335
|
methodResponses:
|
|
289
336
|
- statusCode: 201
|
|
290
337
|
responseBody:
|
|
291
338
|
description: "A user object along with generated API Keys"
|
|
292
339
|
responseModels:
|
|
293
340
|
application/json: "PutDocumentResponse"
|
|
341
|
+
responseHeaders:
|
|
342
|
+
X-Rate-Limit-Limit:
|
|
343
|
+
description: The number of allowed requests in the current period
|
|
344
|
+
schema:
|
|
345
|
+
type: integer
|
|
294
346
|
- statusCode: 500
|
|
295
347
|
responseBody:
|
|
296
348
|
description: "An error message when creating a new user"
|
|
@@ -320,8 +372,8 @@ queryParams:
|
|
|
320
372
|
|
|
321
373
|
Path parameters can be described as follow:
|
|
322
374
|
|
|
323
|
-
* `name`: the name of the
|
|
324
|
-
* `description`: a description of the
|
|
375
|
+
* `name`: the name of the path parameter
|
|
376
|
+
* `description`: a description of the path parameter
|
|
325
377
|
* `schema`: JSON schema (inline, file or externally hosted)
|
|
326
378
|
|
|
327
379
|
```yml
|
|
@@ -336,9 +388,9 @@ pathParams:
|
|
|
336
388
|
|
|
337
389
|
Cookie parameters can be described as follow:
|
|
338
390
|
|
|
339
|
-
* `name`: the name of the
|
|
340
|
-
* `description`: a description of the
|
|
341
|
-
* `required`: whether the
|
|
391
|
+
* `name`: the name of the cookie parameter
|
|
392
|
+
* `description`: a description of the cookie parameter
|
|
393
|
+
* `required`: whether the cookie parameter is mandatory (boolean)
|
|
342
394
|
* `schema`: JSON schema (inline, file or externally hosted)
|
|
343
395
|
|
|
344
396
|
```yml
|
|
@@ -354,9 +406,9 @@ cookieParams:
|
|
|
354
406
|
|
|
355
407
|
Request Headers can be described as follow:
|
|
356
408
|
|
|
357
|
-
* `name`: the name of the
|
|
358
|
-
* `description`: a description of the
|
|
359
|
-
* `required`: whether the
|
|
409
|
+
* `name`: the name of the header
|
|
410
|
+
* `description`: a description of the header
|
|
411
|
+
* `required`: whether the header is mandatory (boolean)
|
|
360
412
|
* `schema`: JSON schema (inline, file or externally hosted)
|
|
361
413
|
|
|
362
414
|
```yml
|