Stackoverflow in toExampleValue() for python client#8054
Stackoverflow in toExampleValue() for python client#8054spacether merged 1 commit intoOpenAPITools:masterfrom
Conversation
|
Hey there. Thanks for your PR. Yup adding a new parameter is the cleanest way to handle it. |
spacether
left a comment
There was a problem hiding this comment.
please regenerate the samples to eliminate the CI error
| return fullPrefix + modelName + closeChars; | ||
| } else if(modelName != null && !modelName.isEmpty()){ | ||
| // if the model is non-null and non-empty, add it to the set | ||
| processedModels.add(modelName); |
There was a problem hiding this comment.
Shouldn't we only add a model when we have finished generating its sample?
What are our recursive base cases here for cycles?
How about naming them seenModels because we have not finished processing it yet.
There was a problem hiding this comment.
I'll go back and take a look at this again, thanks. I didn't realize that the 'ran /bin/utils/ensure-up-to-date' was required and didn't pick up on the fact that my examples had changed that.
There was a problem hiding this comment.
@spacether Got a CircleCI build error that I'm having a hard time interpreting. Do you mind taking a look and providing pointers for how to reproduce locally?
There was a problem hiding this comment.
That error is unrelated. We. can ignore it.
cacc4d6 to
47da5e5
Compare
|
@spacether We took another crack at the toExampleValueRecursive() issue. |
There was a problem hiding this comment.
null is invalid in Python. Can you update this value? If the list is not explicitly nullable, then the example value should be [] (empty list). If it is nullable, then the example value can be None.
spacether
left a comment
There was a problem hiding this comment.
Thank you for making these changes. It is almost there!
Your tests sample includes null which is not valid python code.
Can you update the string null to be the string None?
47da5e5 to
0cd251d
Compare
|
Hi @spacether, We have updated the example value to be None in the recursive case. |
There was a problem hiding this comment.
Thank you for making that update. So looking at your spec None is not a valid value for geometries because geometries is type array and that array is not Nullable. Sorry for asking for None here earlier. Please change the empty value to be empty list for your output example. The only valid values for geometries as defined in your spec are:
- []
- [one or more GeoJsonGeometry]
|
When /i is passed in can we turn on case insensitive in RgxGen? If you don't want to do this now we can leave it to the future. |
0cd251d to
63ac823
Compare
|
We changed the default value for the recursive item to: |
Added a Set<String> in toExampleValueRecursive() to keep track of which models we have generated to avoid an infinite recursion for recursive models. An example of a recursive model would be a GeoJson GeometryCollection.
63ac823 to
3206b2b
Compare
|
Hello @spacether, I noticed that this PR had conflicts with the latest master. I went ahead and fixed the conflicts and pushed the latest. Let me know if you need any other changes. |
|
This PR broke master so I am reverting it. There is a java test failure that we missed |
|
@spacether everything passed on my side. Can you point me to the build log that failed? I'll figure it out. |
|
Thank you so much! Here is a log |
Added a Set to the toExampleValueRecursive() method to detect circular references.
Added a watered down GeoJson API that, prior to this commit, would have thrown a StackOverflowException
Added a unit test (testRecursiveToExample()) and expected output confirming that the fix works.
@spacether this solution may be a little heavy handed. I tried not to introduce another parameter to the toExampleValueRecursive(), but this seemed like the cleanest way to do it.
PR checklist
./bin/generate-samples.shto update all Petstore samples related to your fix. 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