Skip to content

Commit 50ca85b

Browse files
committed
remove single-request option from axios slim
1 parent ac8c6c6 commit 50ca85b

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

docs/generators/typescript-axios-slim.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ title: Documentation for the typescript-axios-slim Generator
1111
| generator type | CLIENT | |
1212
| generator language | Typescript | |
1313
| generator default templating engine | mustache | |
14-
| helpTxt | Generates a TypeScript client library using axios (slim direct API style with valibot validation). | |
14+
| helpTxt | Generates a TypeScript client library using axios (slim direct API style with valibot validation and enforced single request parameter object). | |
1515

1616
## CONFIG OPTIONS
1717
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
@@ -42,7 +42,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
4242
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
4343
|stringEnums|Generate string enums instead of objects for enum values.| |false|
4444
|supportsES6|Generate code that conforms to ES6.| |false|
45-
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false|
4645
|useSquareBracketsInArrayNames|Setting this property to true will add brackets to array attribute names, e.g. my_values[].| |false|
4746
|withAWSV4Signature|whether to include AWS v4 signature support| |false|
4847
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosSlimClientCodegen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public TypeScriptAxiosSlimClientCodegen() {
2323
super();
2424
outputFolder = "generated-code/typescript-axios-slim";
2525
embeddedTemplateDir = templateDir = "typescript-axios-slim";
26+
cliOptions.removeIf(option -> USE_SINGLE_REQUEST_PARAMETER.equals(option.getOpt()));
2627
additionalProperties.put(USE_SINGLE_REQUEST_PARAMETER, true);
2728
}
2829

@@ -40,6 +41,6 @@ public String getName() {
4041

4142
@Override
4243
public String getHelp() {
43-
return "Generates a TypeScript client library using axios (slim direct API style with valibot validation).";
44+
return "Generates a TypeScript client library using axios (slim direct API style with valibot validation and enforced single request parameter object).";
4445
}
4546
}

modules/openapi-generator/src/main/resources/typescript-axios-slim/README.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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:
44

5-
> `typescript-axios-slim` intentionally differs from `typescript-axios`: it removes `AxiosParamCreator`, `Fp`, and `Factory` layers 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.
66

77
Environment
88
* Node.js

modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/axios/TypeScriptAxiosSlimParityTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ public void shouldReturnPayloadDataFromObjectOrientedMethods() throws Exception
131131
assertTrue(apiSource.contains("return localVarResponse.data;"), "Slim API class should resolve axios response data directly");
132132
}
133133

134+
@Test(description = "slim: useSingleRequestParameter remains enabled even if configured false")
135+
public void shouldForceSingleRequestParameterForSlimGenerator() throws Exception {
136+
Consumer<CodegenConfigurator> forceSingleRequestFalse = cfg -> cfg.addAdditionalProperty("useSingleRequestParameter", false);
137+
138+
IdentitySurface axiosSurface = generateIdentity("typescript-axios", EDGE_CASE_SPEC, NO_CUSTOMIZER);
139+
IdentitySurface slimSurface = generateIdentity("typescript-axios-slim", EDGE_CASE_SPEC, forceSingleRequestFalse);
140+
141+
assertIdentitySurfaceEquals("forced-single-request-parameter", axiosSurface, slimSurface);
142+
}
143+
134144
private IdentitySurface generateIdentity(String generatorName, String specPath, Consumer<CodegenConfigurator> customizer) throws Exception {
135145
File output = Files.createTempDirectory("typescript_axios_identity_").toFile().getCanonicalFile();
136146
output.deleteOnExit();

0 commit comments

Comments
 (0)