openapi-to-postman
openapi-to-postman copied to clipboard
Import OAuth2 flow settings from OpenApi spec
Currently an OAuth2 Security Scheme in OpenAPI
"securitySchemes": {
"OAuth2": {
"type": "oauth2",
"description": "Lorem Ipsum",
"in": "header",
"scheme": "https",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://acme.com/oauth/authorize",
"tokenUrl": "https://acme.com/oauth/token",
"scopes": {
"read_stuff": "Grant read access to stuff"
}
}
}
}
}
will be converted to
"auth": {
"type": "oauth2"
}
It would be nice if the settings from the OAuth2 flow would be included:
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "grant_type",
"value": "authorization_code",
"type": "string"
},
{
"key": "authUrl",
"value": "https://acme.com/oauth/authorize",
"type": "string"
}
{
"key": "accessTokenUrl",
"value": "https://acme.com/oauth/token",
"type": "string"
},
{
"key": "scope",
"value": "read_stuff",
"type": "string"
},
]
},
Beware that there may be multiple OAuth2 flows specified in OpenAPI. Therefore either only import first flow or add selection of flow via configuration option or similar.
+1 to this request
+1 to this request
Would be very nice to have, otherwise we need to add some post-processor of the generated collection to include this information.
@SahilChoudhary22 Can we look into this please^
@gn-stuckenberg Hi, this feature was added and released with openapi-to-postman v4.2.0.
PR - https://github.com/postmanlabs/openapi-to-postman/pull/614
Now if we take this Input as an example -
{
"components": {
"responses": {},
"schemas": {},
"securitySchemes": {
"OAuth2": {
"type": "oauth2",
"description": "Lorem Ipsum",
"in": "header",
"scheme": "https",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://acme.com/oauth/authorize",
"tokenUrl": "https://acme.com/oauth/token",
"scopes": {
"read_stuff": "Grant read access to stuff"
}
}
}
}
}
},
"info": {
"title": "API",
"version": "0.2"
},
"openapi": "3.0.0",
"paths": {},
"security": [
{
"OAuth2": [
"read:stuff"
]
}
],
"servers": [
{
"url": "https://foobar.com",
"variables": {}
}
],
"tags": []
}
the following will be the output (auth section)
...
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "scope",
"value": "read_stuff"
},
{
"key": "accessTokenUrl",
"value": "https://acme.com/oauth/token"
},
{
"key": "authUrl",
"value": "https://acme.com/oauth/authorize"
},
{
"key": "grant_type",
"value": "authorization_code"
}
]
},
...
This should've solved this issue. if it did not, do let me know and I'll be happy to help. 👍
PS: You can observe the same behaviour in the postman app from v9.30.0-220817 and higher.
CC: @suyashjoshi @anikitin @SaloniV3011