serverless-openapi-documenter 0.0.33 → 0.0.40

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
@@ -52,6 +52,16 @@ Options:
52
52
  --postmanCollection -p Will generate a postman collection (from the generated openAPI documentation), in json only, if passed in. Default postman.json
53
53
  ```
54
54
 
55
+ ### README Highlighted Reading
56
+
57
+ #### Security Details
58
+ * [Security](#securityschemes)
59
+ * [Security on All Operations](#security-on-each-operation)
60
+ * [Security Per Operation](#security)
61
+ #### Model Details
62
+ * [Models](#models)
63
+ * [Notes on Schemas](#notes-on-schemas)
64
+
55
65
  ### OpenAPI Mapping
56
66
 
57
67
  | OpenAPI field | Serverless field |
@@ -184,6 +194,7 @@ custom:
184
194
  ```
185
195
 
186
196
  Name is required but `url` is optional and must be in the format of a url.
197
+
187
198
  #### Extended Fields
188
199
 
189
200
  You can also add extended fields to the documentation object:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serverless-openapi-documenter",
3
- "version": "0.0.33",
3
+ "version": "0.0.40",
4
4
  "description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -32,6 +32,7 @@
32
32
  "chalk": "^4.1.2",
33
33
  "js-yaml": "^4.1.0",
34
34
  "json-schema-for-openapi": "^0.3.1",
35
+ "lodash.isequal": "^4.5.0",
35
36
  "oas-validator": "^5.0.8",
36
37
  "openapi-to-postmanv2": "^4.4.1",
37
38
  "swagger2openapi": "^7.0.8",
@@ -5,7 +5,8 @@ const path = require('path')
5
5
  const { v4: uuid } = require('uuid')
6
6
  const validator = require('oas-validator');
7
7
  const SchemaConvertor = require('json-schema-for-openapi')
8
- const $RefParser = require("@apidevtools/json-schema-ref-parser");
8
+ const $RefParser = require("@apidevtools/json-schema-ref-parser")
9
+ const isEqual = require('lodash.isequal')
9
10
 
