@asyncapi/generator 2.0.3 → 2.1.1

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.
Files changed (59) hide show
  1. package/.dockerignore +2 -0
  2. package/CHANGELOG.md +15 -0
  3. package/docs/configuration-file.md +2 -2
  4. package/docs/nunjucks-render-engine.md +2 -1
  5. package/jest.config.js +9 -0
  6. package/lib/__mocks__/filtersRegistry.js +3 -0
  7. package/lib/__mocks__/hooksRegistry.js +3 -0
  8. package/lib/__mocks__/templateConfigValidator.js +3 -0
  9. package/lib/__mocks__/utils.js +25 -0
  10. package/lib/filtersRegistry.js +14 -10
  11. package/package.json +9 -9
  12. package/test/__mocks__/@npmcli/arborist.js +11 -0
  13. package/test/__mocks__/@npmcli/config.js +3 -0
  14. package/test/__mocks__/fs.extra.js +3 -0
  15. package/test/__mocks__/loglevel.js +3 -0
  16. package/test/__mocks__/resolve-from.js +8 -0
  17. package/test/__mocks__/resolve-pkg.js +8 -0
  18. package/test/__snapshots__/integration.test.js.snap +25 -0
  19. package/test/docs/apiwithref.json +41 -0
  20. package/test/docs/dummy.yml +390 -0
  21. package/test/docs/dummyV3.yml +31 -0
  22. package/test/docs/shared.json +27 -0
  23. package/test/docs/ws.yml +36 -0
  24. package/test/generator.test.js +626 -0
  25. package/test/integration.test.js +58 -0
  26. package/test/parser.test.js +107 -0
  27. package/test/renderer.test.js +62 -0
  28. package/test/templateConfigValidator.test.js +277 -0
  29. package/test/test-project/.yarncr.yml +3 -0
  30. package/test/test-project/README.md +4 -0
  31. package/test/test-project/docker-compose.yml +24 -0
  32. package/test/test-project/package.json +25 -0
  33. package/test/test-project/test-entrypoint.sh +12 -0
  34. package/test/test-project/test-global.test.js +37 -0
  35. package/test/test-project/test-project.test.js +98 -0
  36. package/test/test-project/test-registry.test.js +55 -0
  37. package/test/test-project/test.sh +99 -0
  38. package/test/test-project/verdaccio/config.yaml +16 -0
  39. package/test/test-project/verdaccio/htpasswd +1 -0
  40. package/test/test-templates/nunjucks-template/package-lock.json +4143 -0
  41. package/test/test-templates/nunjucks-template/package.json +21 -0
  42. package/test/test-templates/nunjucks-template/template/test-file.md +5 -0
  43. package/test/test-templates/react-template/__transpiled/test-file.md.js +24 -0
  44. package/test/test-templates/react-template/__transpiled/test-file.md.js.map +1 -0
  45. package/test/test-templates/react-template/package-lock.json +4143 -0
  46. package/test/test-templates/react-template/package.json +23 -0
  47. package/test/test-templates/react-template/template/test-file.md.js +11 -0
  48. package/test/utils.test.js +76 -0
  49. package/.eslintignore +0 -5
  50. package/.eslintrc +0 -113
  51. package/.npmrc.template +0 -1
  52. package/.releaserc +0 -24
  53. package/.sonarcloud.properties +0 -2
  54. package/CODEOWNERS +0 -12
  55. package/CODE_OF_CONDUCT.md +0 -46
  56. package/CONTRIBUTING.md +0 -79
  57. package/LICENSE +0 -201
  58. package/README.md +0 -98
  59. package/assets/readme-banner.png +0 -0
