You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/generators/typescript-axios-slim.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
49
49
|withSeparateModelsAndApi|Put the model and api in separate folders and in separate classes. This requires in addition a value for 'apiPackage' and 'modelPackage'||false|
50
50
|withoutPrefixEnums|Don't prefix enum names with class names||false|
51
51
52
+
Generated API methods default to resolving payload data. Pass `observe: 'response'` in the request config to receive `AxiosResponse<T>` when you need headers or status metadata.
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/resources/typescript-axios-slim/README.mustache
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
4
4
5
-
> `typescript-axios-slim` intentionally differs from `typescript-axios`: it removes `AxiosParamCreator`, `Fp`, and `Factory` layers, always uses a single request-parameter object per operation, and emits direct class methods with request-parameter schema validation.
5
+
> `typescript-axios-slim` intentionally differs from `typescript-axios`: it removes `AxiosParamCreator`, `Fp`, and `Factory` layers, always uses a single request-parameter object per operation, and emits direct class methods with request-parameter schema validation. By default methods resolve payload data directly; pass `observe: 'response'` to receive full `AxiosResponse` values when you need headers or status metadata.
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/axios/TypeScriptAxiosSlimParityTest.java
+47-4Lines changed: 47 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -125,10 +125,24 @@ public void shouldReturnPayloadDataFromObjectOrientedMethods() throws Exception
assertTrue(apiSource.contains("): Promise<"), "Slim API methods should return Promise payload types");
128
+
assertTrue(apiSource.contains("<TObserve extends ObserveOptions = ObserveOptions>"), "Slim API methods should expose observe-aware generics");
129
+
assertTrue(apiSource.contains("options: TObserve = {} as TObserve): Promise<TObserve extends ResponseObserveOptions ? AxiosResponse<"), "Slim API methods should return payload types by default through observe-aware generics");
129
130
assertFalse(apiSource.contains("AxiosPromise<"), "Slim API interface should not expose AxiosPromise return wrappers");
130
-
assertFalse(apiSource.contains("Promise<AxiosResponse<"), "Slim API class should not return Promise<AxiosResponse<T>>");
131
-
assertTrue(apiSource.contains("return localVarResponse.data;"), "Slim API class should resolve axios response data directly");
131
+
assertTrue(apiSource.contains("options: ResponseObserveOptions): Promise<AxiosResponse<"), "Slim API methods should preserve explicit response overloads when observe=response");
132
+
assertTrue(apiSource.contains("const localVarObserve = options.observe ?? 'body';"), "Slim API class should default observe mode to body");
133
+
assertTrue(apiSource.contains("return localVarResponse as TObserve extends ResponseObserveOptions ? AxiosResponse<"), "Slim API class should return raw axios responses when observe=response");
134
+
assertTrue(apiSource.contains("return localVarResponse.data as TObserve extends ResponseObserveOptions ? AxiosResponse<"), "Slim API class should resolve axios response data directly");
135
+
}
136
+
137
+
@Test(description = "slim: observe options are exported for typed response access")
assertTrue(commonSource.contains("export type Observe = 'body' | 'response';"), "Slim common runtime should export observe mode types");
144
+
assertTrue(commonSource.contains("export type ObserveOptions = BodyObserveOptions | ResponseObserveOptions;"), "Slim common runtime should export observe option union types");
145
+
assertTrue(apiSource.contains("const { observe, ...axiosOptions } = options;"), "Slim API class should strip observe before forwarding axios options");
132
146
}
133
147
134
148
@Test(description = "slim: useSingleRequestParameter remains enabled even if configured false")
0 commit comments