Skip to content

Commit 2498006

Browse files
committed
fix(openapi): correct example usage for 3.0
In OpenApi 3.0 in component schema properties only `example` is allowed. Hence we convert examples to example.
1 parent 8de9bf8 commit 2498006

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/OpenApi/Serializer/LegacyOpenApiNormalizer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public function normalize(mixed $object, ?string $format = null, array $context
4545
}
4646
unset($schemas[$name]['properties'][$property]['type']);
4747
}
48+
49+
if (\is_array($value['examples'] ?? false)) {
50+
$schemas[$name]['properties'][$property]['example'] = $value['examples'];
51+
unset($schemas[$name]['properties'][$property]['examples']);
52+
}
4853
}
4954
}
5055

0 commit comments

Comments
 (0)