Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep x-args in securityScheme flow when converting OA3 to SW2 #346

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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