serverless-openapi-documenter 0.0.19 → 0.2.2
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 +13 -13
- package/package.json +3 -3
- package/src/definitionGenerator.js +25 -32
- package/test/unit/definitionGenerator.spec.js +8 -72
- package/test/serverless 1/package-lock.json +0 -15981
- package/test/serverless 1/package.json +0 -14
- package/test/serverless 1/serverless.docs.yml +0 -62
- package/test/serverless 1/serverless.yml +0 -79
- package/test/serverless 2/index.js +0 -220
- package/test/serverless 2/package-lock.json +0 -12898
- package/test/serverless 2/package.json +0 -14
- package/test/serverless 2/serverless.docs.yml +0 -62
- package/test/serverless 2/serverless.yml +0 -121
- package/test/serverless 3/serverless.docs.yml +0 -62
- package/test/serverless 3/serverless.yml +0 -88
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "serverless-1",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"author": "",
|
|
10
|
-
"license": "ISC",
|
|
11
|
-
"devDependencies": {
|
|
12
|
-
"serverless": "^1.83.3"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
endpoints:
|
|
2
|
-
createUser:
|
|
3
|
-
summary: Create User
|
|
4
|
-
description: Creates a user and then sends a generated password email
|
|
5
|
-
requestBody:
|
|
6
|
-
description: A user information object
|
|
7
|
-
requestModels:
|
|
8
|
-
application/json: PutDocumentRequest
|
|
9
|
-
pathParams:
|
|
10
|
-
- name: username
|
|
11
|
-
description: The username for a user to create
|
|
12
|
-
schema:
|
|
13
|
-
type: string
|
|
14
|
-
pattern: "^[-a-z0-9_]+$"
|
|
15
|
-
queryParams:
|
|
16
|
-
- name: membershipType
|
|
17
|
-
description: The user's Membership Type
|
|
18
|
-
schema:
|
|
19
|
-
type: string
|
|
20
|
-
enum:
|
|
21
|
-
- premium
|
|
22
|
-
- standard
|
|
23
|
-
cookieParams:
|
|
24
|
-
- name: SessionId
|
|
25
|
-
description: A Session ID variable
|
|
26
|
-
schema:
|
|
27
|
-
type: string
|
|
28
|
-
methodResponses:
|
|
29
|
-
- statusCode: 201
|
|
30
|
-
responseBody:
|
|
31
|
-
description: A user object along with generated API Keys
|
|
32
|
-
responseModels:
|
|
33
|
-
application/json: PutDocumentResponse
|
|
34
|
-
- statusCode: 500
|
|
35
|
-
responseBody:
|
|
36
|
-
description: An error message when creating a new user
|
|
37
|
-
responseModels:
|
|
38
|
-
application/json: ErrorResponse
|
|
39
|
-
|
|
40
|
-
documentation:
|
|
41
|
-
models:
|
|
42
|
-
- name: ErrorResponse
|
|
43
|
-
description: This is an error
|
|
44
|
-
contentType: application/json
|
|
45
|
-
schema: ${file(models/ErrorResponse.json)}
|
|
46
|
-
|
|
47
|
-
- name: PutDocumentResponse
|
|
48
|
-
description: PUT Document response model (external reference example)
|
|
49
|
-
contentType: application/json
|
|
50
|
-
schema: ${file(models/PutDocumentResponse.json)}
|
|
51
|
-
|
|
52
|
-
- name: PutDocumentRequest
|
|
53
|
-
description: PUT Document request model (inline example)
|
|
54
|
-
contentType: application/json
|
|
55
|
-
schema:
|
|
56
|
-
$schema: http://json-schema.org/draft-04/schema#
|
|
57
|
-
properties:
|
|
58
|
-
SomeObject:
|
|
59
|
-
type: object
|
|
60
|
-
properties:
|
|
61
|
-
SomeAttribute:
|
|
62
|
-
type: string
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
service: serverless-openapi-doc-demo
|
|
2
|
-
frameworkVersion: ">=1.0.0 < 2.0.0"
|
|
3
|
-
enableLocalInstallationFallback: true
|
|
4
|
-
provider:
|
|
5
|
-
name: aws
|
|
6
|
-
runtime: nodejs14.x
|
|
7
|
-
|
|
8
|
-
plugins:
|
|
9
|
-
- ../../index.js
|
|
10
|
-
|
|
11
|
-
functions:
|
|
12
|
-
createUser:
|
|
13
|
-
handler: handler.create
|
|
14
|
-
events:
|
|
15
|
-
- http:
|
|
16
|
-
path: create
|
|
17
|
-
method: post
|
|
18
|
-
documentation:
|
|
19
|
-
summary: Create User
|
|
20
|
-
description: Creates a user and then sends a generated password email
|
|
21
|
-
requestBody:
|
|
22
|
-
description: A user information object
|
|
23
|
-
requestModels:
|
|
24
|
-
application/json: PutDocumentRequest
|
|
25
|
-
pathParams:
|
|
26
|
-
- name: username
|
|
27
|
-
description: The username for a user to create
|
|
28
|
-
schema:
|
|
29
|
-
type: string
|
|
30
|
-
pattern: "^[-a-z0-9_]+$"
|
|
31
|
-
queryParams:
|
|
32
|
-
- name: membershipType
|
|
33
|
-
description: The user's Membership Type
|
|
34
|
-
schema:
|
|
35
|
-
type: string
|
|
36
|
-
enum:
|
|
37
|
-
- premium
|
|
38
|
-
- standard
|
|
39
|
-
cookieParams:
|
|
40
|
-
- name: SessionId
|
|
41
|
-
description: A Session ID variable
|
|
42
|
-
schema:
|
|
43
|
-
type: string
|
|
44
|
-
methodResponses:
|
|
45
|
-
- statusCode: 201
|
|
46
|
-
responseBody:
|
|
47
|
-
description: A user object along with generated API Keys
|
|
48
|
-
responseModels:
|
|
49
|
-
application/json: PutDocumentResponse
|
|
50
|
-
- statusCode: 500
|
|
51
|
-
responseBody:
|
|
52
|
-
description: An error message when creating a new user
|
|
53
|
-
responseModels:
|
|
54
|
-
application/json: ErrorResponse
|
|
55
|
-
|
|
56
|
-
custom:
|
|
57
|
-
documentation:
|
|
58
|
-
models:
|
|
59
|
-
- name: ErrorResponse
|
|
60
|
-
description: This is an error
|
|
61
|
-
contentType: application/json
|
|
62
|
-
schema: ${file(models/ErrorResponse.json)}
|
|
63
|
-
|
|
64
|
-
- name: PutDocumentResponse
|
|
65
|
-
description: PUT Document response model (external reference example)
|
|
66
|
-
contentType: application/json
|
|
67
|
-
schema: ${file(models/PutDocumentResponse.json)}
|
|
68
|
-
|
|
69
|
-
- name: PutDocumentRequest
|
|
70
|
-
description: PUT Document request model (inline example)
|
|
71
|
-
contentType: application/json
|
|
72
|
-
schema:
|
|
73
|
-
$schema: http://json-schema.org/draft-04/schema#
|
|
74
|
-
properties:
|
|
75
|
-
SomeObject:
|
|
76
|
-
type: object
|
|
77
|
-
properties:
|
|
78
|
-
SomeAttribute:
|
|
79
|
-
type: string
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
const openApi = {
|
|
2
|
-
openapi: '3.0.0',
|
|
3
|
-
info: {
|
|
4
|
-
title: 'serverless-openapi-doc-demo',
|
|
5
|
-
description: 'This is a description of what this does',
|
|
6
|
-
version: '1.0.0'
|
|
7
|
-
},
|
|
8
|
-
components: {
|
|
9
|
-
// requestBodies: {
|
|
10
|
-
|
|
11
|
-
// },
|
|
12
|
-
responses: {
|
|
13
|
-
PutDocumentResponse: {
|
|
14
|
-
description: 'PUT Document response model (external reference example)',
|
|
15
|
-
content: {
|
|
16
|
-
'application/json': { schema: { title: 'Empty Schema', type: 'object' } }
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
// ErrorResponse: {
|
|
20
|
-
// description: 'This is an error',
|
|
21
|
-
// content: {
|
|
22
|
-
// 'application/json': {
|
|
23
|
-
// schema: {
|
|
24
|
-
// title: 'JSON API Schema',
|
|
25
|
-
// description: 'This is a schema for responses in the JSON API format. For more, see http://jsonapi.org',
|
|
26
|
-
// type: 'object',
|
|
27
|
-
// required: [ 'errors' ],
|
|
28
|
-
// properties: {
|
|
29
|
-
// errors: {
|
|
30
|
-
// type: 'array',
|
|
31
|
-
// items: { '$ref': '#/components/schemas/error' },
|
|
32
|
-
// uniqueItems: true
|
|
33
|
-
// },
|
|
34
|
-
// meta: { '$ref': '#/components/schemas/meta' },
|
|
35
|
-
// links: { '$ref': '#/components/schemas/links' }
|
|
36
|
-
// },
|
|
37
|
-
// additionalProperties: false
|
|
38
|
-
// }
|
|
39
|
-
// }
|
|
40
|
-
// }
|
|
41
|
-
// }
|
|
42
|
-
},
|
|
43
|
-
schemas: {
|
|
44
|
-
PutDocumentRequest: {
|
|
45
|
-
// description: 'PUT Document request model (inline example)',
|
|
46
|
-
// content: {
|
|
47
|
-
// 'application/json': {
|
|
48
|
-
// schema: {
|
|
49
|
-
properties: {
|
|
50
|
-
SomeObject: {
|
|
51
|
-
type: 'object',
|
|
52
|
-
properties: { SomeAttribute: { type: 'string' } }
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// }
|
|
56
|
-
// }
|
|
57
|
-
// }
|
|
58
|
-
},
|
|
59
|
-
error: {
|
|
60
|
-
type: 'object',
|
|
61
|
-
properties: {
|
|
62
|
-
id: {
|
|
63
|
-
description: 'A unique identifier for this particular occurrence of the problem.',
|
|
64
|
-
type: 'string'
|
|
65
|
-
},
|
|
66
|
-
links: { '$ref': '#/components/schemas/links' },
|
|
67
|
-
status: {
|
|
68
|
-
description: 'The HTTP status code applicable to this problem, expressed as a string value.',
|
|
69
|
-
type: 'string'
|
|
70
|
-
},
|
|
71
|
-
code: {
|
|
72
|
-
description: 'An application-specific error code, expressed as a string value.',
|
|
73
|
-
type: 'string'
|
|
74
|
-
},
|
|
75
|
-
title: {
|
|
76
|
-
description: 'A short, human-readable summary of the problem. It **SHOULD NOT** change from occurrence to occurrence of the problem, except for purposes of localization.',
|
|
77
|
-
type: 'string'
|
|
78
|
-
},
|
|
79
|
-
detail: {
|
|
80
|
-
description: 'A human-readable explanation specific to this occurrence of the problem.',
|
|
81
|
-
type: 'string'
|
|
82
|
-
},
|
|
83
|
-
source: {
|
|
84
|
-
type: 'object',
|
|
85
|
-
properties: {
|
|
86
|
-
pointer: {
|
|
87
|
-
description: 'A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute].',
|
|
88
|
-
type: 'string'
|
|
89
|
-
},
|
|
90
|
-
parameter: {
|
|
91
|
-
description: 'A string indicating which query parameter caused the error.',
|
|
92
|
-
type: 'string'
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
meta: { '$ref': '#/components/schemas/meta' }
|
|
97
|
-
},
|
|
98
|
-
additionalProperties: false
|
|
99
|
-
},
|
|
100
|
-
meta: {
|
|
101
|
-
description: 'Non-standard meta-information that can not be represented as an attribute or relationship.',
|
|
102
|
-
type: 'object',
|
|
103
|
-
additionalProperties: true
|
|
104
|
-
},
|
|
105
|
-
links: {
|
|
106
|
-
description: `A resource object **MAY** contain references to other resource objects ("relationships"). Relationships may be to-one or to-many. Relationships can be specified by including a member in a resource's links object.`,
|
|
107
|
-
type: 'object',
|
|
108
|
-
properties: {
|
|
109
|
-
self: {
|
|
110
|
-
description: 'A `self` member, whose value is a URL for the relationship itself (a "relationship URL"). This URL allows the client to directly manipulate the relationship. For example, it would allow a client to remove an `author` from an `article` without deleting the people resource itself.',
|
|
111
|
-
type: 'string',
|
|
112
|
-
format: 'uri'
|
|
113
|
-
},
|
|
114
|
-
related: { '$ref': '#/components/schemas/link' }
|
|
115
|
-
},
|
|
116
|
-
additionalProperties: true
|
|
117
|
-
},
|
|
118
|
-
link: {
|
|
119
|
-
description: "A link **MUST** be represented as either: a string containing the link's URL or a link object.",
|
|
120
|
-
oneOf: [
|
|
121
|
-
{
|
|
122
|
-
description: "A string containing the link's URL.",
|
|
123
|
-
type: 'string',
|
|
124
|
-
format: 'uri'
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
type: 'object',
|
|
128
|
-
required: [ 'href' ],
|
|
129
|
-
properties: {
|
|
130
|
-
href: {
|
|
131
|
-
description: "A string containing the link's URL.",
|
|
132
|
-
type: 'string',
|
|
133
|
-
format: 'uri'
|
|
134
|
-
},
|
|
135
|
-
meta: { '$ref': '#/components/schemas/meta' }
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
]
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
paths: {
|
|
143
|
-
'/create/{username}': {
|
|
144
|
-
post: {
|
|
145
|
-
summary: 'Create User',
|
|
146
|
-
description: 'Creates a user and then sends a generated password email',
|
|
147
|
-
operationId: 'a8a77f9b-da84-48c3-9265-5dce491d4749',
|
|
148
|
-
parameters: [
|
|
149
|
-
{
|
|
150
|
-
name: 'username',
|
|
151
|
-
in: 'path',
|
|
152
|
-
description: 'The username for a user to create',
|
|
153
|
-
required: true,
|
|
154
|
-
schema: { type: 'string', pattern: '^[-a-z0-9_]+$' }
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: 'membershipType',
|
|
158
|
-
in: 'query',
|
|
159
|
-
description: "The user's Membership Type",
|
|
160
|
-
required: false,
|
|
161
|
-
schema: { type: 'string', enum: [ 'premium', 'standard' ] }
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
name: 'SessionId',
|
|
165
|
-
in: 'cookie',
|
|
166
|
-
description: 'A Session ID variable',
|
|
167
|
-
required: false,
|
|
168
|
-
schema: { type: 'string' }
|
|
169
|
-
}
|
|
170
|
-
],
|
|
171
|
-
requestBody: {
|
|
172
|
-
description: 'A user information object',
|
|
173
|
-
required: false,
|
|
174
|
-
// schema: {
|
|
175
|
-
// '$ref': '#/components/requestBodies/PutDocumentRequest'
|
|
176
|
-
// }
|
|
177
|
-
content: {
|
|
178
|
-
'application/json': {
|
|
179
|
-
schema: {
|
|
180
|
-
'$ref': '#/components/schemas/PutDocumentRequest'
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
responses: {
|
|
186
|
-
'201': {
|
|
187
|
-
description: 'A user object along with generated API Keys',
|
|
188
|
-
// content: {
|
|
189
|
-
// 'application/json': {
|
|
190
|
-
// schema: {
|
|
191
|
-
// '$ref': '#/components/responses/PutDocumentResponse'
|
|
192
|
-
// }
|
|
193
|
-
// }
|
|
194
|
-
// }
|
|
195
|
-
// },
|
|
196
|
-
// '500': {
|
|
197
|
-
// description: 'An error message when creating a new user',
|
|
198
|
-
// content: {
|
|
199
|
-
// 'application/json': {
|
|
200
|
-
// schema: { '$ref': '#/components/responses/ErrorResponse' }
|
|
201
|
-
// }
|
|
202
|
-
// }
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const validator = require('oas-validator');
|
|
212
|
-
const main = async () => {
|
|
213
|
-
await validator.validateInner(openApi, {})
|
|
214
|
-
.catch(err => {
|
|
215
|
-
console.error(err)
|
|
216
|
-
})
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
main()
|
|
220
|
-
|