[Polymorphism Prep] Expose private KotlinGenerator methods in SharedCodegen#104
[Polymorphism Prep] Expose private KotlinGenerator methods in SharedCodegen#104macisamuele wants to merge 6 commits intoYelp:masterfrom
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 |
cortinico
left a comment
There was a problem hiding this comment.
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 👍
| */ | ||
| fun forEachVarAttribute( | ||
| codegenModel: CodegenModel, | ||
| action: (CodegenModelVar, MutableList<CodegenProperty>) -> Unit |
There was a problem hiding this comment.
Seems like the CodegenModelVar here is unused. Can you please remove it?
There was a problem hiding this comment.
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.
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.
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
|
|
||
| handleXNullable(codegenModel) | ||
|
|
||
| // Update all enum properties datatypeWithEnum to use "BaseClass.InnerEnumClass" to reduce ambiguity |
There was a problem hiding this comment.
I'm having a hard time understanding the use case of this.
|
@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
KotlinGeneratortoSharedCodegen.I totally understand that this PR seems disconnected and doesn't really explain why certain features are moved back to
SharedCodegenor 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