Skip to content

Commit 38a8dc2

Browse files
committed
As suggested in #3759 (comment), I renamed serializationEngine to serializationLibrary
Fixed the data class mustache template to not add an extra line between the @entity and the variable name Regenerated petstore samples
1 parent 2d945a9 commit 38a8dc2

53 files changed

Lines changed: 29 additions & 190 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
202202
public static final String ENUM_PROPERTY_NAMING = "enumPropertyNaming";
203203
public static final String ENUM_PROPERTY_NAMING_DESC = "Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'";
204204

205-
public static final String SERIALIZATION_ENGINE = "serializationEngine";
206-
public static final String SERIALIZATION_ENGINE_DESC = "What serialization engine to use: 'moshi' (default), or 'gson'";
207-
public static enum SERIALIZATION_ENGINE_TYPE {moshi, gson}
205+
public static final String SERIALIZATION_LIBRARY = "serializationLibrary";
206+
public static final String SERIALIZATION_LIBRARY_DESC = "What serialization library to use: 'moshi' (default), or 'gson'";
207+
public static enum SERIALIZATION_LIBRARY_TYPE {moshi, gson}
208208

209209
public static final String MODEL_NAME_PREFIX = "modelNamePrefix";
210210
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names.";

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
5151
protected boolean parcelizeModels = false;
5252

5353
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.camelCase;
54-
protected CodegenConstants.SERIALIZATION_ENGINE_TYPE serializationEngine = CodegenConstants.SERIALIZATION_ENGINE_TYPE.moshi;
54+
protected CodegenConstants.SERIALIZATION_LIBRARY_TYPE serializationLibrary = CodegenConstants.SERIALIZATION_LIBRARY_TYPE.moshi;
5555

5656
public AbstractKotlinCodegen() {
5757
super();
@@ -207,8 +207,8 @@ public AbstractKotlinCodegen() {
207207
CliOption enumPropertyNamingOpt = new CliOption(CodegenConstants.ENUM_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC);
208208
cliOptions.add(enumPropertyNamingOpt.defaultValue(enumPropertyNaming.name()));
209209

210-
CliOption serializationEngineOpt = new CliOption(CodegenConstants.SERIALIZATION_ENGINE, CodegenConstants.SERIALIZATION_ENGINE_DESC);
211-
cliOptions.add(serializationEngineOpt.defaultValue(serializationEngine.name()));
210+
CliOption serializationLibraryOpt = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY, CodegenConstants.SERIALIZATION_LIBRARY_DESC);
211+
cliOptions.add(serializationLibraryOpt.defaultValue(serializationLibrary.name()));
212212

213213
cliOptions.add(new CliOption(CodegenConstants.PARCELIZE_MODELS, CodegenConstants.PARCELIZE_MODELS_DESC));
214214
}
@@ -249,8 +249,8 @@ public CodegenConstants.ENUM_PROPERTY_NAMING_TYPE getEnumPropertyNaming() {
249249
return this.enumPropertyNaming;
250250
}
251251

