You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG][csharp][generichost] api_test generates wrong per-parameter model type for un-merged sibling inline enums (CS1503) #24112
Have you provided a full/minimal spec to reproduce the issue?
Have you validated the input using an OpenAPI validator?
Have you tested with the latest master to confirm the issue still exists?
Description
For the csharp generichost library, when two operation parameters reference distinct inline enum models, the generated API (FakeApi.cs) types each parameter with its own model, but the generated test (FakeApiTests.cs) declares all of them with the first (form) model. This produces a CS1503 compile error.
This stays hidden as long as the sibling inline enums are merged into a single model (the current default for the fake-endpoints spec). It surfaces the moment they are emitted as separate models.
openapi-generator version
master (reproduced on builds for #24007 / #23978, which stop merging description-only-different / same-valued sibling inline schemas)
Steps to reproduce
On a build where sibling inline enums are no longer merged, regenerate bin/configs/csharp-generichost-net8-formModels.yaml.
FakeApiTests.cs(226): error CS1503: Argument 3: cannot convert from
'Option<TestEnumParametersRequestEnumFormString>' to
'Option<TestEnumParametersEnumHeaderStringParameter>'
Suggested area
modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api_test.mustache renders params via {{#allParams}}{{>OperationDataType}} — the same construct api.mustache uses — yet the resolved dataType differs between the two outputs for these params. Root cause likely in how the per-parameter dataType is populated for the test context.
Correction: this issue is mis-framed as a csharp generichost template bug. CI demonstrates that api_test.mustache emits the correct, self-consistent output (EnumHeaderStringParameter, matching the FakeApi signature), so the templates are not at fault.
The real, narrower problem: the generated test parameter types for testEnumParameters are environment-dependent. In some environments (e.g. my macOS setup) the api_test generation path resolves enumHeaderString/enumQueryString to RequestEnumFormString — inconsistent with the API signature and uncompilable — while CI resolves them consistently to EnumHeaderStringParameter. It reproduces stably within an environment (so it is not run-to-run nondeterminism), and the variable is not isolated: not JDK (11 vs 25 identical), not locale; a Docker check was confounded by host-filesystem mounting.
Most useful clue: within a single generation run, FakeApi.cs and FakeApiTests.cs disagree on the same parameter's model type, and FakeApi.cs is stable across environments. So the order/environment sensitivity is specific to the api_test generation path, not global inline-model naming.
This surfaced via #24007 / #24009 (which stop merging description-only-different / same-valued sibling inline enums); both PRs are now green after committing the CI-consistent samples. If maintainers prefer, this issue can be closed and tracked within those PRs, or kept open to fix the underlying environment-dependent test-type resolution.
@devhl-labs Sorry for the slow reply, and thanks for the triage.
To answer your question directly: it's a compile issue, not incorrect HTTP messages. Within a single generation run, FakeApiTests.cs declares the parameter as RequestEnumFormString while FakeApi.cs declares the same parameter as EnumHeaderStringParameter, so the generated test file does not compile against the API it is testing.
On the minified yaml — that's the part I can't deliver, and it's why I'm closing this rather than leaving it open. The trigger isn't a spec of mine: it reproduces with this repository's own generichost sample generation (the FakeApi spec already in the tree). What varies is the environment, not the input — the same spec at the same commit produces the consistent EnumHeaderStringParameter output on CI and the inconsistent one in my local macOS setup, stably in each. I ruled out JDK version (11 vs 25 identical) and locale, and a Docker comparison was confounded by host-filesystem mounting, so I never isolated the variable. A minified yaml wouldn't carry the difference that actually causes this.
Two further reasons this issue is no longer the right container for the problem:
As I noted above, it is mis-framed. The title blames the csharp generichost templates, but api_test.mustache emits correct, self-consistent output — the templates are not at fault. The fault is in the api_test type-resolution path.
So I'm closing it as not actionable in its current form. If FakeApi.cs and FakeApiTests.cs disagree again on current master, I'll open a fresh issue describing the full generation environment rather than a spec excerpt — that's where the reproducer actually lives.
Activity
seonwooj0810 commentedon Jun 24, 2026
Correction: this issue is mis-framed as a csharp generichost template bug. CI demonstrates that
api_test.mustacheemits the correct, self-consistent output (EnumHeaderStringParameter, matching theFakeApisignature), so the templates are not at fault.The real, narrower problem: the generated test parameter types for
testEnumParametersare environment-dependent. In some environments (e.g. my macOS setup) the api_test generation path resolvesenumHeaderString/enumQueryStringtoRequestEnumFormString— inconsistent with the API signature and uncompilable — while CI resolves them consistently toEnumHeaderStringParameter. It reproduces stably within an environment (so it is not run-to-run nondeterminism), and the variable is not isolated: not JDK (11 vs 25 identical), not locale; a Docker check was confounded by host-filesystem mounting.Most useful clue: within a single generation run,
FakeApi.csandFakeApiTests.csdisagree on the same parameter's model type, andFakeApi.csis stable across environments. So the order/environment sensitivity is specific to the api_test generation path, not global inline-model naming.This surfaced via #24007 / #24009 (which stop merging description-only-different / same-valued sibling inline enums); both PRs are now green after committing the CI-consistent samples. If maintainers prefer, this issue can be closed and tracked within those PRs, or kept open to fix the underlying environment-dependent test-type resolution.
devhl-labs commentedon Jun 27, 2026
Is this a compile issue, or incorrect http messages? Please provide a minified yaml where you see the problem.
seonwooj0810 commentedon Sep 1, 2026
@devhl-labs Sorry for the slow reply, and thanks for the triage.
To answer your question directly: it's a compile issue, not incorrect HTTP messages. Within a single generation run,
FakeApiTests.csdeclares the parameter asRequestEnumFormStringwhileFakeApi.csdeclares the same parameter asEnumHeaderStringParameter, so the generated test file does not compile against the API it is testing.On the minified yaml — that's the part I can't deliver, and it's why I'm closing this rather than leaving it open. The trigger isn't a spec of mine: it reproduces with this repository's own generichost sample generation (the
FakeApispec already in the tree). What varies is the environment, not the input — the same spec at the same commit produces the consistentEnumHeaderStringParameteroutput on CI and the inconsistent one in my local macOS setup, stably in each. I ruled out JDK version (11 vs 25 identical) and locale, and a Docker comparison was confounded by host-filesystem mounting, so I never isolated the variable. A minified yaml wouldn't carry the difference that actually causes this.Two further reasons this issue is no longer the right container for the problem:
api_test.mustacheemits correct, self-consistent output — the templates are not at fault. The fault is in the api_test type-resolution path.So I'm closing it as not actionable in its current form. If
FakeApi.csandFakeApiTests.csdisagree again on current master, I'll open a fresh issue describing the full generation environment rather than a spec excerpt — that's where the reproducer actually lives.