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
Models are now typed as Object when properties of another Model #79
Comments
Sorry for the issue and thank you a lot for the analysis. This probably affects more generators than just Kotlin and need to be fixed. I wrote in PR #45 that the code was not as nice as it could be, but my intention is to keep the feature. I will fix it ASAP. PS: I am sorry you lost so much time with the analysis. I have opened #80 to discuss possible solutions. |
I have seen the change, by running the generator before and after my commit...
For the moment I do not understand where the type is changed.
(the test as no real value because it is the same check than I will continue my investigations. |
Thanks for the great analysis, @jimschubert ! |
@jmini If you can't track it down, I'll be happy to help when I next have a chance. I enjoy a good bug hunt. Also, I didn't feel like I lost time sure to my analysis, only in my silly mistake to check the wrong file. Rather that running bisect and finding the source in 10-15 min, it took me around an hour to run, go "That's not right", run again twice with modifications, then find my error and run successfully once more. |
I have found why the test and the real run are different: The call in the test (all most all tests):
Should be:
Then I have also the problem in the UT. I will bring a solution, but this requires some work to do it correctly. We need to propagate the openAPI instance in multiple locations, so this requires some work. Do you want me to revert the changes of #45, so that the broken stuff is fixed again? |
I can confirm that python-* is also affected. Thanks for fixing it.
|
Fixed by merge of #82 |
@jmini That's some excellent sleuthing Looks like we need a way to standardize the inputs, so the fromModel with two parameters is deprecated or removed? I haven't looked recently, but from memory I don't think there's a way to get the allDefinitions when not provided... so it'll probably take a little refactoring. |
@jimschubert: I have just pushed #90 as a first step. |
Description
This was asked in chat, and I've done some evaluation to determine what's going on. Models which are properties of other models are now considered
Object
rather than the property type.Apparently, our petstore example for many generated samples only nest models once (
Category
underPet#category
). This bug appears to happen for any nested models. Nested enums and arrays of types are unaffected.openapi-generator version
master (752b36e)
OpenAPI declaration file content or url
n/a
Command line used for generation
Any generator under
./bin
with nested modelsSteps to reproduce
mvn clean package install
./bin/kotlin-client-petstore.sh
cat samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Pet.kt
Notice that category is now
kotlin.Any?
rather thanCategory
as it was previously.Related issues/PRs
Suggest a fix/enhancement
Nothing substantial to suggest. Maybe copying non-empty properties to the new schema rather than replacing the reference?
@jmini you commented in the PR that the fix is temporary. However, I consider the issue a significant one.
It looks like this block is the bug:
I haven't stepped through the code to verify, but it seems to me that this would be falling back to
Object
where it shouldn't be. I saw that you opened a bug with swagger-parser for the json-schema properties that don't get exposed as expected. I think that parser bug is unrelated to this bug.For reference, I tracked this down via git bisect using:
Would you mind giving this a quick look? I had planned to get into a fix, but I wasted a big of time with my evaluation script (running kotlin-client generator, then checking kotlin-server output produced only HEAD as the bad commit).
The text was updated successfully, but these errors were encountered: