Skip to content

Commit

Permalink
changed generating of allOf to oneOf for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartłomiej Nowak committed Mar 4, 2024
1 parent b306289 commit 32de004
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 62 deletions.
7 changes: 1 addition & 6 deletions src/PropertyDescriber/ObjectPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ public function describe(array $types, OA\Schema $property, array $groups = null
if ($types[0]->isNullable()) {
$weakContext = Util::createWeakContext($property->_context);
$schemas = [new OA\Schema(['ref' => $this->modelRegistry->register(new Model($type, $groups, null, $context)), '_context' => $weakContext])];

if (function_exists('enum_exists') && enum_exists($type->getClassName())) {
$property->allOf = $schemas;
} else {
$property->oneOf = $schemas;
}
$property->oneOf = $schemas;

return;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Fixtures/Controller2209.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"nullableType": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down
48 changes: 24 additions & 24 deletions tests/Functional/Fixtures/MapQueryStringCleanupComponents.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -102,7 +102,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -157,7 +157,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -212,7 +212,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -267,7 +267,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -322,7 +322,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -377,7 +377,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -432,7 +432,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -489,7 +489,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -544,7 +544,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -599,7 +599,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -654,7 +654,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -709,7 +709,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -764,7 +764,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -819,7 +819,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -874,7 +874,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -1253,7 +1253,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -1308,7 +1308,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -1363,7 +1363,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -1418,7 +1418,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -1473,7 +1473,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -1528,7 +1528,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -1583,7 +1583,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down Expand Up @@ -1638,7 +1638,7 @@
"required": false,
"schema": {
"nullable": true,
"allOf": [
"oneOf": [
{
"$ref": "#/components/schemas/ArticleType81"
}
Expand Down

0 comments on commit 32de004

Please sign in to comment.