Do not use cached entities in code generation#403
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #403 +/- ##
==========================================
- Coverage 19.15% 19.11% -0.04%
==========================================
Files 82 82
Lines 8683 8679 -4
==========================================
- Hits 1663 1659 -4
Misses 6874 6874
Partials 146 146
☔ View full report in Codecov by Sentry. |
pietern
left a comment
There was a problem hiding this comment.
For my info, where are these entities modified after being returned?
|
@pietern as an example, for It happens that When we process Thus, when |
|
this PR breaks SDK generation with path parameters |
This reverts commit 0af0ffc, otherwise, we miss the path parameters in the requests and break all SDKs 
Changes
Code generator stores the defined types (entities) in
pkg.typesfield. This field is primarily used for keeping the list of all observed types while generating code.But if we use the entity stored in this map and modify it in-place, for example, add that some field is required, it will change the entity stored.
If later one we use this "cached" version of entity, it will contain modified configuration which can lead to unexpected results, for example,
Userentity inUsers.createoperation will haveIDfield as required even though based on OpenAPI definition it is not.Thus, it's better not to use cached entities.
Tests
make testpassingmake fmtapplied