Skip to content

Commit 0acb15c

Browse files
committed
fix(typescript-axios): warn when useErasableSyntax and stringEnums are both enabled
TypeScript enum declarations are not erasable syntax and will fail with erasableSyntaxOnly. Log a warning guiding users to disable stringEnums (the default generates erasable-compatible const objects).
1 parent 0417ca0 commit 0acb15c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import lombok.Getter;
2323
import lombok.Setter;
2424
import org.apache.commons.lang3.StringUtils;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
2527
import org.openapitools.codegen.*;
2628
import org.openapitools.codegen.meta.features.DocumentationFeature;
2729
import org.openapitools.codegen.meta.features.SecurityFeature;
@@ -39,6 +41,8 @@
3941

4042
public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodegen {
4143

44+
private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptAxiosClientCodegen.class);
45+
4246
public static final String NPM_REPOSITORY = "npmRepository";
4347
public static final String WITH_INTERFACES = "withInterfaces";
4448
public static final String SEPARATE_MODELS_AND_API = "withSeparateModelsAndApi";
@@ -186,6 +190,13 @@ public void processOpts() {
186190
additionalProperties.put(USE_ERASABLE_SYNTAX, this.useErasableSyntax);
187191
}
188192

193+
if (this.useErasableSyntax && this.stringEnums) {
194+
LOGGER.warn("useErasableSyntax and stringEnums are both enabled. "
195+
+ "TypeScript 'enum' declarations are not erasable syntax and will fail with "
196+
+ "erasableSyntaxOnly. Consider disabling stringEnums (the default generates "
197+
+ "erasable-compatible const objects instead).");
198+
}
199+
189200
if (additionalProperties.containsKey(NPM_NAME)) {
190201
addNpmPackageGeneration();
191202
}

0 commit comments

Comments
 (0)