252-
public CodegenConstants.SERIALIZATION_ENGINE_TYPE getSerializationEngine() {
253-
return this.serializationEngine;
252+
public CodegenConstants.SERIALIZATION_LIBRARY_TYPE getSerializationLibrary() {
253+
return this.serializationLibrary;
254254
}
255255

256256
/**
@@ -273,14 +273,14 @@ public void setEnumPropertyNaming(final String enumPropertyNamingType) {
273273
/**
274274
* Sets the serialization engine for Kotlin
275275
*
276-
* @param enumSerializationEngine The string representation of the serialization engine as defined by {@link CodegenConstants.SERIALIZATION_ENGINE_TYPE}
276+
* @param enumSerializationLibrary The string representation of the serialization library as defined by {@link CodegenConstants.SERIALIZATION_LIBRARY_TYPE}
277277
*/
278-
public void setSerializationEngine(final String enumSerializationEngine) {
278+
public void setSerializationLibrary(final String enumSerializationLibrary) {
279279
try {
280-
this.serializationEngine = CodegenConstants.SERIALIZATION_ENGINE_TYPE.valueOf(enumSerializationEngine);
280+
this.serializationLibrary = CodegenConstants.SERIALIZATION_LIBRARY_TYPE.valueOf(enumSerializationLibrary);
281281
} catch (IllegalArgumentException ex) {
282-
StringBuilder sb = new StringBuilder(enumSerializationEngine + " is an invalid enum property naming option. Please choose from:");
283-
for (CodegenConstants.SERIALIZATION_ENGINE_TYPE t : CodegenConstants.SERIALIZATION_ENGINE_TYPE.values()) {
282+
StringBuilder sb = new StringBuilder(enumSerializationLibrary + " is an invalid enum property naming option. Please choose from:");
283+
for (CodegenConstants.SERIALIZATION_LIBRARY_TYPE t : CodegenConstants.SERIALIZATION_LIBRARY_TYPE.values()) {
284284
sb.append("\n ").append(t.name());
285285
}
286286
throw new RuntimeException(sb.toString());
@@ -356,12 +356,12 @@ public void processOpts() {
356356
setEnumPropertyNaming((String) additionalProperties.get(CodegenConstants.ENUM_PROPERTY_NAMING));
357357
}
358358

359-
if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_ENGINE)) {
360-
setSerializationEngine((String) additionalProperties.get(CodegenConstants.SERIALIZATION_ENGINE));
361-
additionalProperties.put(this.serializationEngine.name(), true);
359+
if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {
360+
setSerializationLibrary((String) additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY));
361+
additionalProperties.put(this.serializationLibrary.name(), true);
362362
}
363363
else {
364-
additionalProperties.put(this.serializationEngine.name(), true);
364+
additionalProperties.put(this.serializationLibrary.name(), true);
365365
}
366366

367367
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{{#description}}
22
/* {{{description}}} */
33
{{/description}}
4-
{{#moshi}}@Json(name = "{{{baseName}}}"){{/moshi}}
5-
{{#gson}}@SerializedName("{{name}}"){{/gson}}
4+
{{#moshi}}
5+
@Json(name = "{{{baseName}}}")
6+
{{/moshi}}
7+
{{#gson}}
8+
@SerializedName("{{name}}")
9+
{{/gson}}
610
val {{{name}}}: {{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{{#description}}
22
/* {{{description}}} */
33
{{/description}}
4-
{{#moshi}}@Json(name = "{{{baseName}}}"){{/moshi}}
5-
{{#gson}}@SerializedName("{{name}}"){{/gson}}
4+
{{#moshi}}
5+
@Json(name = "{{{baseName}}}")
6+
{{/moshi}}
7+
{{#gson}}
8+
@SerializedName("{{name}}")
9+
{{/gson}}
610
val {{{name}}}: {{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}

samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@ import com.squareup.moshi.Json
2121
*/
2222
data class ApiResponse (
2323
@Json(name = "code")
24-
2524
val code: kotlin.Int? = null,
2625
@Json(name = "type")
27-
2826
val type: kotlin.String? = null,
2927
@Json(name = "message")
30-
3128
val message: kotlin.String? = null
3229
)
3330

samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Category.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ import com.squareup.moshi.Json
2020
*/
2121
data class Category (
2222
@Json(name = "id")
23-
2423
val id: kotlin.Long? = null,
2524
@Json(name = "name")
26-
2725
val name: kotlin.String? = null
2826
)
2927

samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,17 @@ import com.squareup.moshi.Json
2424
*/
2525
data class Order (
2626
@Json(name = "id")
27-
2827
val id: kotlin.Long? = null,
2928
@Json(name = "petId")
30-
3129
val petId: kotlin.Long? = null,
3230
@Json(name = "quantity")
33-
3431
val quantity: kotlin.Int? = null,
3532
@Json(name = "shipDate")
36-
3733
val shipDate: java.time.LocalDateTime? = null,
3834
/* Order Status */
3935
@Json(name = "status")
40-
4136
val status: Order.Status? = null,
4237
@Json(name = "complete")
43-
4438
val complete: kotlin.Boolean? = null
4539
)
4640

samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Pet.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,17 @@ import com.squareup.moshi.Json
2626
*/
2727
data class Pet (
2828
@Json(name = "name")
29-
3029
val name: kotlin.String,
3130
@Json(name = "photoUrls")
32-
3331
val photoUrls: kotlin.Array<kotlin.String>,
3432
@Json(name = "id")
35-
3633
val id: kotlin.Long? = null,
3734
@Json(name = "category")
38-
3935
val category: Category? = null,
4036
@Json(name = "tags")
41-
4237
val tags: kotlin.Array<Tag>? = null,
4338
/* pet status in the store */
4439
@Json(name = "status")
45-
4640
val status: Pet.Status? = null
4741
)
4842

samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Tag.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ import com.squareup.moshi.Json
2020
*/
2121
data class Tag (
2222
@Json(name = "id")
23-
2423
val id: kotlin.Long? = null,
2524
@Json(name = "name")
26-
2725
val name: kotlin.String? = null
2826
)
2927

samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/User.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,21 @@ import com.squareup.moshi.Json
2626
*/
2727
data class User (
2828
@Json(name = "id")
29-
3029
val id: kotlin.Long? = null,
3130
@Json(name = "username")
32-
3331
val username: kotlin.String? = null,
3432
@Json(name = "firstName")
35-
3633
val firstName: kotlin.String? = null,
3734
@Json(name = "lastName")
38-
3935
val lastName: kotlin.String? = null,
4036
@Json(name = "email")
41-
4237
val email: kotlin.String? = null,
4338
@Json(name = "password")
44-
4539
val password: kotlin.String? = null,
4640
@Json(name = "phone")
47-
4841
val phone: kotlin.String? = null,
4942
/* User Status */
5043
@Json(name = "userStatus")
51-
5244
val userStatus: kotlin.Int? = null
5345
)
5446

0 commit comments

Comments
 (0)