[typescript][axios] Add any to index type when additionalPropertiesIsAnyType is true (#16494) (#17625)

This commit is contained in:
wouter-rednose 2024-02-02 16:04:42 +01:00 committed by GitHub
parent eb7d2d9fd2
commit 5397f64595
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 4 deletions

View File

@ -226,6 +226,11 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
for (ModelMap mo : models) { for (ModelMap mo : models) {
CodegenModel cm = mo.getModel(); 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 // Deduce the model file name in kebab case
cm.classFilename = cm.classname.replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase(Locale.ROOT); cm.classFilename = cm.classname.replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase(Locale.ROOT);

View File

@ -5,7 +5,7 @@
*/ */
export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
{{#additionalPropertiesType}} {{#additionalPropertiesType}}
[key: string]: {{{additionalPropertiesType}}}{{^additionalPropertiesIsAnyType}}{{#hasVars}} | any{{/hasVars}}{{/additionalPropertiesIsAnyType}}; [key: string]: {{{additionalPropertiesType}}}{{#additionalPropertiesIsAnyType}}{{#hasVars}} | any{{/hasVars}}{{/additionalPropertiesIsAnyType}};
{{/additionalPropertiesType}} {{/additionalPropertiesType}}
{{#vars}} {{#vars}}

View File

@ -447,7 +447,7 @@ export interface Dog extends Animal {
* @interface Drawing * @interface Drawing
*/ */
export interface Drawing { export interface Drawing {
[key: string]: Fruit; [key: string]: Fruit | any;
/** /**
* *
@ -1043,7 +1043,7 @@ export interface Name {
* @interface NullableClass * @interface NullableClass
*/ */
export interface NullableClass { export interface NullableClass {
[key: string]: object; [key: string]: object | any;
/** /**
* *

View File

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