Skip to content

Commit 3bf28be

Browse files
authored
[REQ][typescript-axios] useSingleRequestParameter should mark parameter optional if all properties are optional (#6477)
* Include map for `AnyType` in `typescript` * Exclude `any` from the list of types extracted from `anyOf`, `allOf`, `oneOf` Exclude if there are other meaningful types * Include new scripts and `yaml` to test the new case * Execute the new sample for `typescript-axios` * Filter out only `AnyType` instead of all `any` types * Renamed and modified samples - Included more examples using `oneOf, `allOf`, `anyOf` - Includede examples when types that are translated to `any` are involved (`file`) * Changes in mustache file Set default value to empty object when the `requestParameter` doesn't have any required param * New schema with operations without required params * Generate the sample
1 parent 7cef7b7 commit 3bf28be

File tree

5 files changed

+706
-15
lines changed

5 files changed

+706
-15
lines changed

bin/typescript-axios-petstore-with-single-request-parameters.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/with-single-request-parameters --additional-properties useSingleRequestParameter=true $@"
30+
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-with-operations-without-required-params.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/with-single-request-parameters --additional-properties useSingleRequestParameter=true $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/windows/typescript-axios-petstore-with-single-request-parameters.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ If Not Exist %executable% (
77
)
88

99
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
10-
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\with-single-request-parameters --additional-properties useSingleRequestParameter=true
10+
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-operations-without-required-params.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\with-single-request-parameters --additional-properties useSingleRequestParameter=true
1111

1212
java %JAVA_OPTS% -jar %executable% %ags%

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ export class {{classname}} extends BaseAPI {
351351
* @memberof {{classname}}
352352
*/
353353
{{#useSingleRequestParameter}}
354-
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request, {{/allParams.0}}options?: any) {
354+
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: any) {
355355
return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(this.axios, this.basePath));
356356
}
357357
{{/useSingleRequestParameter}}

0 commit comments

Comments
 (0)