Skip to content

Commit a4fd99c

Browse files
authored
Merge pull request #145 from JaredCE/improve-circular-reference-handling
Improve circular reference handling
2 parents 46210a7 + a116271 commit a4fd99c

File tree

3 files changed

+100
-58
lines changed

3 files changed

+100
-58
lines changed

package-lock.json

Lines changed: 73 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-openapi-documenter",
3-
"version": "0.0.80",
3+
"version": "0.0.81",
44
"description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
55
"main": "index.js",
66
"keywords": [
@@ -40,20 +40,20 @@
4040
"@apidevtools/json-schema-ref-parser": "^9.1.0",
4141
"chalk": "^4.1.2",
4242
"js-yaml": "^4.1.0",
43-
"json-schema-for-openapi": "^0.3.2",
43+
"json-schema-for-openapi": "^0.4.1",
4444
"lodash.isequal": "^4.5.0",
4545
"oas-validator": "^5.0.8",
46-
"openapi-to-postmanv2": "^4.16.0",
46+
"openapi-to-postmanv2": "^4.17.0",
4747
"swagger2openapi": "^7.0.8",
4848
"uuid": "^9.0.0"
4949
},
5050
"engines": {
5151
"node": ">=14"
5252
},
5353
"devDependencies": {
54-
"chai": "^4.3.7",
54+
"chai": "^4.3.8",
5555
"mocha": "^10.2.0",
56-
"nock": "^13.3.0",
57-
"sinon": "^15.0.3"
56+
"nock": "^13.3.3",
57+
"sinon": "^16.0.0"
5858
}
5959
}

src/schemaHandler.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,10 @@ class SchemaHandler {
6868
).catch((err) => {
6969
if (err.errors) {
7070
for (const error of err?.errors) {
71-
if (error.message.includes("HTTP ERROR")) {
72-
// throw err;
73-
throw new Error(
74-
`There was an error dereferencing ${
75-
model.name
76-
} schema. \n\n dereferencing message: ${
77-
error.message
78-
} \n\n Model received: ${JSON.stringify(model)}`
79-
);
80-
}
71+
this.__HTTPError(error);
8172
}
73+
} else {
74+
this.__HTTPError(err);
8275
}
8376
return modelSchema;
8477
});
@@ -108,7 +101,11 @@ class SchemaHandler {
108101
throw new Error(
109102
`There was an error converting the ${
110103
model.name
111-
} schema. Model received looks like: \n\n${JSON.stringify(model)}`
104+
} schema. Model received looks like: \n\n${JSON.stringify(
105+
model
106+
)}. The convereted schema looks like \n\n${JSON.stringify(
107+
convertedSchemas
108+
)}`
112109
);
113110
}
114111
}
@@ -230,6 +227,19 @@ class SchemaHandler {
230227
Object.assign(this.openAPI, components);
231228
}
232229
}
230+
231+
__HTTPError(error) {
232+
if (error.message.includes("HTTP ERROR")) {
233+
// throw err;
234+
throw new Error(
235+
`There was an error dereferencing ${
236+
model.name
237+
} schema. \n\n dereferencing message: ${
238+
error.message
239+
} \n\n Model received: ${JSON.stringify(model)}`
240+
);
241+
}
242+
}
233243
}
234244

235245
module.exports = SchemaHandler;

0 commit comments

Comments
 (0)