@@ -0,0 +1,390 @@
1
+ asyncapi: '2.3.0'
2
+
3
+ externalDocs:
4
+ description: Find more info here
5
+ url: https://www.asyncapi.com
6
+
7
+ info:
8
+ title: Dummy example with all spec features included
9
+ version: '0.0.1'
10
+ description: |
11
+ This is an example of AsyncAPI specification file that is suppose to include all possible features of the AsyncAPI specification. Do not use it on production.
12
+
13
+ It's goal is to support development of documentation and code generation with the [AsyncAPI Generator](https://github.com/asyncapi/generator/) and [Template projects](https://github.com/search?q=topic%3Aasyncapi+topic%3Agenerator+topic%3Atemplate)
14
+ license:
15
+ name: Apache 2.0
16
+ url: https://www.apache.org/licenses/LICENSE-2.0
17
+ contact:
18
+ name: API Support
19
+ url: http://www.asyncapi.com/support
20
+ email: info@asyncapi.io
21
+ x-twitter: '@AsyncAPISpec'
22
+
23
+ tags:
24
+ - name: root-tag1
25
+ externalDocs:
26
+ description: External docs description 1
27
+ url: https://www.asyncapi.com/
28
+ - name: root-tag2
29
+ description: Description 2
30
+ externalDocs:
31
+ url: "https://www.asyncapi.com/"
32
+ - name: root-tag3
33
+ - name: root-tag4
34
+ description: Description 4
35
+ - name: root-tag5
36
+ externalDocs:
37
+ url: "https://www.asyncapi.com/"
38
+
39
+ servers:
40
+ dummy-mqtt:
41
+ $ref: '#/components/servers/dummyMQTT'
42
+ dummy-amqp:
43
+ url: amqp://localhost:{port}
44
+ protocol: amqp
45
+ description: dummy AMQP broker
46
+ protocolVersion: "0.9.1"
47
+ variables:
48
+ port:
49
+ enum:
50
+ - '15672'
51
+ - '5672'
52
+ security:
53
+ - user-password: []
54
+ dummy-kafka:
55
+ url: http://localhost:{port}
56
+ protocol: kafka
57
+ description: dummy Kafka broker
58
+ variables:
59
+ port:
60
+ default: '9092'
61
+
62
+ defaultContentType: application/json
63
+
64
+ channels:
65
+ dummy/channel/with/{dummy}/parameter/create:
66
+ x-dummy-security:
67
+ $ref: '#/components/securitySchemes/supportedOauthFlows/flows/clientCredentials'
68
+ description: Dummy channel description.
69
+ parameters:
70
+ dummy:
71
+ $ref: '#/components/parameters/dummy'
72
+ publish:
73
+ summary: Inform whenever something dummy is created.
74
+ description: |
75
+ Longer description.
76
+
77
+ Still dummy though.
78
+ operationId: receiveNewDummyInfo
79
+ tags:
80
+ - name: oparation-tag1
81
+ externalDocs:
82
+ description: External docs description 1
83
+ url: https://www.asyncapi.com/
84
+ - name: oparation-tag2
85
+ description: Description 2
86
+ externalDocs:
87
+ url: "https://www.asyncapi.com/"
88
+ - name: oparation-tag3
89
+ - name: oparation-tag4
90
+ description: Description 4
91
+ - name: oparation-tag5
92
+ externalDocs:
93
+ url: "https://www.asyncapi.com/"
94
+ traits:
95
+ - $ref: '#/components/operationTraits/kafka'
96
+ message:
97
+ $ref: '#/components/messages/dummyCreated'
98
+
99
+ dummy/channel/without/parameter:
100
+ $ref: '#/components/channels/dummyChannel'
101
+ components:
102
+ servers:
103
+ dummyMQTT:
104
+ url: mqtt://localhost
105
+ protocol: mqtt
106
+ description: dummy MQTT broker
107
+ bindings:
108
+ mqtt:
109
+ clientId: guest
110
+ cleanSession: true
111
+ channels:
112
+ dummyChannel:
113
+ bindings:
114
+ amqp:
115
+ is: routingKey
116
+ subscribe:
117
+ operationId: receiveSystemInfo
118
+ bindings:
119
+ amqp:
120
+ expiration: 100000
121
+ userId: guest
122
+ cc: [ 'user.logs' ]
123
+ priority: 10
124
+ deliveryMode: 2
125
+ mandatory: false
126
+ bcc: [ 'external.audit' ]
127
+ replyTo: user.signedup
128
+ timestamp: true
129
+ ack: false
130
+ bindingVersion: 0.1.0
131
+ message:
132
+ $ref: '#/components/messages/dummyInfo'
133
+ messages:
134
+ dummyCreated:
135
+ name: dummyCreated
136
+ title: Dummy created message
137
+ summary: This is just a dummy create message
138
+ correlationId:
139
+ description: This is a dummy correlation ID.
140
+ location: $message.header#/correlationId
141
+ tags:
142
+ - name: message-tag1
143
+ externalDocs:
144
+ description: External docs description 1
145
+ url: https://www.asyncapi.com/
146
+ - name: message-tag2
147
+ description: Description 2
148
+ externalDocs:
149
+ url: "https://www.asyncapi.com/"
150
+ - name: message-tag3
151
+ - name: message-tag4
152
+ description: Description 4
153
+ - name: message-tag5
154
+ externalDocs:
155
+ url: "https://www.asyncapi.com/"
156
+ headers:
157
+ type: object
158
+ properties:
159
+ my-custom-app-header:
160
+ type: string
161
+ correlationId:
162
+ type: string
163
+ payload:
164
+ $ref: "#/components/schemas/dummyCreated"
165
+ bindings:
166
+ kafka:
167
+ key:
168
+ type: object
169
+ properties:
170
+ id:
171
+ type: string
172
+ format: uuid
173
+ type:
174
+ type: string
175
+ enum: [ 'type1', "type2" ]
176
+ bindingVersion: '0.1.0'
177
+ amqp:
178
+ contentEncoding: gzip
179
+ messageType: 'user.signup'
180
+ bindingVersion: 0.1.0
181
+ x-response:
182
+ $ref: "#/components/messages/dummyInfo"
183
+ dummyInfo:
184
+ name: dummyInfo
185
+ title: Dummy system info
186
+ summary: This is just a dummy info message
187
+ correlationId:
188
+ location: $message.header#/correlationId
189
+ description: |
190
+ More description for a dummy message.
191
+
192
+ It is a dummy system info message.
193
+ traits:
194
+ - $ref: '#/components/messageTraits/commonHeaders'
195
+ payload:
196
+ $ref: "#/components/schemas/dummyInfo"
197
+ examples:
198
+ - name: option1example
199
+ summary: this is dummy summary for option1example
200
+ headers:
201
+ my-app-header: 12
202
+ payload:
203
+ prop1: option1
204
+ sentAt: 2020-01-31T13:24:53Z
205
+ - name: headerExample
206
+ headers:
207
+ my-app-header: 13
208
+ - payload:
209
+ prop1: option2
210
+ sentAt: 2020-01-31T13:24:53Z
211
+
212
+
213
+ schemas:
214
+ dummyCreated:
215
+ type: object
216
+ required:
217
+ - prop2
218
+ x-schema-extensions-as-object:
219
+ type: object
220
+ properties:
221
+ prop1:
222
+ type: string
223
+ prop2:
224
+ type: integer
225
+ minimum: 0
226
+ x-schema-extensions-as-primitive: dummy
227
+ x-schema-extensions-as-array:
228
+ - "item1"
229
+ - "item2"
230
+ properties:
231
+ prop1:
232
+ type: integer
233
+ minimum: 0
234
+ description: Dummy prop1
235
+ x-prop1-dummy: dummy extension
236
+ prop2:
237
+ type: string
238
+ description: Dummy prop2
239
+ sentAt:
240
+ $ref: "#/components/schemas/sentAt"
241
+ dummyArrayWithObject:
242
+ $ref: "#/components/schemas/dummyArrayWithObject"
243
+ dummyArrayWithArray:
244
+ $ref: "#/components/schemas/dummyArrayWithArray"
245
+ dummyObject:
246
+ $ref: "#/components/schemas/dummyObject"
247
+ dummyArrayRank:
248
+ $ref: '#/components/schemas/dummyArrayRank'
249
+ dummyInfo:
250
+ type: object
251
+ required:
252
+ - prop1
253
+ properties:
254
+ prop1:
255
+ type: string
256
+ enum:
257
+ - option1
258
+ - option2
259
+ description: Dummy prop1
260
+ sentAt:
261
+ $ref: "#/components/schemas/sentAt"
262
+ dummyArrayWithObject:
263
+ type: array
264
+ items:
265
+ $ref: "#/components/schemas/dummyInfo"
266
+ dummyArrayWithArray:
267
+ type: array
268
+ items:
269
+ - $ref: "#/components/schemas/dummyInfo"
270
+ - type: string
271
+ - type: number
272
+ dummyObject:
273
+ type: object
274
+ properties:
275
+ dummyObjectProp1:
276
+ $ref: "#/components/schemas/sentAt"
277
+ dummyObjectProp2:
278
+ $ref: "#/components/schemas/dummyRecursiveObject"
279
+ dummyObjectProp3:
280
+ type: object
281
+ additionalProperties: true
282
+ dummyObjectProp4:
283
+ type: object
284
+ additionalProperties: false
285
+ dummyRecursiveObject:
286
+ type: object
287
+ properties:
288
+ dummyRecursiveProp1:
289
+ $ref: "#/components/schemas/dummyObject"
290
+ dummyRecursiveProp2:
291
+ type: string
292
+ sentAt:
293
+ type: string
294
+ format: date-time
295
+ description: Date and time when the message was sent.
296
+ dummyArrayRank:
297
+ type: object
298
+ properties:
299
+ dummyArrayValueRank:
300
+ $ref: '#/components/schemas/dummyArrayValueRank'
301
+ dummyArrayDimensions:
302
+ $ref: '#/components/schemas/dummyArrayArrayDimensions'
303
+ dummyArrayValueRank:
304
+ description: >
305
+ This Attribute indicates whether the val Attribute of the datapoint is an
306
+ array and how many dimensions the array has.
307
+ type: integer
308
+ default: -1
309
+ examples:
310
+ - 2
311
+ oneOf:
312
+ - const: -1
313
+ description: 'Scalar: The value is not an array.'
314
+ - const: 0
315
+ description: 'OneOrMoreDimensions: The value is an array with one or more dimensions.'
316
+ - const: 1
317
+ description: 'OneDimension: The value is an array with one dimension.'
318
+ - const: 2
319
+ description: 'The value is an array with two dimensions.'
320
+ dummyArrayArrayDimensions:
321
+ type: array
322
+ items:
323
+ type: integer
324
+ minimum: 0
325
+ examples:
326
+ - [3, 5]
327
+
328
+ securitySchemes:
329
+ user-password:
330
+ type: userPassword
331
+ apiKey:
332
+ type: apiKey
333
+ in: user
334
+ description: Provide your API key as the user and leave the password empty.
335
+ supportedOauthFlows:
336
+ type: oauth2
337
+ description: Flows to support OAuth 2.0
338
+ flows:
339
+ implicit:
340
+ authorizationUrl: 'https://authserver.example/auth'
341
+ scopes:
342
+ 'dummy:created': Ability to create dummy message
343
+ 'dymmy:read': Ability to read dummy info
344
+ password:
345
+ tokenUrl: 'https://authserver.example/token'
346
+ scopes:
347
+ 'dummy:created': Ability to create dummy message
348
+ 'dymmy:read': Ability to read dummy info
349
+ clientCredentials:
350
+ tokenUrl: 'https://authserver.example/token'
351
+ scopes:
352
+ 'dummy:created': Ability to create dummy message
353
+ 'dymmy:read': Ability to read dummy info
354
+ authorizationCode:
355
+ authorizationUrl: 'https://authserver.example/auth'
356
+ tokenUrl: 'https://authserver.example/token'
357
+ refreshUrl: 'https://authserver.example/refresh'
358
+ scopes:
359
+ 'dummy:created': Ability to create dummy message
360
+ 'dymmy:read': Ability to read dummy info
361
+ openIdConnectWellKnown:
362
+ type: openIdConnect
363
+ openIdConnectUrl: 'https://authserver.example/.well-known'
364
+
365
+ parameters:
366
+ dummy:
367
+ description: The ID of the new dummy message.
368
+ schema:
369
+ type: string
370
+ description: Description that not be rendered, as parameter has explicit description.
371
+
372
+ messageTraits:
373
+ commonHeaders:
374
+ headers:
375
+ type: object
376
+ properties:
377
+ my-app-header:
378
+ type: integer
379
+ minimum: 0
380
+ maximum: 100
381
+ correlationId:
382
+ type: string
383
+
384
+ operationTraits:
385
+ kafka:
386
+ bindings:
387
+ kafka:
388
+ groupId: my-app-group-id
389
+ clientId: my-app-client-id
390
+ bindingVersion: '0.1.0'
@@ -0,0 +1,31 @@
1
+ asyncapi: 3.0.0
2
+ info:
3
+ title: Account Service
4
+ version: 1.0.0
5
+ description: This service is in charge of processing user signups
6
+ channels:
7
+ user/signedup:
8
+ address: user/signedup
9
+ messages:
10
+ UserSignedUp:
11
+ $ref: '#/components/messages/UserSignedUp'
12
+ operations:
13
+ user/signedup.subscribe:
14
+ action: send
15
+ channel:
16
+ $ref: '#/channels/user~1signedup'
17
+ messages:
18
+ - $ref: '#/channels/user~1signedup/messages/UserSignedUp'
19
+ components:
20
+ messages:
21
+ UserSignedUp:
22
+ payload:
23
+ type: object
24
+ properties:
25
+ displayName:
26
+ type: string
27
+ description: Name of the user
28
+ email:
29
+ type: string
30
+ format: email
31
+ description: Email of the user
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://schema.example.com/crm/shared.json",
4
+ "description": "Shared Customer Relationship Management models",
5
+ "type": "object",
6
+ "properties": {
7
+ "type": {
8
+ "enum": [
9
+ "CustomerProfile"
10
+ ]
11
+ },
12
+ "id": {
13
+ "type": "string",
14
+ "format": "uuid",
15
+ "example": "c0e5e95a-e26a-4d16-a185-32cb8f9725fc"
16
+ },
17
+ "attributes": {
18
+ "type": "object",
19
+ "properties": {
20
+ "name": {
21
+ "type": "string",
22
+ "example": "Mustermann"
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,36 @@
1
+ asyncapi: 2.0.0
2
+ info:
3
+ title: WebSockets echo server
4
+ version: 1.0.0
5
+
6
+ servers:
7
+ localhost:
8
+ url: localhost
9
+ protocol: ws
10
+
11
+ channels:
12
+ /echo:
13
+ bindings:
14
+ ws:
15
+ query:
16
+ type: object
17
+ properties:
18
+ times:
19
+ type: integer
20
+ description: How many times the message should be echoed.
21
+ minimum: 1
22
+ bindingVersion: 0.1.0
23
+ subscribe:
24
+ operationId: onEcho
25
+ message:
26
+ $ref: '#/components/messages/echo'
27
+ publish:
28
+ operationId: sendEcho
29
+ message:
30
+ $ref: '#/components/messages/echo'
31
+
32
+ components:
33
+ messages:
34
+ echo:
35
+ payload:
36
+ type: string