Skip to content

Commit 77648da

Browse files
authored
Fix the generated code for enum-based map keys for json services (#1602)
* 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.
1 parent 0a136cf commit 77648da

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/CodeGenerator/src/Generator/RequestSerializer/RestJsonSerializer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ private function dumpArrayMap(string $output, string $input, string $contextProp
227227
$mapKeyShape = $shape->getKey()->getShape();
228228
if (!empty($mapKeyShape->getEnum())) {
229229
$enumClassName = $this->namespaceRegistry->getEnum($mapKeyShape);
230-
$validateEnum = strtr('if (!ENUM_CLASS::exists($mapKey)) {
231-
throw new InvalidArgument(sprintf(\'Invalid key for "%s". The value "%s" is not a valid "ENUM_CLASS".\', __CLASS__, $mapKey));
230+
$validateEnum = strtr('if (!ENUM_CLASS::exists($name)) {
231+
throw new InvalidArgument(sprintf(\'Invalid key for "%s". The value "%s" is not a valid "ENUM_CLASS".\', __CLASS__, $name));
232232
}', [
233233
'ENUM_CLASS' => $enumClassName->getName(),
234234
]);

tests/Unit/ChangelogTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ static function ($branch) {
219219
} elseif ('Integration' === $parts[1]) {
220220
$service = $parts[2] . '/' . $parts[3];
221221
$base = 'src/Integration/' . $service;
222-
} elseif ('CodeGenerator' === $parts[1] || 'Core' === $parts[1]) {
222+
} elseif ('CodeGenerator' === $parts[1]) {
223+
continue; // The code generator does not have a changelog as it has no releases
224+
} elseif ('Core' === $parts[1]) {
223225
$service = $parts[1];
224226
$base = 'src/' . $service;
225227
} else {

0 commit comments

Comments
 (0)