diff --git a/packages/spec-parser/src/constants.ts b/packages/spec-parser/src/constants.ts index 41aab1f939..9a5dd5d776 100644 --- a/packages/spec-parser/src/constants.ts +++ b/packages/spec-parser/src/constants.ts @@ -52,7 +52,12 @@ export class ConstantString { static readonly TextBlockType = "TextBlock"; static readonly ImageType = "Image"; static readonly ContainerType = "Container"; - static readonly RegistrationIdPostfix = "REGISTRATION_ID"; + static readonly RegistrationIdPostfix: { [key: string]: string } = { + apiKey: "REGISTRATION_ID", + oauth2: "CONFIGURATION_ID", + http: "REGISTRATION_ID", + openIdConnect: "REGISTRATION_ID", + }; static readonly ResponseCodeFor20X = [ "200", "201", diff --git a/packages/spec-parser/src/manifestUpdater.ts b/packages/spec-parser/src/manifestUpdater.ts index a8ef472458..827377b7c5 100644 --- a/packages/spec-parser/src/manifestUpdater.ts +++ b/packages/spec-parser/src/manifestUpdater.ts @@ -147,7 +147,7 @@ export class ManifestUpdater { if (pluginAuthObj.type !== "None") { const safeRegistrationIdName = Utils.getSafeRegistrationIdEnvName( - `${authInfo.name}_${ConstantString.RegistrationIdPostfix}` + `${authInfo.name}_${ConstantString.RegistrationIdPostfix[authInfo.authScheme.type]}` ); pluginAuthObj.reference_id = `\${{${safeRegistrationIdName}}}`; @@ -384,11 +384,11 @@ export class ManifestUpdater { if (authInfo) { const auth = authInfo.authScheme; const safeRegistrationIdName = Utils.getSafeRegistrationIdEnvName( - `${authInfo.name}_${ConstantString.RegistrationIdPostfix}` + `${authInfo.name}_${ConstantString.RegistrationIdPostfix[authInfo.authScheme.type]}` ); if (Utils.isAPIKeyAuth(auth) || Utils.isBearerTokenAuth(auth)) { const safeApiSecretRegistrationId = Utils.getSafeRegistrationIdEnvName( - `${authInfo.name}_${ConstantString.RegistrationIdPostfix}` + `${authInfo.name}_${ConstantString.RegistrationIdPostfix[authInfo.authScheme.type]}` ); (composeExtension as any).authorization = { authType: "apiSecretServiceAuth", diff --git a/packages/spec-parser/test/manifestUpdater.test.ts b/packages/spec-parser/test/manifestUpdater.test.ts index 96e3c6d727..4a7dbd0433 100644 --- a/packages/spec-parser/test/manifestUpdater.test.ts +++ b/packages/spec-parser/test/manifestUpdater.test.ts @@ -413,7 +413,7 @@ describe("updateManifestWithAiPlugin", () => { type: "OpenApi", auth: { type: "OAuthPluginVault", - reference_id: "${{OAUTH_REGISTRATION_ID}}", + reference_id: "${{OAUTH_CONFIGURATION_ID}}", }, spec: { url: "spec/outputSpec.yaml", @@ -3685,7 +3685,7 @@ describe("manifestUpdater", () => { authorization: { authType: "oAuth2.0", oAuthConfiguration: { - oauthConfigurationId: "${{OAUTH_AUTH_REGISTRATION_ID}}", + oauthConfigurationId: "${{OAUTH_AUTH_CONFIGURATION_ID}}", }, }, commands: [