Commit 8a3dd4d
authored
Assign to properties with explicit self in
### Motivation
Our generated `init(from decoder:)` assigns to properties without using
explicit self. This is a problem because it can produce conflicts with
the local variables created in the initializer, e.g. the decoding
container, which will then fail to compile for schemas with properties
named `container`, as found by an adopter in #695.
We should probably take a broader pass with regard to the use of
explicit self in our generated code, but for now we can resolve this by
focussing on this problematic generation, where a schema with named and
additional properties.
### Modifications
- Assign to properties with explicit self in `init(from decoder:)`
### Result
- Fixes #695.
### Test Plan
- Add a snippet test.
- Update the reference tests.init(from decoder:) (#696)1 parent 61ec6b6 commit 8a3dd4d
File tree
3 files changed
+22
-7
lines changed- Sources/_OpenAPIGeneratorCore/Translator/CommonTranslations
- Tests/OpenAPIGeneratorReferenceTests
- Resources/ReferenceSources/Petstore
3 files changed
+22
-7
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
597 | | - | |
| 597 | + | |
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
| |||
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
629 | | - | |
| 629 | + | |
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
669 | | - | |
| 669 | + | |
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
| |||
Lines changed: 18 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
514 | 516 | | |
515 | 517 | | |
516 | 518 | | |
517 | 519 | | |
518 | 520 | | |
519 | | - | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
520 | 528 | | |
521 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
522 | 537 | | |
523 | 538 | | |
524 | 539 | | |
| |||
0 commit comments