-
Notifications
You must be signed in to change notification settings - Fork 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
[Swift3] decoders call parents decoders to fix issue with class inheritance #5369
[Swift3] decoders call parents decoders to fix issue with class inheritance #5369
Conversation
@julienfouilhe thanks for the PR. |
@julienfouilhe could you regenerate the sample files and put in here as well? I wanted to see what the output looks like now... |
@jaz-ah, it should be in the commit. Most of it is in Models.swift, and the diff is not displayed on github unless you click because it's too large. :) Edit: Oh, you mean those other files in the samples. Give me a few secs |
@julienfouilhe ah I meant the actual sample output -i.e. the sample/test project checked into the tree... |
@jaz-ah I ran |
@julienfouilhe I must have missed it - I see it now - looks good - thx! +1 @wing328 |
@jaz-ah Yes I just ran them and amended my commit. ;) I don't think there's a test for that though. If you want to see where the bug is, you would need to add an endpoint to the Petstore API |
@julienfouilhe thanks for the PR. @jaz-ah thanks for reviewing the change. |
I am double checking but the changes in this PR have broken my swagger generated code . This line in the template
generates the following code for classes in the Models.swift file :
As a result the decode function is looking for a class decoder named "String". NB The classes this fails on do use AdditionalProperties (which @danwoodel and I are currently fixing)…and I think this might be the issue as the current implementation of AdditionalProperties handling in the Swift3 codegen is completely broken in that it tries to make the class a subclass of a string collection. This I would guess is what is causing the {{parent}} to mistakenly return it the type as String. Comments/thoughts anyone? |
I think it might be a good idea to add some models in the PetStore example with some additional properties. |
We should check if Done in #5416 |
We do have that in petstore-with-fake-endpoints-models-for-testing.yaml, which covers a lot more edge cases. Currently, the Swift Petstore is using petstore.yaml (the basic one) and I'll create a task to track updating Swift Petstore to use petstore-with-fake-endpoints-models-for-testing.yaml |
Created #5419 for tracking |
@dwoodel actually swift3 petstore is already using the fake petstore. Please feel free to submit a PR to add additional test cases to fake petstore so as to cover more edge cases. |
@julienfouilhe when you've time I wonder if you can make the same change against 2.3.0 branch instead as I got merge conflict when syncing the changes from master to 2.3.0. Thanks! |
@wing328 Done! |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)2.3.0
branch for breaking (non-backward compatible) changes.Description of the PR
I was having problems with classes inheriting from other classes, fields defined in parent classes were
nil
. I fixed it by calling the parent's decoder in the child's decoder and passing the child's instance.