Skip to content

Commit

Permalink
[typescript][axios] Add any to index type when additionalPropertiesIs…
Browse files Browse the repository at this point in the history
…AnyType is true (#16494) (#17625)
  • Loading branch information
wouter-rednose authored Feb 2, 2024
1 parent eb7d2d9 commit 5397f64
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ public ModelsMap postProcessModels(ModelsMap objs) {
for (ModelMap mo : models) {
CodegenModel cm = mo.getModel();

// Type is already any
if (cm.getAdditionalPropertiesIsAnyType() && "any".equals(cm.getAdditionalPropertiesType())) {
cm.setAdditionalPropertiesIsAnyType(false);
}

// Deduce the model file name in kebab case
cm.classFilename = cm.classname.replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase(Locale.ROOT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
{{#additionalPropertiesType}}
[key: string]: {{{additionalPropertiesType}}}{{^additionalPropertiesIsAnyType}}{{#hasVars}} | any{{/hasVars}}{{/additionalPropertiesIsAnyType}};
[key: string]: {{{additionalPropertiesType}}}{{#additionalPropertiesIsAnyType}}{{#hasVars}} | any{{/hasVars}}{{/additionalPropertiesIsAnyType}};

{{/additionalPropertiesType}}
{{#vars}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export interface Dog extends Animal {
* @interface Drawing
*/
export interface Drawing {
[key: string]: Fruit;
[key: string]: Fruit | any;

/**
*
Expand Down Expand Up @@ -1043,7 +1043,7 @@ export interface Name {
* @interface NullableClass
*/
export interface NullableClass {
[key: string]: object;
[key: string]: object | any;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ export interface Name {
* @interface NullableClass
*/
export interface NullableClass {
[key: string]: object;
[key: string]: object | any;

/**
*
Expand Down

0 comments on commit 5397f64

Please sign in to comment.