-
-
Notifications
You must be signed in to change notification settings - Fork 246
Description
Description
I received this error:
❗️ SDK warning: unsupported security scheme. Please open an issue if you'd like it added https://github.com/hey-api/openapi-ts/issues
{
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "/login",
"tokenUrl": "/oauth/token",
"scopes": {}
}
}
}
I can see that only password
is supported presently:
openapi-ts/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts
Lines 130 to 140 in 7eebbef
if (securitySchemeObject.type === 'oauth2') { | |
// TODO: parser - handle more/multiple oauth2 flows | |
if (securitySchemeObject.flows.password) { | |
return { | |
scheme: 'bearer', | |
type: 'http', | |
}; | |
} | |
return; | |
} |
This remains true even in the new feat/security-basic
branch:
openapi-ts/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts
Lines 190 to 197 in 646064d
if (securitySchemeObject.type === 'oauth2') { | |
if (securitySchemeObject.flows.password) { | |
security.push({ | |
fn: 'accessToken', | |
in: 'header', | |
name: 'Authorization', | |
}); | |
} |
From docs OAuth 2.0 | Swagger Docs the following are valid:
- authorizationCode – Authorization Code flow (previously called accessCode in OpenAPI 2.0)
- implicit – Implicit flow
- password – Resource Owner Password flow
- clientCredentials – Client Credentials flow (previously called application in OpenAPI 2.0)
Generally, these all use a bearer token for making requests so the implementation (new and old) would apply for each of these. For me, my current workaround is simply to using the password
flow when generating.
Can we update (both) branches to accept all of theses flows?
Of note, the main
branch includes support for the bearer
scheme but this appears to have been remove from the new feat/security-basic
branch. It should probably be supported in the same manner as OAuth2?
openapi-ts/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts
Lines 162 to 174 in 7eebbef
if (securitySchemeObject.type === 'http') { | |
if ( | |
securitySchemeObject.scheme === 'bearer' || | |
securitySchemeObject.scheme === 'basic' | |
) { | |
return { | |
scheme: securitySchemeObject.scheme, | |
type: 'http', | |
}; | |
} | |
return; | |
} |