Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited4f40b

Browse files
committed
Pull definition logic into a new function
1 parentd1e6f92 commited4f40b

File tree

1 file changed

+21
-19
lines changed
  • server/node-service/src/plugins/openApi

1 file changed

+21
-19
lines changed

‎server/node-service/src/plugins/openApi/index.ts‎

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ interface ActionDataType {
5050
[key:string]:any;
5151
}
5252

53-
exportasyncfunctionrunOpenApi(
54-
actionData:ActionDataType,
55-
dataSourceConfig:DataSourceDataType,
53+
asyncfunctiongetDefinitions(
5654
spec:OpenAPI.Document|MultiOpenApiSpecItem[],
57-
defaultHeaders?:Record<string,string>,
5855
openApiSpecDereferenced?:OpenAPI.Document,
59-
){
60-
constspecList=Array.isArray(spec) ?spec :[{ spec,id:""}];
61-
letdefinitions;
62-
63-
if(!openApiSpecDereferenced){
64-
definitions=awaitPromise.all(
56+
):Promise<{def:OpenAPI.Document;id:string}[]>{
57+
if(openApiSpecDereferenced){
58+
return[{
59+
def:openApiSpecDereferenced,
60+
id:"",
61+
}]
62+
}else{
63+
constspecList=Array.isArray(spec) ?spec :[{ spec,id:""}];
64+
returnawaitPromise.all(
6565
specList.map(async({id, spec})=>{
6666
constdeRefedSpec=awaitSwaggerParser.dereference(spec);
6767
return{
@@ -70,20 +70,22 @@ export async function runOpenApi(
7070
};
7171
})
7272
);
73-
}else{
74-
definitions=[{
75-
def:openApiSpecDereferenced,
76-
id:"",
77-
}]
7873
}
74+
}
75+
76+
exportasyncfunctionrunOpenApi(
77+
actionData:ActionDataType,
78+
dataSourceConfig:DataSourceDataType,
79+
spec:OpenAPI.Document|MultiOpenApiSpecItem[],
80+
defaultHeaders?:Record<string,string>,
81+
openApiSpecDereferenced?:OpenAPI.Document,
82+
){
7983
const{ actionName, ...otherActionData}=actionData;
8084
const{ serverURL}=dataSourceConfig;
8185

82-
letdefinition:OpenAPI.Document|undefined;
83-
letoperation;
84-
letrealOperationId;
86+
letoperation,realOperationId,definition:OpenAPI.Document|undefined;
8587

86-
for(const{id, def}ofdefinitions){
88+
for(const{id, def}ofawaitgetDefinitions(spec,openApiSpecDereferenced)){
8789
constret=findOperation(actionName,def,id);
8890
if(ret){
8991
definition=def;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp