fix: merge allOf, properties, and additionalProperties#464
fix: merge allOf, properties, and additionalProperties#464agnesesterhuizen wants to merge 2 commits intoomissis:mainfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #464 +/- ##
=======================================
Coverage ? 41.78%
=======================================
Files ? 62
Lines ? 6615
Branches ? 0
=======================================
Hits ? 2764
Misses ? 3576
Partials ? 275 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
fyi @agnesesterhuizen I'm not a maintainer, but also have this issue and solved this in slightly similar way in #465. That MR also supports the |
Hey @perher! apologies for the slow response here. I'm happy to close this PR in favour of #473 which should solve my issue. |
Issue
When
allOfwas used in combination with directpropertiesandadditionalProperties, the code generator would only process theallOfreferences but ignore any properties or additionalProperties defined directly on the same schema object.schema:
{ "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { "BaseObject": { "type": "object", "properties": { "BaseField": { "type": "string" } }, "required": ["BaseField"] }, "ComposedObject": { "allOf": [ { "$ref": "#/definitions/BaseObject" } ], "type": "object", "additionalProperties": true, "properties": { "MissingField": { "type": "array", "items": { "type": "string" }, "uniqueItems": true } } } } }current output:
The
MissingFieldproperty andadditionalPropertieswere ignored.Fix
The fix adds logic to merge
allOfschemas with any direct properties and additionalProperties before generating the struct so all fields from both sources are included.fixed output:
The generated struct now includes:
allOfreferences (BaseFieldfromBaseObject)MissingField)AdditionalPropertiesfield)