Skip to content

Commit

Permalink
Migrate fix from v6.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
kalinchernev committed Mar 1, 2021
1 parent 1e5a6a7 commit 5e02ed4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/yaml-anchors-aliases/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = (app) => {
* 200:
* description: OK
* x-amazon-apigateway-integration: *default-integration
* x-second-integration: *second-integration
*/
app.get('/aws', () => {});

Expand Down
9 changes: 9 additions & 0 deletions examples/yaml-anchors-aliases/reference-specification.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
"type": "aws_proxy",
"uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789:function:helloworldlambda/invocations"
}
},
"x-second-integration": {
"type": "object",
"x-amazon-apigateway-integration": {
"httpMethod": "GET",
"passthroughBehavior": "when_no_match",
"type": "aws_proxy",
"uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789:function:helloworldlambda/invocations"
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ x-amazon-apigateway-integrations:
passthroughBehavior: when_no_match
type: aws_proxy
uri: 'arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789:function:helloworldlambda/invocations'
second-integration: &second-integration
type: object
x-amazon-apigateway-integration:
httpMethod: GET
passthroughBehavior: when_no_match
type: aws_proxy
uri: 'arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789:function:helloworldlambda/invocations'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swagger-jsdoc",
"description": "Generates swagger doc based on JSDoc",
"version": "7.0.0-rc.3",
"version": "7.0.0-rc.4",
"engines": {
"node": ">=12.0.0"
},
Expand Down
13 changes: 8 additions & 5 deletions src/specification.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export async function extract(options) {
if (yamlDocsErrors.length) {
for (const docWithErr of yamlDocsErrors) {
const errsToDelete = [];

docWithErr.errors.forEach((error, index) => {
if (error.name === 'YAMLReferenceError') {
// This should either be a smart regex or ideally a YAML library method using the error.range.
Expand All @@ -268,12 +269,14 @@ export async function extract(options) {
yamlDocsReady.push(readyDocument);
errsToDelete.push(index);
}

// Cleanup solved errors in order to allow for parser to pass through.
for (const errIndex of errsToDelete) {
docWithErr.errors.splice(errIndex, 1);
}
});
// reverse sort the deletion array so we always delete from the end
errsToDelete.sort((a, b) => b - a);

// Cleanup solved errors in order to allow for parser to pass through.
for (const errIndex of errsToDelete) {
docWithErr.errors.splice(errIndex, 1);
}
}

const errReport = yamlDocsErrors
Expand Down

0 comments on commit 5e02ed4

Please sign in to comment.