Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/quicktype-core/src/rewrites/ResolveIntersections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ class IntersectionAccumulator
return;
}

// Named properties from intersected objects are combined. Whether
// additional properties are allowed only affects names not declared
// by any of those objects.
const allPropertyNames = setUnionInto(
new Set(this._objectProperties.keys()),
maybeObject.getProperties().keys(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"animal": {
"foo": "inherited property",
"bar": "inline property"
}
}
7 changes: 7 additions & 0 deletions test/inputs/schema/allof-closed-objects.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"animal": {
"foo": "inherited property",
"discriminator": "dog",
"bar": "inline property"
}
}
37 changes: 37 additions & 0 deletions test/inputs/schema/allof-closed-objects.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Container",
"type": "object",
"additionalProperties": false,
"properties": {
"animal": {
"oneOf": [
{ "$ref": "#/definitions/dog" },
{ "type": "null" }
]
}
},
"definitions": {
"dog": {
"allOf": [
{ "$ref": "#/definitions/animal" },
{
"type": "object",
"additionalProperties": false,
"properties": {
"bar": { "type": ["null", "string"] }
}
}
]
},
"animal": {
"type": "object",
"additionalProperties": false,
"required": ["discriminator"],
"properties": {
"foo": { "type": ["null", "string"] },
"discriminator": { "type": "string" }
}
}
}
}
7 changes: 7 additions & 0 deletions test/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ export const CJSONLanguage: Language = {
/* Required properties absent are not checked (for the current implementation, can be added later, should abord parsing and return NULL) */
"intersection.schema",
"required.schema",
"allof-closed-objects.schema",
// The default-value fail sample also relies on required-property
// enforcement, which cJSON does not do.
"default-value.schema",
Expand Down Expand Up @@ -1002,6 +1003,8 @@ export const SwiftLanguage: Language = {
// This works on macOS, but on Linux one of the failure test cases doesn't fail
...skipsUntypedUnions,
"required.schema",
// Same Linux-only missing-required behavior as required.schema.
"allof-closed-objects.schema",
// The default-value fail sample also relies on required-property enforcement.
"default-value.schema",
"multi-type-enum.schema",
Expand Down Expand Up @@ -1918,6 +1921,9 @@ export const HaskellLanguage: Language = {
"keyword-unions.schema",
"optional-any.schema",
"required.schema",
// Same undetectable expected-failure limitation as required.schema:
// a failed decode prints "null" and exits 0.
"allof-closed-objects.schema",
// The default-value fail sample also relies on required-property enforcement.
"default-value.schema",
"required-non-properties.schema",
Expand Down Expand Up @@ -2273,6 +2279,7 @@ export const ElixirLanguage: Language = {
// Struct keys cannot be enforced at runtime in Elixir and their values will just be set to null.
"strict-optional.schema",
"required.schema",
"allof-closed-objects.schema",
// The default-value fail sample also relies on required-property enforcement.
"default-value.schema",
"boolean-subschema.schema",
Expand Down
Loading