@@ -14,6 +14,7 @@ import {
1414 pluginMetaSchema ,
1515 pluginRequestPayloadSchema ,
1616} from '@lobehub/chat-plugin-sdk' ;
17+ import { OPENAPI_REQUEST_BODY_KEY } from '@lobehub/chat-plugin-sdk/openapi' ;
1718// @ts -ignore
1819import SwaggerClient from 'swagger-client' ;
1920
@@ -181,7 +182,7 @@ export class Gateway {
181182 message : '[plugin] plugin manifest is invalid' ,
182183 } ) ;
183184
184- console . log ( `[${ identifier } ] plugin manifest:` , manifest ) ;
185+ // console.log(`[${identifier}] plugin manifest:`, manifest);
185186
186187 // ========== 6. 校验是否按照 manifest 包含了 settings 配置 ========== //
187188
@@ -281,7 +282,7 @@ export class Gateway {
281282 } ;
282283
283284 // 根据 settings 中的每个属性来构建 authorizations 对象
284- for ( const [ key , value ] of Object . entries ( settings ) ) {
285+ for ( const [ key , value ] of Object . entries ( settings || { } ) ) {
285286 // 处理 API Key 和 Bearer Token
286287 authorizations [ key ] = value as string ;
287288
@@ -316,10 +317,11 @@ export class Gateway {
316317 } ) ;
317318 }
318319
319- const parameters = JSON . parse ( args || '{}' ) ;
320+ const requestParams = JSON . parse ( args || '{}' ) ;
321+ const { [ OPENAPI_REQUEST_BODY_KEY ] : requestBody , ...parameters } = requestParams ;
320322
321323 try {
322- const res = await client . execute ( { operationId : apiName , parameters } ) ;
324+ const res = await client . execute ( { operationId : apiName , parameters, requestBody } ) ;
323325
324326 return this . createSuccessResponse ( res . text ) ;
325327 } catch ( error ) {
@@ -335,6 +337,7 @@ export class Gateway {
335337 '[plugin] there are problem with sending openapi request, please contact with LobeHub Team' ,
336338 openapi : manifest . openapi ,
337339 parameters,
340+ requestBody,
338341 } ) ;
339342 }
340343
0 commit comments