Skip to content

Commit 5675d5f

Browse files
authored
Fix bug when variables key doesn't exist (#7429)
1 parent 80bef2f commit 5675d5f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

modules/openapi-generator/src/main/resources/php/Configuration.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ class Configuration
482482
$url = $host["url"];
483483

484484
// go through variable and assign a value
485-
foreach ($host["variables"] as $name => $variable) {
485+
foreach ($host["variables"] ?? [] as $name => $variable) {
486486
if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user
487487
if (in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum
488488
$url = str_replace("{".$name."}", $variables[$name], $url);

samples/client/petstore/php/OpenAPIClient-php/lib/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ public function getHostFromSettings($index, $variables = null)
499499
$url = $host["url"];
500500

501501
// go through variable and assign a value
502-
foreach ($host["variables"] as $name => $variable) {
502+
foreach ($host["variables"] ?? [] as $name => $variable) {
503503
if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user
504504
if (in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum
505505
$url = str_replace("{".$name."}", $variables[$name], $url);

0 commit comments

Comments
 (0)