@@ -33,8 +33,6 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegenConfig {
33
33
protected String apiDocPath = "docs/" ;
34
34
protected String modelDocPath = "docs/" ;
35
35
36
- protected CodegenConstants .ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants .ENUM_PROPERTY_NAMING_TYPE .camelCase ;
37
-
38
36
public AbstractKotlinCodegen () {
39
37
super ();
40
38
supportsInheritance = true ;
@@ -197,16 +195,14 @@ public AbstractKotlinCodegen() {
197
195
importMapping .put ("LocalTime" , "java.time.LocalTime" );
198
196
199
197
specialCharReplacements .put (";" , "Semicolon" );
198
+ specialCharReplacements .put (":" , "Colon" );
200
199
201
200
cliOptions .clear ();
202
201
addOption (CodegenConstants .SOURCE_FOLDER , CodegenConstants .SOURCE_FOLDER_DESC , sourceFolder );
203
202
addOption (CodegenConstants .PACKAGE_NAME , "Generated artifact package name (e.g. io.swagger)." , packageName );
204
203
addOption (CodegenConstants .GROUP_ID , "Generated artifact package's organization (i.e. maven groupId)." , groupId );
205
204
addOption (CodegenConstants .ARTIFACT_ID , "Generated artifact id (name of jar)." , artifactId );
206
205
addOption (CodegenConstants .ARTIFACT_VERSION , "Generated artifact's package version." , artifactVersion );
207
-
208
- CliOption enumPropertyNamingOpt = new CliOption (CodegenConstants .ENUM_PROPERTY_NAMING , CodegenConstants .ENUM_PROPERTY_NAMING_DESC );
209
- cliOptions .add (enumPropertyNamingOpt .defaultValue (enumPropertyNaming .name ()));
210
206
}
211
207
212
208
protected void addOption (String key , String description ) {
@@ -257,27 +253,6 @@ public String escapeUnsafeCharacters(String input) {
257
253
return input .replace ("*/" , "*_/" ).replace ("/*" , "/_*" );
258
254
}
259
255
260
- public CodegenConstants .ENUM_PROPERTY_NAMING_TYPE getEnumPropertyNaming () {
261
- return this .enumPropertyNaming ;
262
- }
263
-
264
- /**
265
- * Sets the naming convention for Kotlin enum properties
266
- *
267
- * @param enumPropertyNamingType The string representation of the naming convention, as defined by {@link CodegenConstants.ENUM_PROPERTY_NAMING_TYPE}
268
- */
269
- public void setEnumPropertyNaming (final String enumPropertyNamingType ) {
270
- try {
271
- this .enumPropertyNaming = CodegenConstants .ENUM_PROPERTY_NAMING_TYPE .valueOf (enumPropertyNamingType );
272
- } catch (IllegalArgumentException ex ) {
273
- StringBuilder sb = new StringBuilder (enumPropertyNamingType + " is an invalid enum property naming option. Please choose from:" );
274
- for (CodegenConstants .ENUM_PROPERTY_NAMING_TYPE t : CodegenConstants .ENUM_PROPERTY_NAMING_TYPE .values ()) {
275
- sb .append ("\n " ).append (t .name ());
276
- }
277
- throw new RuntimeException (sb .toString ());
278
- }
279
- }
280
-
281
256
/**
282
257
* Output the type declaration of the property
283
258
*
@@ -351,10 +326,6 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
351
326
public void processOpts () {
352
327
super .processOpts ();
353
328
354
- if (additionalProperties .containsKey (CodegenConstants .ENUM_PROPERTY_NAMING )) {
355
- setEnumPropertyNaming ((String ) additionalProperties .get (CodegenConstants .ENUM_PROPERTY_NAMING ));
356
- }
357
-
358
329
if (additionalProperties .containsKey (CodegenConstants .SOURCE_FOLDER )) {
359
330
this .setSourceFolder ((String ) additionalProperties .get (CodegenConstants .SOURCE_FOLDER ));
360
331
} else {
@@ -435,29 +406,7 @@ public String toEnumVarName(String value, String datatype) {
435
406
} else {
436
407
modified = value ;
437
408
modified = sanitizeKotlinSpecificNames (modified );
438
- }
439
-
440
- switch (getEnumPropertyNaming ()) {
441
- case original :
442
- // NOTE: This is provided as a last-case allowance, but will still result in reserved words being escaped.
443
- modified = value ;
444
- break ;
445
- case camelCase :
446
- // NOTE: Removes hyphens and underscores
447
- modified = camelize (modified , true );
448
- break ;
449
- case PascalCase :
450
- // NOTE: Removes hyphens and underscores
451
- String result = camelize (modified );
452
- modified = titleCase (result );
453
- break ;
454
- case snake_case :
455
- // NOTE: Removes hyphens
456
- modified = underscore (modified );
457
- break ;
458
- case UPPERCASE :
459
- modified = modified .toUpperCase ();
460
- break ;
409
+ modified = modified .toUpperCase ();
461
410
}
462
411
463
412
if (isReservedWord (modified )) {
@@ -623,4 +572,4 @@ protected boolean needToImport(String type) {
623
572
624
573
return imports ;
625
574
}
626
- }
575
+ }
0 commit comments