-
Notifications
You must be signed in to change notification settings - Fork 37
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
[Polymorphism Prep] Expose private KotlinGenerator methods in SharedCodegen #104
base: master
Are you sure you want to change the base?
Conversation
e6e330b
to
4fc3396
Compare
I've rebased this branch on top of the laster master to remove the merge conflicts. @cortinico could you please have a look to this CR? This provides a starting point for for #103 and by itself does not provide any change that deserve a major release, so it could be merged even if we're not yet planning on having the 2.0.0 release |
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.
Left several comments.
Maybe having also the second part will help understand some of the changes?
Generally looks good, but having some tests will be beneficial 👍
gradle-plugin/plugin/src/main/java/com/yelp/codegen/KotlinGenerator.kt
Outdated
Show resolved
Hide resolved
gradle-plugin/plugin/src/main/java/com/yelp/codegen/SharedCodegen.kt
Outdated
Show resolved
Hide resolved
gradle-plugin/plugin/src/main/java/com/yelp/codegen/utils/CodegenModelVar.kt
Show resolved
Hide resolved
*/ | ||
fun forEachVarAttribute( | ||
codegenModel: CodegenModel, | ||
action: (CodegenModelVar, MutableList<CodegenProperty>) -> Unit |
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.
Seems like the CodegenModelVar
here is unused. Can you please remove it?
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.
I'd rather prefer having it as it will be used in the subsequent branch :)
import io.swagger.codegen.CodegenModel | ||
import io.swagger.codegen.CodegenProperty | ||
|
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.
This class is probably not needed at all and the same behavior can be achieved with an extension function:
fun CodegenModel.forEachVarAttribute(
action: (MutableList<CodegenProperty>) -> Unit
) {
listOf<MutableList<CodegenProperty>>(
this.allVars,
this.optionalVars,
this.parentVars,
this.readOnlyVars,
this.readWriteVars,
this.requiredVars,
this.vars).forEach { action(it) }
}
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.
The enums and stuff are mostly needed to ensure that we can have information on which list of variables we're working on.
This is something needed in the usages that will be proposed on the subsequent PR
@@ -256,6 +257,16 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig { | |||
} | |||
|
|||
handleXNullable(codegenModel) | |||
|
|||
// Update all enum properties datatypeWithEnum to use "BaseClass.InnerEnumClass" to reduce ambiguity |
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.
I'm having a hard time understanding the use case of this.
gradle-plugin/plugin/src/main/java/com/yelp/codegen/SharedCodegen.kt
Outdated
Show resolved
Hide resolved
@cortinico it will take me some time (maybe a few weeks) to provide changes on this PR.
The current branch that fully targets #103 is avaiblable on https://github.com/macisamuele/swagger-gradle-codegen/tree/maci-polymorphism . |
No problem, let's keep this opened for now. |
4fc3396
to
19ad9fe
Compare
Codecov Report
@@ Coverage Diff @@
## master #104 +/- ##
============================================
+ Coverage 70.83% 72.65% +1.81%
- Complexity 138 147 +9
============================================
Files 11 12 +1
Lines 576 607 +31
Branches 87 80 -7
============================================
+ Hits 408 441 +33
- Misses 118 122 +4
+ Partials 50 44 -6
Continue to review full report at Codecov.
|
19ad9fe
to
78ba5fb
Compare
… CodegenModel vars attributes
… before usage (to limit kotlin warnings)
78ba5fb
to
cdd09a3
Compare
This PR does some preparatory work for #103 .
In order to achieve polymorphism support we need to extract few functionalities from
KotlinGenerator
toSharedCodegen
.I totally understand that this PR seems disconnected and doesn't really explain why certain features are moved back to
SharedCodegen
or why we do even need to iterate over allCodegenModel.*vars
.In order to provide a better visibility I would suggest to check the potential draft of polymorphism on macisamuele/swagger-gradle-codegen@maci-polymmorphism