From e67dfd938cacd1662e3eb6eeb9462b952569a48c Mon Sep 17 00:00:00 2001 From: rien-vroom-cquential <124083137+rien-vroom-cquential@users.noreply.github.com> Date: Thu, 26 Oct 2023 21:47:06 +0200 Subject: [PATCH] Allow recursive nesting of AdditionalProperties in Attributes (#1490) --- docs/reference/attributes.md | 2 ++ src/Attributes/AdditionalProperties.php | 3 +- .../Scratch/NestedAdditionalProperties.php | 30 +++++++++++++++++++ .../Scratch/NestedAdditionalProperties.yaml | 18 +++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/Fixtures/Scratch/NestedAdditionalProperties.php create mode 100644 tests/Fixtures/Scratch/NestedAdditionalProperties.yaml diff --git a/docs/reference/attributes.md b/docs/reference/attributes.md index c4ebcf0c2..292679b09 100644 --- a/docs/reference/attributes.md +++ b/docs/reference/attributes.md @@ -152,6 +152,8 @@ schema defined by this property's value.
An instance validates successfully against this property if it validates successfully against exactly one schema
defined by this property's value.
http://json-schema.org/latest/json-schema-validation.html#anchor64.
While the OpenAPI Specification tries to accommodate most use cases, additional data can be added to extend the specification at certain points.
For further details see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specificationExtensions
diff --git a/src/Attributes/AdditionalProperties.php b/src/Attributes/AdditionalProperties.php
index 6147238c2..ca0ab3f8d 100644
--- a/src/Attributes/AdditionalProperties.php
+++ b/src/Attributes/AdditionalProperties.php
@@ -61,6 +61,7 @@ public function __construct(
?array $allOf = null,
?array $anyOf = null,
?array $oneOf = null,
+ AdditionalProperties|bool|null $additionalProperties = null,
// annotation
?array $x = null,
?array $attachables = null
@@ -100,7 +101,7 @@ public function __construct(
'oneOf' => $oneOf ?? Generator::UNDEFINED,
'x' => $x ?? Generator::UNDEFINED,
'attachables' => $attachables ?? Generator::UNDEFINED,
- 'value' => $this->combine($items, $discriminator, $externalDocs, $attachables),
+ 'value' => $this->combine($items, $discriminator, $externalDocs, $additionalProperties, $attachables),
]);
}
}
diff --git a/tests/Fixtures/Scratch/NestedAdditionalProperties.php b/tests/Fixtures/Scratch/NestedAdditionalProperties.php
new file mode 100644
index 000000000..01eb62b1e
--- /dev/null
+++ b/tests/Fixtures/Scratch/NestedAdditionalProperties.php
@@ -0,0 +1,30 @@
+