Skip to content

Commit

Permalink
[REQ][typescript-axios] useSingleRequestParameter should mark paramet…
Browse files Browse the repository at this point in the history
…er 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
  • Loading branch information
codeserk committed May 29, 2020
1 parent 7cef7b7 commit 3bf28be
Show file tree
Hide file tree
Showing 5 changed files with 706 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
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 $@"
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 $@"

java $JAVA_OPTS -jar $executable $ags
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ If Not Exist %executable% (
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
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
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

java %JAVA_OPTS% -jar %executable% %ags%
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export class {{classname}} extends BaseAPI {
* @memberof {{classname}}
*/
{{#useSingleRequestParameter}}
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request, {{/allParams.0}}options?: any) {
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: any) {
return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(this.axios, this.basePath));
}
{{/useSingleRequestParameter}}
Expand Down
Loading

0 comments on commit 3bf28be

Please sign in to comment.