Skip to content

[php-nextgen] Add Flag to Allow Ignoring Operation Servers#24328

Open
ckoegel wants to merge 2 commits into
OpenAPITools:masterfrom
ckoegel:php-nextgen-op-servers
Open

[php-nextgen] Add Flag to Allow Ignoring Operation Servers#24328
ckoegel wants to merge 2 commits into
OpenAPITools:masterfrom
ckoegel:php-nextgen-op-servers

Conversation

@ckoegel

@ckoegel ckoegel commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This PR adds a flag to the configuration object to allow for ignoring operation servers. Currently, if operation level host objects are defined, there is no way to ignore these or use a different base path at the SDK level, which many other languages support. The new ignoreOperationHosts flag allows the user to ignore any operation hosts defined and instead use the currently defined $host. This will default to the top level base path defined in the OpenAPI file, but can be configured to be any url by using setIgnoreOperationHosts.

2 things to note:

  1. I used hosts terminology instead of servers since this SDK refers to them as hosts already, this means the flag name deviates slightly from other languages, but is consistent with how the rest of the Config refers to this value. It'd be super simple to switch to servers if we value cross language consistency more. Let me know and I'll update that.
  2. I originally planned to use a ternary when setting $operationHost to do the flag check inline, but decided to guard the entire block to avoid the potential for an invalid $hostIndex error if the config was just going to ignore it anyway. I can do it inline if we want to be as minimally invasive as possible. Also open to making that change, again lmk.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), @ybelenko (2018/07), @renepardon (2018/12)


Summary by cubic

Adds a new ignoreOperationHosts config flag to the PHP next-gen SDK so clients can skip operation-level hosts and always use the configured $host. Updates templates and samples; default behavior is unchanged.

  • New Features
    • Added ignoreOperationHosts (default false) with setIgnoreOperationHosts(bool) and getIgnoreOperationHosts() in Configuration.
    • API templates now use $config->getHost() for $operationHost when the flag is true; otherwise, existing server indexing and validation are preserved.
    • Regenerated samples for echo and petstore to include the new config option.

Written for commit 7228d2e. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

1 issue found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/openapi-generator/src/main/resources/php-nextgen/Configuration.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/php-nextgen/Configuration.mustache:400">
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`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

*
* @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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant