-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kotlin client/spacings indentations #9853
Kotlin client/spacings indentations #9853
Conversation
Bumps [jimschubert/query-tag-action](https://github.com/jimschubert/query-tag-action) from 1 to 2. - [Release notes](https://github.com/jimschubert/query-tag-action/releases) - [Commits](jimschubert/query-tag-action@v1...v2) Signed-off-by: dependabot[bot] <support@github.com>
…back encode/decode for each enum.
{{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} `{{name}}`: {{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone mistakenly removed default values for this data class. Brought back now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not have been by mistake. I just updated to version 5.2.1 and enum values are now initialized with unknown class.
I think {{{defaultValue}}}
may not be well defined.
data class MyDataClass (
@Json(name = "type")
val type: MyDataClass.Type = TypeEnum.MOVE,
) : MyDataClass {
/**
*
*
* Values: MOVE
*/
enum class Type(val value: kotlin.String) {
@Json(name = "MOVE") MOVE("MOVE");
}
}
TypeEnum
is not something that exists in the codebase. It should be MyDataClass.type.MOVE
I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably similar to #10244
modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noordawod I left some questions to you in the code review, could you please take a look at those? 🙂
samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Order.kt
Show resolved
Hide resolved
...es/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt
Outdated
Show resolved
Hide resolved
...s/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt
Outdated
Show resolved
Hide resolved
Build failed for another reason: |
I believe all is taken care of now, @4brunu. |
@noordawod Could you please solve the merge conflicts? |
/** | ||
* Converts the provided [data] to a [String] on success, null otherwise. | ||
*/ | ||
fun encode(data: Any?): kotlin.String? = if (data is {{classname}}) "$data" else null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noordawod could you please explain what is the use case for this utility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused by me, but because decode()
is introduced I wanted to compliment it with an encode()
, I think it's a good practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ps: I use decode()
.
@noordawod When you have some time, could you please solve the merge conflicts? 🙂 |
Yup, was on a holiday ;) I'll attend to this asap! |
Sorry, when you have time :) |
Synced and pushed now, let's hope everything passes. |
Some tests aren't passing because of |
…ubert/query-tag-action-2 Bump jimschubert/query-tag-action from 1 to 2
Looks good to me 👍 |
There has been changes in the Kotlin template that wrecked the beautifully-generated code that I'm used to, plus removed few important utility functions for enums for no obvious reason.
Well, I brought these utility functions back and also added plenty of reserved keywords and operators that were missing from the Kotlin generator.
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
,5.1.x
,6.0.x
@jimschubert @dr4ke616 @karismann @Zomzog @andrewemery @4brunu @yutaka0m