Skip to content

Commit

Permalink
Fix the generated code for enum-based map keys for json services (#1602)
Browse files Browse the repository at this point in the history
* Fix the generated code for enum-based map keys for json services

* Fix the changelog test for changes in the CodeGenerator

The CodeGenerator package does not have a changelog as it has no
releases.
  • Loading branch information
stof authored Nov 10, 2023
1 parent bcf7d61 commit 299375f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Generator/RequestSerializer/RestJsonSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ private function dumpArrayMap(string $output, string $input, string $contextProp
$mapKeyShape = $shape->getKey()->getShape();
if (!empty($mapKeyShape->getEnum())) {
$enumClassName = $this->namespaceRegistry->getEnum($mapKeyShape);
$validateEnum = strtr('if (!ENUM_CLASS::exists($mapKey)) {
throw new InvalidArgument(sprintf(\'Invalid key for "%s". The value "%s" is not a valid "ENUM_CLASS".\', __CLASS__, $mapKey));
$validateEnum = strtr('if (!ENUM_CLASS::exists($name)) {
throw new InvalidArgument(sprintf(\'Invalid key for "%s". The value "%s" is not a valid "ENUM_CLASS".\', __CLASS__, $name));
}', [
'ENUM_CLASS' => $enumClassName->getName(),
]);
Expand Down

0 comments on commit 299375f

Please sign in to comment.