10
11
  class DefinitionGenerator {
11
12
  constructor(serverless, options = {}) {
@@ -29,6 +30,11 @@ class DefinitionGenerator {
29
30
  this.operationIds = []
30
31
  this.schemaIDs = []
31
32
 
33
+ this.componentTypes = {
34
+ schemas: 'schemas',
35
+ securitySchemes: 'securitySchemes'
36
+ }
37
+
32
38
  try {
33
39
  this.refParserOptions = require(path.resolve('options', 'ref-parser.js'))
34
40
  } catch (err) {
@@ -455,42 +461,13 @@ class DefinitionGenerator {
455
461
  }
456
462
 
457
463
  async dereferenceSchema(schema) {
458
- return await $RefParser.dereference(schema, this.refParserOptions)
464
+ let deReferencedSchema = await $RefParser.dereference(schema, this.refParserOptions)
459
465
  .catch(err => {
460
466
  console.error(err)
461
467
  throw err
462
468
  })
463
- }
464
-
465
- async schemaCreator(schema, name) {
466
- const addToComponents = (schema, name) => {
467
- const schemaObj = {
468
- [name]: schema
469
- }
470
-
471
- if (this.openAPI?.components) {
472
- if (this.openAPI.components?.schemas) {
473
- Object.assign(this.openAPI.components.schemas, schemaObj)
474
- } else {
475
- Object.assign(this.openAPI.components, {schemas: schemaObj})
476
- }
477
- } else {
478
- const components = {
479
- components: {
480
- schemas: schemaObj
481
- }
482
- }
483
-
484
- Object.assign(this.openAPI, components)
485
- }
486
- }
487
-
488
- let deReferencedSchema = await this.dereferenceSchema(schema)
489
- .catch((err) => {
490
- throw err
491
- })
492
469
 
493
- // deal with schemas that have been de-referenced poorly
470
+ // deal with schemas that have been de-referenced poorly: naive
494
471
  if (deReferencedSchema.$ref === '#') {
495
472
  const oldRef = schema.$ref
496
473
  const path = oldRef.split('/')
@@ -505,35 +482,44 @@ class DefinitionGenerator {
505
482
  })
506
483
  }
507
484
 
508
- const convertedSchema = SchemaConvertor.convert(deReferencedSchema, name)
509
- let schemaName = name
510
- if (this.schemaIDs.includes(schemaName))
511
- schemaName = `${name}-${uuid()}`
512
-
513
- this.schemaIDs.push(schemaName)
485
+ return deReferencedSchema
486
+ }
514
487
 
515
- for (const key of Object.keys(convertedSchema.schemas)) {
516
- if (key === name || key.split('-')[0] === name) {
517
- let ref = `#/components/schemas/`
488
+ async schemaCreator(schema, name) {
489
+ let schemaName = name
490
+ let finalName = schemaName
491
+ const dereferencedSchema = await this.dereferenceSchema(schema)
492
+ .catch(err => {
493
+ console.error(err)
494
+ throw err
495
+ })
518
496
 
519
- if (this.openAPI?.components?.schemas?.[name]) {
520
- if (JSON.stringify(convertedSchema.schemas[key]) === JSON.stringify(this.openAPI.components.schemas[name])) {
521
- return `${ref}${name}`
522
- }
497
+ const convertedSchemas = SchemaConvertor.convert(dereferencedSchema, schemaName)
498
+
499
+ for (const convertedSchemaName of Object.keys(convertedSchemas.schemas)) {
500
+ const convertedSchema = convertedSchemas.schemas[convertedSchemaName]
501
+ if (this.existsInComponents(convertedSchemaName)) {
502
+ if (this.isTheSameSchema(convertedSchema, convertedSchemaName) === false) {
503
+ if (convertedSchemaName === schemaName) {
504
+ finalName = `${schemaName}-${uuid()}`
505
+ this.addToComponents(this.componentTypes.schemas, convertedSchema, finalName)
506
+ } else
507
+ this.addToComponents(this.componentTypes.schemas, convertedSchema, convertedSchemaName)
523
508
  }
524
-
525
- addToComponents(convertedSchema.schemas[key], schemaName)
526
- return `${ref}${schemaName}`
527
509
  } else {
528
- if (this.openAPI?.components?.schemas?.[key]) {
529
- if (JSON.stringify(convertedSchema.schemas[key]) !== JSON.stringify(this.openAPI.components.schemas[key])) {
530
- addToComponents(convertedSchema.schemas[key], key)
531
- }
532
- } else {
533
- addToComponents(convertedSchema.schemas[key], key)
534
- }
510
+ this.addToComponents(this.componentTypes.schemas, convertedSchema, convertedSchemaName)
535
511
  }
536
512
  }
513
+
514
+ return `#/components/schemas/${finalName}`
515
+ }
516
+
517
+ existsInComponents(name) {
518
+ return Boolean(this.openAPI?.components?.schemas?.[name])
519
+ }
520
+
521
+ isTheSameSchema(schema, otherSchemaName) {
522
+ return isEqual(schema, this.openAPI.components.schemas[otherSchemaName])
537
523
  }
538
524
 
539
525
  addToComponents(type, schema, name) {
@@ -592,7 +578,7 @@ class DefinitionGenerator {
592
578
  break;
593
579
  }
594
580
 
595
- this.addToComponents('securitySchemes', schema, scheme)
581
+ this.addToComponents(this.componentTypes.securitySchemes, schema, scheme)
596
582
  }
597
583
  }
598
584
 
@@ -709,234 +709,165 @@ describe('DefinitionGenerator', () => {
709
709
  expect(expected).to.equal('#/components/schemas/main')
710
710
  });
711
711
 
712
- it('should add each definition of a complex schema to the components object', async function() {
713
- const complexSchema = {
714
- "$schema": "http://json-schema.org/draft-04/schema#",
715
- "title": "JSON API Schema",
716
- "description": "This is a blah blah for responses in the JSON API format. For more, see http://jsonapi.org",
717
- "type": "object",
718
- "required": [
719
- "errors"
720
- ],
721
- "properties": {
722
- "errors": {
723
- "type": "array",
724
- "items": {
725
- "$ref": "#/definitions/error"
726
- },
727
- "uniqueItems": true
728
- }
729
- },
730
- "definitions": {
731
- "error": {
732
- "type": "object",
733
- "properties": {
734
- "id": {
735
- "description": "A unique identifier for this particular occurrence of the problem.",
736
- "type": "string"
737
- }
738
- }
739
- }
740
- }
741
- }
712
+ it('should not overwrite a schema that has the same name and same schema as a pre-existing schema', async function() {
742
713
  const definitionGenerator = new DefinitionGenerator(mockServerless)
743
- const expected = await definitionGenerator.schemaCreator(complexSchema, 'PutRequest')
744
- .catch((err) => {
745
- console.error(err)
746
- })
747
714
 
748
- expect(definitionGenerator.openAPI.components.schemas).to.have.property('PutRequest')
749
- expect(definitionGenerator.openAPI.components.schemas).to.not.have.property('error')
750
- expect(expected).to.equal('#/components/schemas/PutRequest')
751
- });
715
+ const spy = sinon.spy(definitionGenerator, 'addToComponents')
752
716
 
753
- it(`should not overwrite an object that already exists in the components if they're the same`, async function() {
754
717
  const complexSchema = {
755
- "$schema": "http://json-schema.org/draft-04/schema#",
756
- "title": "JSON API Schema",
757
- "description": "This is a blah blah for responses in the JSON API format. For more, see http://jsonapi.org",
758
- "type": "object",
759
- "required": [
760
- "errors"
761
- ],
762
- "properties": {
763
- "errors": {
764
- "type": "array",
765
- "items": {
766
- "$ref": "#/definitions/error"
767
- },
768
- "uniqueItems": true
769
- }
770
- },
771
- "definitions": {
772
- "error": {
773
- "type": "object",
774
- "properties": {
775
- "id": {
776
- "description": "A unique identifier for this particular occurrence of the problem.",
777
- "type": "string"
778
- }
779
- }
718
+ type: 'object',
719
+ properties: {
720
+ error: {
721
+ type: 'string'
780
722
  }
781
723
  }
782
724
  }
783
- const definitionGenerator = new DefinitionGenerator(mockServerless)
784
- let expected = await definitionGenerator.schemaCreator(complexSchema, 'PutRequest')
725
+
726
+ let expected = await definitionGenerator.schemaCreator(complexSchema, 'main')
785
727
  .catch((err) => {
786
728
  console.error(err)
787
729
  })
788
730
 
789
- expect(definitionGenerator.openAPI.components.schemas).to.have.property('PutRequest')
790
- expect(definitionGenerator.openAPI.components.schemas).to.not.have.property('error')
791
- expect(expected).to.equal('#/components/schemas/PutRequest')
731
+ expect(definitionGenerator.openAPI.components.schemas).to.have.property('main')
732
+ expect(JSON.stringify(definitionGenerator.openAPI.components.schemas.main)).to.equal(JSON.stringify(complexSchema))
733
+ expect(expected).to.equal('#/components/schemas/main')
792
734
 
793
- expected = await definitionGenerator.schemaCreator(complexSchema, 'PutRequest')
794
- .catch((err) => {
735
+ expected = await definitionGenerator.schemaCreator(complexSchema, 'main')
736
+ .catch((err) => {
795
737
  console.error(err)
796
738
  })
797
739
 
798
- expect(definitionGenerator.openAPI.components.schemas).to.have.property('PutRequest')
799
- expect(definitionGenerator.openAPI.components.schemas).to.not.have.property('error')
800
- expect(expected).to.equal('#/components/schemas/PutRequest')
740
+ expect(expected).to.equal('#/components/schemas/main')
741
+ expect(spy.callCount).to.be.equal(1)
742
+
743
+ spy.resetHistory()
801
744
  });
802
745
 
803
- it(`should create a new object for a similarly named object but with different properties`, async function() {
746
+ it('should not overwrite a schema that has the same name and same schema as a pre-existing schema but in a slightly different order', async function() {
747
+ const definitionGenerator = new DefinitionGenerator(mockServerless)
748
+
749
+ const spy = sinon.spy(definitionGenerator, 'addToComponents')
750
+
804
751
  const complexSchema = {
805
- "$schema": "http://json-schema.org/draft-04/schema#",
806
- "title": "JSON API Schema",
807
- "description": "This is a blah blah for responses in the JSON API format. For more, see http://jsonapi.org",
808
- "type": "object",
809
- "required": [
810
- "errors"
811
- ],
812
- "properties": {
813
- "errors": {
814
- "type": "array",
815
- "items": {
816
- "$ref": "#/definitions/error"
817
- },
818
- "uniqueItems": true
819
- }
820
- },
821
- "definitions": {
822
- "error": {
823
- "type": "object",
824
- "properties": {
825
- "id": {
826
- "description": "A unique identifier for this particular occurrence of the problem.",
827
- "type": "string"
828
- }
829
- }
752
+ type: 'object',
753
+ properties: {
754
+ error: {
755
+ type: 'string',
756
+ format: 'uuid'
830
757
  }
831
758
  }
832
759
  }
833
- const definitionGenerator = new DefinitionGenerator(mockServerless)
834
- let expected = await definitionGenerator.schemaCreator(complexSchema, 'PutRequest')
760
+
761
+ let expected = await definitionGenerator.schemaCreator(complexSchema, 'main')
835
762
  .catch((err) => {
836
763
  console.error(err)
837
764
  })
838
765
 
839
- expect(definitionGenerator.openAPI.components.schemas).to.have.property('PutRequest')
840
- expect(definitionGenerator.openAPI.components.schemas).to.not.have.property('error')
841
- expect(expected).to.equal('#/components/schemas/PutRequest')
766
+ expect(definitionGenerator.openAPI.components.schemas).to.have.property('main')
767
+ expect(JSON.stringify(definitionGenerator.openAPI.components.schemas.main)).to.equal(JSON.stringify(complexSchema))
768
+ expect(expected).to.equal('#/components/schemas/main')
842
769
 
843
- complexSchema.properties.cheese = {
844
- type: 'string'
770
+ const complexSchema2 = {
771
+ type: 'object',
772
+ properties: {
773
+ error: {
774
+ format: 'uuid',
775
+ type: 'string'
776
+ }
777
+ }
845
778
  }
846
779
 
847
- expected = await definitionGenerator.schemaCreator(complexSchema, 'PutRequest')
848
- .catch((err) => {
780
+ expected = await definitionGenerator.schemaCreator(complexSchema2, 'main')
781
+ .catch((err) => {
849
782
  console.error(err)
850
783
  })
851
784
 
852
- expect(definitionGenerator.openAPI.components.schemas).to.have.property('PutRequest')
853
- expect(definitionGenerator.openAPI.components.schemas).to.not.have.property('error')
785
+ expect(expected).to.equal('#/components/schemas/main')
786
+ expect(spy.callCount).to.be.equal(1)
854
787
 
855
- let newSchemaStr = expected.split('/')
856
- expect(v4.test(newSchemaStr[newSchemaStr.length-1].split('PutRequest-')[1])).to.be.true
857
- expect(definitionGenerator.openAPI.components.schemas).to.have.property(newSchemaStr[newSchemaStr.length-1])
788
+ spy.resetHistory()
789
+ });
858
790
 
859
- // expected = await definitionGenerator.schemaCreator(complexSchema, 'PutRequest')
860
- // .catch((err) => {
861
- // console.error(err)
862
- // })
791
+ it('should add a schema to components when a name already exists but the schema is different', async function() {
792
+ const definitionGenerator = new DefinitionGenerator(mockServerless)
863
793
 
864
- // expect(definitionGenerator.openAPI.components.schemas).to.have.property('PutRequest')
865
- // expect(definitionGenerator.openAPI.components.schemas).to.have.property('error')
866
- // console.log(expected)
867
- // expect(expected)
868
- // expect(expected).to.equal('#/components/schemas/PutRequest1')
794
+ const spy = sinon.spy(definitionGenerator, 'addToComponents')
869
795
 
870
- complexSchema.properties.wine = {
871
- type: 'string'
796
+ const complexSchema = {
797
+ type: 'object',
798
+ properties: {
799
+ error: {
800
+ type: 'string'
801
+ }
802
+ }
872
803
  }
873
804
 
874
- expected = await definitionGenerator.schemaCreator(complexSchema, 'PutRequest')
805
+ let expected = await definitionGenerator.schemaCreator(complexSchema, 'main')
875
806
  .catch((err) => {
876
807
  console.error(err)
877
808
  })
878
809
 
879
- expect(definitionGenerator.openAPI.components.schemas).to.have.property('PutRequest')
880
- expect(definitionGenerator.openAPI.components.schemas).to.not.have.property('error')
881
- expect(definitionGenerator.openAPI.components.schemas).to.have.property(newSchemaStr[newSchemaStr.length-1])
882
- newSchemaStr = expected.split('/')
883
- expect(v4.test(newSchemaStr[newSchemaStr.length-1].split('PutRequest-')[1])).to.be.true
884
- expect(definitionGenerator.openAPI.components.schemas).to.have.property(newSchemaStr[newSchemaStr.length-1])
810
+ expect(definitionGenerator.openAPI.components.schemas).to.have.property('main')
811
+ expect(JSON.stringify(definitionGenerator.openAPI.components.schemas.main)).to.equal(JSON.stringify(complexSchema))
812
+ expect(expected).to.equal('#/components/schemas/main')
813
+
814
+ const complexSchema2 = JSON.parse(JSON.stringify(complexSchema))
815
+ complexSchema2.properties.error.format = 'uuid'
816
+
817
+ expected = await definitionGenerator.schemaCreator(complexSchema2, 'main')
818
+ .catch((err) => {
819
+ console.error(err)
820
+ })
821
+
822
+ const splitPath = expected.split('/')
823
+ expect(v4.test(splitPath[3].split('main-')[1])).to.be.true
824
+ expect(definitionGenerator.openAPI.components.schemas[splitPath[3]]).to.be.an('object')
825
+ expect(definitionGenerator.openAPI.components.schemas[splitPath[3]].properties.error).to.have.property('format')
826
+ expect(spy.callCount).to.be.equal(2)
827
+
828
+ spy.resetHistory()
885
829
  });
886
830
 
887
- it(`should create a new object for a differently named object but with same properties`, async function() {
831
+ it('should correctly dereference a schema with definitions and add to the components', async function() {
832
+ const definitionGenerator = new DefinitionGenerator(mockServerless)
833
+
888
834
  const complexSchema = {
889
- "$schema": "http://json-schema.org/draft-04/schema#",
890
- "title": "JSON API Schema",
891
- "description": "This is a blah blah for responses in the JSON API format. For more, see http://jsonapi.org",
892
- "type": "object",
893
- "required": [
894
- "errors"
895
- ],
896
- "properties": {
897
- "errors": {
898
- "type": "array",
899
- "items": {
900
- "$ref": "#/definitions/error"
901
- },
902
- "uniqueItems": true
835
+ type: 'object',
836
+ properties: {
837
+ error: {
838
+ '$ref': '#/definitions/error'
903
839
  }
904
840
  },
905
- "definitions": {
906
- "error": {
907
- "type": "object",
908
- "properties": {
909
- "id": {
910
- "description": "A unique identifier for this particular occurrence of the problem.",
911
- "type": "string"
912
- }
913
- }
841
+ definitions: {
842
+ error: {
843
+ type: "string"
914
844
  }
915
845
  }
916
846
  }
917
- const definitionGenerator = new DefinitionGenerator(mockServerless)
918
- let expected = await definitionGenerator.schemaCreator(complexSchema, 'PutRequest')
919
- .catch((err) => {
920
- console.error(err)
921
- })
922
847
 
923
- expect(definitionGenerator.openAPI.components.schemas).to.have.property('PutRequest')
924
- expect(definitionGenerator.openAPI.components.schemas).to.not.have.property('error')
925
- expect(expected).to.equal('#/components/schemas/PutRequest')
848
+ const spy = sinon.spy(definitionGenerator, 'dereferenceSchema')
926
849
 
927
- expected = await definitionGenerator.schemaCreator(complexSchema, 'ContactPutRequest')
850
+ const expected = await definitionGenerator.schemaCreator(complexSchema, 'main')
928
851
  .catch((err) => {
929
852
  console.error(err)
930
853
  })
931
854
 
932
- expect(definitionGenerator.openAPI.components.schemas).to.have.property('PutRequest')
933
- expect(definitionGenerator.openAPI.components.schemas).to.not.have.property('error')
934
- expect(definitionGenerator.openAPI.components.schemas).to.have.property('ContactPutRequest')
935
- expect(expected).to.equal('#/components/schemas/ContactPutRequest')
855
+ expect(definitionGenerator.openAPI.components.schemas).to.have.property('main')
856
+ expect(definitionGenerator.openAPI.components.schemas.main.properties).to.have.property('error')
857
+ expect(definitionGenerator.openAPI.components.schemas.main.properties.error).to.have.property('type')
858
+ expect(definitionGenerator.openAPI.components.schemas.main.properties.error.type).to.be.equal('string')
859
+ expect(definitionGenerator.openAPI.components.schemas.main).to.not.have.property('definitions')
860
+ expect(expected).to.equal('#/components/schemas/main')
861
+
862
+ expect(spy.callCount).to.be.equal(1)
863
+
864
+ spy.resetHistory()
936
865
  });
937
866
 
938
- it('should handle a schema that has been improperly dereferenced', async function() {
939
- const simpleSchema = {
867
+ it('should handle a schema that has been incorrectly dereferenced', async function() {
868
+ const definitionGenerator = new DefinitionGenerator(mockServerless)
869
+
870
+ const complexSchema = {
940
871
  $schema: 'http://json-schema.org/draft-04/schema#',
941
872
  title: 'JSON API Schema',
942
873
  $ref: '#/definitions/Error',
@@ -946,22 +877,72 @@ describe('DefinitionGenerator', () => {
946
877
  }
947
878
  }
948
879
  }
949
- const definitionGenerator = new DefinitionGenerator(mockServerless)
950
- const expected = await definitionGenerator.schemaCreator(simpleSchema, 'simpleSchema')
880
+
881
+ const spy = sinon.spy(definitionGenerator, 'dereferenceSchema')
882
+
883
+ const expected = await definitionGenerator.schemaCreator(complexSchema, 'main')
951
884
  .catch((err) => {
952
885
  console.error(err)
953
886
  })
954
887
 
955
- expect(definitionGenerator.openAPI.components.schemas).to.have.property('simpleSchema')
956
- expect(definitionGenerator.openAPI.components.schemas.simpleSchema).to.deep.equal({
957
- title: 'JSON API Schema',
958
- properties: {
959
- Error: {
960
- type: 'string'
888
+ expect(definitionGenerator.openAPI.components.schemas).to.have.property('main')
889
+ expect(definitionGenerator.openAPI.components.schemas.main.properties).to.have.property('Error')
890
+ expect(definitionGenerator.openAPI.components.schemas.main.properties.Error).to.have.property('type')
891
+ expect(definitionGenerator.openAPI.components.schemas.main.properties.Error.type).to.be.equal('string')
892
+ expect(definitionGenerator.openAPI.components.schemas.main).to.not.have.property('$schema')
893
+ expect(definitionGenerator.openAPI.components.schemas.main).to.not.have.property('$definitions')
894
+ expect(expected).to.equal('#/components/schemas/main')
895
+
896
+ expect(spy.callCount).to.be.equal(2)
897
+
898
+ spy.resetHistory()
899
+ });
900
+
901
+ it('should add all schemas from a conversion to the components', async function() {
902
+ const complexSchema = {
903
+ "$schema": "http://json-schema.org/draft-04/schema#",
904
+ "title": "JSON API Schema",
905
+ "description": "This is a blah blah for responses in the JSON API format. For more, see http://jsonapi.org",
906
+ "type": "object",
907
+ "properties": {
908
+ "street_address": {
909
+ "type": "string"
910
+ },
911
+ "country": {
912
+ "type": "string",
913
+ "default": "United States of America",
914
+ "enum": [
915
+ "United States of America",
916
+ "Canada"
917
+ ]
918
+ }
919
+ },
920
+ "if": {
921
+ "properties": {
922
+ "country": {
923
+ "const": "United States of America"
924
+ }
925
+ }
926
+ },
927
+ "then": {
928
+ "properties": {
929
+ "postal_code": {
930
+ "pattern": "[0-9]{5}(-[0-9]{4})?"
931
+ }
961
932
  }
962
933
  }
963
- })
964
- expect(expected).to.equal('#/components/schemas/simpleSchema')
934
+ }
935
+
936
+ const definitionGenerator = new DefinitionGenerator(mockServerless)
937
+ let expected = await definitionGenerator.schemaCreator(complexSchema, 'main')
938
+ .catch((err) => {
939
+ console.error(err)
940
+ })
941
+
942
+ expect(expected).to.equal('#/components/schemas/main')
943
+ expect(definitionGenerator.openAPI.components.schemas).to.have.property('main')
944
+ expect(Object.keys(definitionGenerator.openAPI.components.schemas).length).to.be.equal(2)
945
+
965
946
  });
966
947
  });
967
948