Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ class Configuration
*/
protected string $tempFolderPath;

/**
* Ignore operation specific hosts
*
* @var bool
*/
protected bool $ignoreOperationHosts = false;

/**
* Constructor
*/
Expand Down Expand Up @@ -383,6 +390,29 @@ class Configuration
return $this->tempFolderPath;
}

/**
* Sets the ignore operation specific hosts flag
*
* @param bool $ignoreOperationHosts Ignore operation specific hosts flag
*
* @return $this
*/
public function setIgnoreOperationHosts(bool $ignoreOperationHosts): static

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new host-selection opt-in has no regression test. Add generated-client coverage for both flag values using distinct operation- and top-level hosts, including an ignored invalid operation hostIndex.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/php-nextgen/Configuration.mustache, line 400:

<comment>The new host-selection opt-in has no regression test. Add generated-client coverage for both flag values using distinct operation- and top-level hosts, including an ignored invalid operation `hostIndex`.</comment>

<file context>
@@ -383,6 +390,29 @@ class Configuration
+     *
+     * @return $this
+     */
+    public function setIgnoreOperationHosts(bool $ignoreOperationHosts): static
+    {
+        $this->ignoreOperationHosts = $ignoreOperationHosts;
</file context>

{
$this->ignoreOperationHosts = $ignoreOperationHosts;
return $this;
}

/**
* Gets the ignore operation specific hosts flag
*
* @return bool Ignore operation specific hosts flag
*/
public function getIgnoreOperationHosts(): bool
{
return $this->ignoreOperationHosts;
}

/**
* Gets the default configuration instance
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -842,17 +842,21 @@ use {{invokerPackage}}\ObjectSerializer;
);

{{#servers.0}}
# Preserve the original behavior of server indexing.
if ($hostIndex === null) {
$hostIndex = $this->hostIndex;
}
if ($this->config->getIgnoreOperationHosts()) {
$operationHost = $this->config->getHost();
} else {
# Preserve the original behavior of server indexing.
if ($hostIndex === null) {
$hostIndex = $this->hostIndex;
}

$hostSettings = $this->getHostSettingsFor{{operationId}}();
$hostSettings = $this->getHostSettingsFor{{operationId}}();

if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) {
throw new InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than ".count($hostSettings));
if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) {
throw new InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than ".count($hostSettings));
}
$operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables);
}
$operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables);
{{/servers.0}}
{{^servers.0}}
$operationHost = $this->config->getHost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ class Configuration
*/
protected string $tempFolderPath;

/**
* Ignore operation specific hosts
*
* @var bool
*/
protected bool $ignoreOperationHosts = false;

/**
* Constructor
*/
Expand Down Expand Up @@ -392,6 +399,29 @@ public function getTempFolderPath(): string
return $this->tempFolderPath;
}

/**
* Sets the ignore operation specific hosts flag
*
* @param bool $ignoreOperationHosts Ignore operation specific hosts flag
*
* @return $this
*/
public function setIgnoreOperationHosts(bool $ignoreOperationHosts): static
{
$this->ignoreOperationHosts = $ignoreOperationHosts;
return $this;
}

/**
* Gets the ignore operation specific hosts flag
*
* @return bool Ignore operation specific hosts flag
*/
public function getIgnoreOperationHosts(): bool
{
return $this->ignoreOperationHosts;
}

/**
* Gets the default configuration instance
*
Expand Down
30 changes: 30 additions & 0 deletions samples/client/echo_api/php-nextgen/src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ class Configuration
*/
protected string $tempFolderPath;

/**
* Ignore operation specific hosts
*
* @var bool
*/
protected bool $ignoreOperationHosts = false;

/**
* Constructor
*/
Expand Down Expand Up @@ -392,6 +399,29 @@ public function getTempFolderPath(): string
return $this->tempFolderPath;
}

/**
* Sets the ignore operation specific hosts flag
*
* @param bool $ignoreOperationHosts Ignore operation specific hosts flag
*
* @return $this
*/
public function setIgnoreOperationHosts(bool $ignoreOperationHosts): static
{
$this->ignoreOperationHosts = $ignoreOperationHosts;
return $this;
}

/**
* Gets the ignore operation specific hosts flag
*
* @return bool Ignore operation specific hosts flag
*/
public function getIgnoreOperationHosts(): bool
{
return $this->ignoreOperationHosts;
}

/**
* Gets the default configuration instance
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,17 +477,21 @@ public function addPetRequest(
$headers
);

# Preserve the original behavior of server indexing.
if ($hostIndex === null) {
$hostIndex = $this->hostIndex;
}
if ($this->config->getIgnoreOperationHosts()) {
$operationHost = $this->config->getHost();
} else {
# Preserve the original behavior of server indexing.
if ($hostIndex === null) {
$hostIndex = $this->hostIndex;
}

$hostSettings = $this->getHostSettingsForaddPet();
$hostSettings = $this->getHostSettingsForaddPet();

if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) {
throw new InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than ".count($hostSettings));
if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) {
throw new InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than ".count($hostSettings));
}
$operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables);
}
$operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables);
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
Expand Down Expand Up @@ -1870,17 +1874,21 @@ public function updatePetRequest(
$headers
);

# Preserve the original behavior of server indexing.
if ($hostIndex === null) {
$hostIndex = $this->hostIndex;
}
if ($this->config->getIgnoreOperationHosts()) {
$operationHost = $this->config->getHost();
} else {
# Preserve the original behavior of server indexing.
if ($hostIndex === null) {
$hostIndex = $this->hostIndex;
}

$hostSettings = $this->getHostSettingsForupdatePet();
$hostSettings = $this->getHostSettingsForupdatePet();

if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) {
throw new InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than ".count($hostSettings));
if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) {
throw new InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than ".count($hostSettings));
}
$operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables);
}
$operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables);
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'PUT',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ class Configuration
*/
protected string $tempFolderPath;

/**
* Ignore operation specific hosts
*
* @var bool
*/
protected bool $ignoreOperationHosts = false;

/**
* Constructor
*/
Expand Down Expand Up @@ -391,6 +398,29 @@ public function getTempFolderPath(): string
return $this->tempFolderPath;
}

/**
* Sets the ignore operation specific hosts flag
*
* @param bool $ignoreOperationHosts Ignore operation specific hosts flag
*
* @return $this
*/
public function setIgnoreOperationHosts(bool $ignoreOperationHosts): static
{
$this->ignoreOperationHosts = $ignoreOperationHosts;
return $this;
}

/**
* Gets the ignore operation specific hosts flag
*
* @return bool Ignore operation specific hosts flag
*/
public function getIgnoreOperationHosts(): bool
{
return $this->ignoreOperationHosts;
}

/**
* Gets the default configuration instance
*
Expand Down
Loading