Skip to content

Commit

Permalink
Keep x-args in securitySchema flow when converting OA3 to SW2
Browse files Browse the repository at this point in the history
  • Loading branch information
koubas committed Jul 20, 2022
1 parent f51ac36 commit 419a0f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/converters/openapi3_to_swagger2.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,12 @@ Converter.prototype.convertSecurityDefinitions = function() {
security.tokenUrl = flow.tokenUrl;
security.scopes = flow.scopes;
delete security.flows;
// copy x- args from the flow as they are
Object.keys(flow).forEach(function (k) {
if (/^x-/i.test(k)) {
security[k] = flow[k]
}
})
}
}
delete this.spec.components.securitySchemes;
Expand Down
3 changes: 2 additions & 1 deletion test/input/openapi_3/petstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@
"read:pets": "Read your pets",
"write:pets": "Modify pets in your account"
},
"tokenUrl": "http://petstore.swagger.wordnik.com/api/oauth/token"
"tokenUrl": "http://petstore.swagger.wordnik.com/api/oauth/token",
"x-pet-lover-validator": "On"
}
},
"type": "oauth2"
Expand Down
3 changes: 2 additions & 1 deletion test/output/swagger_2/petstore_from_oas3.json
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,8 @@
"write:pets": "Modify pets in your account"
},
"tokenUrl": "http://petstore.swagger.wordnik.com/api/oauth/token",
"type": "oauth2"
"type": "oauth2",
"x-pet-lover-validator": "On"
},
"oauth2_implicit": {
"authorizationUrl": "http://petstore.swagger.wordnik.com/api/oauth/dialog",
Expand Down

0 comments on commit 419a0f6

Please sign in to comment.