@@ -33,8 +33,6 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegenConfig {
3333 protected String apiDocPath = "docs/" ;
3434 protected String modelDocPath = "docs/" ;
3535
36- protected CodegenConstants .ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants .ENUM_PROPERTY_NAMING_TYPE .camelCase ;
37-
3836 public AbstractKotlinCodegen () {
3937 super ();
4038 supportsInheritance = true ;
@@ -197,16 +195,14 @@ public AbstractKotlinCodegen() {
197195 importMapping .put ("LocalTime" , "java.time.LocalTime" );
198196
199197 specialCharReplacements .put (";" , "Semicolon" );
198+ specialCharReplacements .put (":" , "Colon" );
200199
201200 cliOptions .clear ();
202201 addOption (CodegenConstants .SOURCE_FOLDER , CodegenConstants .SOURCE_FOLDER_DESC , sourceFolder );
203202 addOption (CodegenConstants .PACKAGE_NAME , "Generated artifact package name (e.g. io.swagger)." , packageName );
204203 addOption (CodegenConstants .GROUP_ID , "Generated artifact package's organization (i.e. maven groupId)." , groupId );
205204 addOption (CodegenConstants .ARTIFACT_ID , "Generated artifact id (name of jar)." , artifactId );
206205 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 ()));
210206 }
211207
212208 protected void addOption (String key , String description ) {
@@ -257,27 +253,6 @@ public String escapeUnsafeCharacters(String input) {
257253 return input .replace ("*/" , "*_/" ).replace ("/*" , "/_*" );
258254 }
259255
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-
281256 /**
282257 * Output the type declaration of the property
283258 *
@@ -351,10 +326,6 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
351326 public void processOpts () {
352327 super .processOpts ();
353328
354- if (additionalProperties .containsKey (CodegenConstants .ENUM_PROPERTY_NAMING )) {
355- setEnumPropertyNaming ((String ) additionalProperties .get (CodegenConstants .ENUM_PROPERTY_NAMING ));
356- }
357-
358329 if (additionalProperties .containsKey (CodegenConstants .SOURCE_FOLDER )) {
359330 this .setSourceFolder ((String ) additionalProperties .get (CodegenConstants .SOURCE_FOLDER ));
360331 } else {
@@ -435,29 +406,7 @@ public String toEnumVarName(String value, String datatype) {
435406 } else {
436407 modified = value ;
437408 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 ();
461410 }
462411
463412 if (isReservedWord (modified )) {
@@ -623,4 +572,4 @@ protected boolean needToImport(String type) {
623572
624573 return imports ;
625574 }
626- }
575+ }
0 commit comments