serverless-openapi-documenter 0.0.65 → 0.0.67
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/README.md +6 -4
- package/package.json +8 -3
- package/src/openAPIGenerator.js +22 -8
- package/test/unit/openAPIGenerator.spec.js +2 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
This will generate an OpenAPI V3 (up to v3.0.3) file for you from your serverless file. It can optionally generate a [Postman Collection V2](https://github.com/postmanlabs/openapi-to-postman) from the OpenAPI file for you too.
|
|
17
|
+
This will generate an OpenAPI V3 (up to v3.0.3) file for you from your serverless file. It can optionally generate a [Postman Collection V2](https://github.com/postmanlabs/openapi-to-postman) from the OpenAPI file for you too. This currently works for `http` and `httpApi` configurations.
|
|
18
18
|
|
|
19
19
|
Originally based off of: https://github.com/temando/serverless-openapi-documentation
|
|
20
20
|
|
|
@@ -131,7 +131,7 @@ Options:
|
|
|
131
131
|
|
|
132
132
|
### Configuration
|
|
133
133
|
|
|
134
|
-
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.
|
|
134
|
+
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/httpApi` event section for each given function in your service.
|
|
135
135
|
|
|
136
136
|
The `custom` section of your `serverless.yml` can be configured as below:
|
|
137
137
|
|
|
@@ -164,7 +164,7 @@ custom:
|
|
|
164
164
|
models: {}
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
Mostly everything here is optional. A version from a UUID will be generated for you if you don't specify one, title will be the name of your service if you don't specify one.
|
|
167
|
+
Mostly everything here is optional. A version from a UUID will be generated for you if you don't specify one, title will be the name of your service if you don't specify one. You will need to specify the `documentation` top object.
|
|
168
168
|
|
|
169
169
|
#### termsOfService
|
|
170
170
|
|
|
@@ -483,7 +483,7 @@ functions:
|
|
|
483
483
|
|
|
484
484
|
#### Functions
|
|
485
485
|
|
|
486
|
-
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.
|
|
486
|
+
To define the documentation for a given function event, you need to create a `documentation` attribute for your `http` or `httpApi` event in your `serverless.yml` file.
|
|
487
487
|
|
|
488
488
|
The `documentation` section of the event configuration can contain the following attributes:
|
|
489
489
|
|
|
@@ -506,6 +506,8 @@ The `documentation` section of the event configuration can contain the following
|
|
|
506
506
|
* `responseHeaders`: a list of response headers (see [responseHeaders](#responseheaders) below)
|
|
507
507
|
* `responseModels`: a list of models to describe the request bodies (see [responseModels](#responsemodels) below) for each `Content-Type`
|
|
508
508
|
|
|
509
|
+
If you don't want a `http` or `httpApi` event to be documented, you can leave off the `documentation` object. The configuration schema will only check that you have specified a `methodResponses` on the `documentation` event, previously the plugin would cause serverless to warn or error (depending on your `configValidationMode`) if you had not supplied a `documentation` on an event.
|
|
510
|
+
|
|
509
511
|
```yml
|
|
510
512
|
functions:
|
|
511
513
|
createUser:
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-openapi-documenter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.67",
|
|
4
4
|
"description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"serverless",
|
|
8
8
|
"serverless2",
|
|
9
|
+
"Serverless 2",
|
|
9
10
|
"serverless3",
|
|
11
|
+
"Serverless 3",
|
|
10
12
|
"serverless framework",
|
|
11
13
|
"serverless framework plugin",
|
|
12
14
|
"serverless plugin",
|
|
@@ -15,7 +17,10 @@
|
|
|
15
17
|
"openAPI3",
|
|
16
18
|
"PostmanCollections",
|
|
17
19
|
"Postman-Collections",
|
|
18
|
-
"Postman Collections"
|
|
20
|
+
"Postman Collections",
|
|
21
|
+
"AWS",
|
|
22
|
+
"AWS APIGateway",
|
|
23
|
+
"Api Gateway"
|
|
19
24
|
],
|
|
20
25
|
"scripts": {
|
|
21
26
|
"test": "mocha --config './test/.mocharc.js'"
|
|
@@ -38,7 +43,7 @@
|
|
|
38
43
|
"json-schema-for-openapi": "^0.3.2",
|
|
39
44
|
"lodash.isequal": "^4.5.0",
|
|
40
45
|
"oas-validator": "^5.0.8",
|
|
41
|
-
"openapi-to-postmanv2": "^4.
|
|
46
|
+
"openapi-to-postmanv2": "^4.15.0",
|
|
42
47
|
"swagger2openapi": "^7.0.8",
|
|
43
48
|
"uuid": "^9.0.0"
|
|
44
49
|
},
|
package/src/openAPIGenerator.js
CHANGED
|
@@ -71,19 +71,33 @@ class OpenAPIGenerator {
|
|
|
71
71
|
|
|
72
72
|
this.customVars = this.serverless.variables.service.custom;
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
const functionEventDocumentationSchema = {
|
|
75
75
|
properties: {
|
|
76
|
-
documentation: {
|
|
76
|
+
documentation: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
properties: {
|
|
79
|
+
methodResponses: {
|
|
80
|
+
type: 'array'
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
required: ['methodResponses']
|
|
84
|
+
},
|
|
77
85
|
},
|
|
78
|
-
|
|
79
|
-
});
|
|
86
|
+
}
|
|
80
87
|
|
|
81
|
-
this.serverless.configSchemaHandler.
|
|
88
|
+
this.serverless.configSchemaHandler.defineCustomProperties({
|
|
89
|
+
type: 'object',
|
|
82
90
|
properties: {
|
|
83
|
-
documentation: {
|
|
91
|
+
documentation: {
|
|
92
|
+
type: 'object'
|
|
93
|
+
}
|
|
84
94
|
},
|
|
85
|
-
required: ['documentation']
|
|
86
|
-
})
|
|
95
|
+
required: ['documentation']
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
this.serverless.configSchemaHandler.defineFunctionEventProperties('aws', 'http', functionEventDocumentationSchema);
|
|
99
|
+
|
|
100
|
+
this.serverless.configSchemaHandler.defineFunctionEventProperties('aws', 'httpApi', functionEventDocumentationSchema);
|
|
87
101
|
|
|
88
102
|
this.serverless.configSchemaHandler.defineFunctionProperties('aws', {
|
|
89
103
|
properties: {
|
|
@@ -31,7 +31,8 @@ describe('OpenAPIGenerator', () => {
|
|
|
31
31
|
},
|
|
32
32
|
configSchemaHandler: {
|
|
33
33
|
defineFunctionEventProperties: () => {},
|
|
34
|
-
defineFunctionProperties: () => {}
|
|
34
|
+
defineFunctionProperties: () => {},
|
|
35
|
+
defineCustomProperties: () => {},
|
|
35
36
|
},
|
|
36
37
|
classes: {
|
|
37
38
|
Error: class ServerlessError {constructor(err) {return new Error(err)}}
|