serverless-openapi-documenter 0.0.51 → 0.0.52

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 CHANGED
@@ -295,12 +295,22 @@ custom:
295
295
  contentType: "application/json"
296
296
  schema:
297
297
  $schema: "http://json-schema.org/draft-04/schema#"
298
+ type: object
298
299
  properties:
299
300
  SomeObject:
300
301
  type: "object"
301
302
  properties:
302
303
  SomeAttribute:
303
304
  type: "string"
305
+ examples:
306
+ - name: someObjectInlineExample
307
+ summary: an example of a request
308
+ description: a longer string than the summary
309
+ value: {SomeObject: {SomeAttribute: 'attribute'}}
310
+ - name: someObjectExternalExample
311
+ summary: an example of a request external
312
+ description: a longer string than the summary
313
+ externalValue: https://example.com/external.json
304
314
  ```
305
315
 
306
316
  The Second way of writing the models:
@@ -329,12 +339,22 @@ custom:
329
339
  application/json:
330
340
  schema:
331
341
  $schema: "http://json-schema.org/draft-04/schema#"
342
+ type: object
332
343
  properties:
333
344
  SomeObject:
334
345
  type: "object"
335
346
  properties:
336
347
  SomeAttribute:
337
348
  type: "string"
349
+ examples:
350
+ - name: someObjectInlineExample
351
+ summary: an example of a request
352
+ description: a longer string than the summary
353
+ value: {SomeObject: {SomeAttribute: 'attribute'}}
354
+ - name: someObjectExternalExample
355
+ summary: an example of a request external
356
+ description: a longer string than the summary
357
+ externalValue: https://example.com/external.json
338
358
  ```
339
359
 
340
360
  ##### Model re-use
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serverless-openapi-documenter",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -458,16 +458,22 @@ class DefinitionGenerator {
458
458
  }
459
459
  const obj = {}
460
460
 
461
- if (mediaTypeDocumentation.example)
462
- obj.example = mediaTypeDocumentation.example
463
-
464
- if (mediaTypeDocumentation.examples)
465
- obj.examples = this.createExamples(mediaTypeDocumentation.examples)
466
-
467
461
  let schema
468
462
  if (mediaTypeDocumentation?.content) {
463
+ if (mediaTypeDocumentation.content[contentKey]?.example)
464
+ obj.example = mediaTypeDocumentation.content[contentKey].example
465
+
466
+ if (mediaTypeDocumentation.content[contentKey]?.examples)
467
+ obj.examples = this.createExamples(mediaTypeDocumentation.content[contentKey].examples)
468
+
469
469
  schema = mediaTypeDocumentation.content[contentKey].schema
470
470
  } else if (mediaTypeDocumentation?.contentType && mediaTypeDocumentation.schema) {
471
+ if (mediaTypeDocumentation?.example)
472
+ obj.example = mediaTypeDocumentation.example
473
+
474
+ if (mediaTypeDocumentation?.examples)
475
+ obj.examples = this.createExamples(mediaTypeDocumentation.examples)
476
+
471
477
  schema = mediaTypeDocumentation.schema
472
478
  }
473
479
 
@@ -748,6 +754,7 @@ class DefinitionGenerator {
748
754
 
749
755
  for(const example of examples) {
750
756
  Object.assign(examplesObj, {[example.name]: example})
757
+ delete examplesObj[example.name].name
751
758
  }
752
759
 
753
760
  return examplesObj;