@acrool/rtk-query-codegen-openapi 1.0.6-alpha.0 → 1.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bin/cli.mjs +26 -22
- package/lib/bin/cli.mjs.map +1 -1
- package/lib/index.js +28 -6
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +28 -6
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/generators/rtk-query-generator.ts +43 -17
- package/src/services/endpoint-info-extractor.ts +10 -4
|
@@ -19,6 +19,7 @@ export interface EndpointInfo {
|
|
|
19
19
|
isVoidArg: boolean;
|
|
20
20
|
summary: string;
|
|
21
21
|
contentType: string;
|
|
22
|
+
hasRequestBody: boolean;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -65,7 +66,7 @@ export class EndpointInfoExtractor {
|
|
|
65
66
|
const summary = operation.summary || `${verb.toUpperCase()} ${path}`;
|
|
66
67
|
|
|
67
68
|
// 解析參數
|
|
68
|
-
const { queryParams, pathParams, isVoidArg } = this.extractParameters(operationDefinition);
|
|
69
|
+
const { queryParams, pathParams, isVoidArg, hasRequestBody } = this.extractParameters(operationDefinition);
|
|
69
70
|
|
|
70
71
|
// 提取 content type
|
|
71
72
|
const contentType = this.extractContentType(operation);
|
|
@@ -82,7 +83,8 @@ export class EndpointInfoExtractor {
|
|
|
82
83
|
pathParams,
|
|
83
84
|
isVoidArg,
|
|
84
85
|
summary,
|
|
85
|
-
contentType
|
|
86
|
+
contentType,
|
|
87
|
+
hasRequestBody
|
|
86
88
|
};
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -97,20 +99,24 @@ export class EndpointInfoExtractor {
|
|
|
97
99
|
const operationParameters = this.resolveArray(operation.parameters);
|
|
98
100
|
const pathItemParameters = this.resolveArray(pathItem.parameters)
|
|
99
101
|
.filter((pp) => !operationParameters.some((op) => op.name === pp.name && op.in === pp.in));
|
|
100
|
-
|
|
102
|
+
|
|
101
103
|
const allParameters = supportDeepObjects([...pathItemParameters, ...operationParameters])
|
|
102
104
|
.filter((param) => param.in !== 'header');
|
|
103
105
|
|
|
104
106
|
const queryParams = allParameters.filter(param => param.in === 'query');
|
|
105
107
|
const pathParams = allParameters.filter(param => param.in === 'path');
|
|
106
108
|
|
|
109
|
+
// 檢查是否有 request body
|
|
110
|
+
const hasRequestBody = !!operation.requestBody;
|
|
111
|
+
|
|
107
112
|
// 檢查是否為 void 類型參數
|
|
108
113
|
const isVoidArg = queryParams.length === 0 && pathParams.length === 0 && !operation.requestBody;
|
|
109
114
|
|
|
110
115
|
return {
|
|
111
116
|
queryParams,
|
|
112
117
|
pathParams,
|
|
113
|
-
isVoidArg
|
|
118
|
+
isVoidArg,
|
|
119
|
+
hasRequestBody
|
|
114
120
|
};
|
|
115
121
|
}
|
|
116
122
|
|