Repository navigation
Commit bb7c33b
fix: keep allOf members that have properties alongside a validation keyword (#24551)
A schema carrying `properties` but omitting `type: object`, next to a
validation keyword, was classified as "validation without a type" and
silently dropped from allOf. Every model inheriting it lost those
properties -- no error, no warning, just a smaller model and a broken JSON
contract:
Parent:
minProperties: 2 # validation keyword, no `type: object`
properties:
alpha: { type: string }
beta: { type: string }
Child:
allOf: [{ $ref: '#/components/schemas/Parent' }]
properties:
gamma: { type: string }
// before: Child has only `gamma`
// after: Child has `alpha`, `beta`, `gamma`
OpenAPINormalizer.removeUnsupportedSchemasFromAllOf() drops any allOf
member for which ModelUtils.isUnsupportedSchema() returns true, and that
check was:
schema.getTypes() == null && hasValidation(schema)
Omitting `type: object` next to `properties` is very common in 3.0 specs,
and getTypes() is only populated for 3.1, so in practice any 3.0 schema
with a validation keyword and no explicit type was judged unsupported --
including ones that are plainly models.
Require that the schema also has no properties (and check getType() as
well, so the 3.0 case is recognised at all). A schema with properties is a
model, not bare validation.
Regenerating all 787 sample configs produces no diff.
Co-authored-by: Kejia Liu <kejia@yaocheng.cn>1 parent b20cbb0 commit bb7c33b
3 files changed
Lines changed: 78 additions & 1 deletion
File tree
- modules/openapi-generator/src
- main/java/org/openapitools/codegen/utils
- test
- java/org/openapitools/codegen
- resources/3_0
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2739 | 2739 | | |
2740 | 2740 | | |
2741 | 2741 | | |
2742 | | - | |
| 2742 | + | |
| 2743 | + | |
2743 | 2744 | | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
2744 | 2754 | | |
2745 | 2755 | | |
2746 | 2756 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
52 | 87 | | |
53 | 88 | | |
54 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
0 commit comments