serverless-openapi-documenter 0.0.43 → 0.0.45
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-openapi-documenter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.45",
|
|
4
4
|
"description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"json-schema-for-openapi": "^0.3.1",
|
|
39
39
|
"lodash.isequal": "^4.5.0",
|
|
40
40
|
"oas-validator": "^5.0.8",
|
|
41
|
-
"openapi-to-postmanv2": "^4.
|
|
41
|
+
"openapi-to-postmanv2": "^4.9.0",
|
|
42
42
|
"swagger2openapi": "^7.0.8",
|
|
43
43
|
"uuid": "^9.0.0"
|
|
44
44
|
},
|
|
@@ -479,8 +479,10 @@ class DefinitionGenerator {
|
|
|
479
479
|
const path = oldRef.split('/')
|
|
480
480
|
|
|
481
481
|
const pathTitle = path[path.length-1]
|
|
482
|
-
const
|
|
483
|
-
|
|
482
|
+
const referencedProperties = deReferencedSchema.definitions[pathTitle]
|
|
483
|
+
|
|
484
|
+
Object.assign(deReferencedSchema, {...referencedProperties})
|
|
485
|
+
|
|
484
486
|
delete deReferencedSchema.$ref
|
|
485
487
|
deReferencedSchema = await this.dereferenceSchema(deReferencedSchema)
|
|
486
488
|
.catch((err) => {
|
|
@@ -887,9 +887,52 @@ describe('DefinitionGenerator', () => {
|
|
|
887
887
|
})
|
|
888
888
|
|
|
889
889
|
expect(definitionGenerator.openAPI.components.schemas).to.have.property('main')
|
|
890
|
-
expect(definitionGenerator.openAPI.components.schemas.main
|
|
891
|
-
expect(definitionGenerator.openAPI.components.schemas.main.
|
|
892
|
-
expect(definitionGenerator.openAPI.components.schemas.main
|
|
890
|
+
expect(definitionGenerator.openAPI.components.schemas.main).to.have.property('type')
|
|
891
|
+
expect(definitionGenerator.openAPI.components.schemas.main.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 handle a complex schema that has been incorrectly dereferenced', async function() {
|
|
902
|
+
const definitionGenerator = new DefinitionGenerator(mockServerless)
|
|
903
|
+
|
|
904
|
+
const complexSchema = {
|
|
905
|
+
$schema: 'http://json-schema.org/draft-04/schema#',
|
|
906
|
+
title: 'JSON API Schema',
|
|
907
|
+
$ref: '#/definitions/Person',
|
|
908
|
+
definitions: {
|
|
909
|
+
Person: {
|
|
910
|
+
type: 'object',
|
|
911
|
+
properties: {
|
|
912
|
+
name: {
|
|
913
|
+
type: 'string'
|
|
914
|
+
},
|
|
915
|
+
age: {
|
|
916
|
+
type: 'number'
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
const spy = sinon.spy(definitionGenerator, 'dereferenceSchema')
|
|
924
|
+
|
|
925
|
+
const expected = await definitionGenerator.schemaCreator(complexSchema, 'main')
|
|
926
|
+
.catch((err) => {
|
|
927
|
+
console.error(err)
|
|
928
|
+
})
|
|
929
|
+
|
|
930
|
+
expect(definitionGenerator.openAPI.components.schemas).to.have.property('main')
|
|
931
|
+
expect(definitionGenerator.openAPI.components.schemas.main).to.have.property('type')
|
|
932
|
+
expect(definitionGenerator.openAPI.components.schemas.main.type).to.be.equal('object')
|
|
933
|
+
expect(definitionGenerator.openAPI.components.schemas.main).to.have.property('properties')
|
|
934
|
+
expect(definitionGenerator.openAPI.components.schemas.main.properties).to.have.property('name')
|
|
935
|
+
expect(definitionGenerator.openAPI.components.schemas.main.properties).to.have.property('age')
|
|
893
936
|
expect(definitionGenerator.openAPI.components.schemas.main).to.not.have.property('$schema')
|
|
894
937
|
expect(definitionGenerator.openAPI.components.schemas.main).to.not.have.property('$definitions')
|
|
895
938
|
expect(expected).to.equal('#/components/schemas/main')
|
|
@@ -1052,9 +1095,8 @@ describe('DefinitionGenerator', () => {
|
|
|
1052
1095
|
})
|
|
1053
1096
|
|
|
1054
1097
|
expect(definitionGenerator.openAPI.components.schemas).to.have.property('LicensedMember')
|
|
1055
|
-
expect(definitionGenerator.openAPI.components.schemas.LicensedMember
|
|
1056
|
-
expect(definitionGenerator.openAPI.components.schemas.LicensedMember.
|
|
1057
|
-
expect(definitionGenerator.openAPI.components.schemas.LicensedMember.properties.Error.type).to.be.equal('string')
|
|
1098
|
+
expect(definitionGenerator.openAPI.components.schemas.LicensedMember).to.have.property('type')
|
|
1099
|
+
expect(definitionGenerator.openAPI.components.schemas.LicensedMember.type).to.be.equal('string')
|
|
1058
1100
|
expect(definitionGenerator.openAPI.components.schemas.LicensedMember).to.not.have.property('$schema')
|
|
1059
1101
|
expect(definitionGenerator.openAPI.components.schemas.LicensedMember).to.not.have.property('$definitions')
|
|
1060
1102
|
expect(expected).to.equal('#/components/schemas/LicensedMember')
|