Skip to content

[Task]: OpenAPI Spec: Duplicate Model Name Conflict #1371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lukehinds opened this issue Apr 27, 2025 · 4 comments
Open

[Task]: OpenAPI Spec: Duplicate Model Name Conflict #1371

lukehinds opened this issue Apr 27, 2025 · 4 comments

Comments

@lukehinds
Copy link
Contributor

Description

I encountered an issue while trying to generate a client library from the api/openapi.json specification using the openapi-python-client tool (and likely other OpenAPI generators).

Problem:

The generator fails because it attempts to create duplicate model names. This seems to stem from the naming convention where schemas exist both with and without an -Output suffix, but normalize to the same name during generation.

Specifically, the following pairs cause conflicts:

  • #/components/schemas/FullWorkspace and #/components/schemas/FullWorkspace-Output both seem to normalize to FullWorkspace.
  • #/components/schemas/WorkspaceConfig and #/components/schemas/WorkspaceConfig-Output both seem to normalize to WorkspaceConfig.

Impact:
This naming collision prevents the generator from creating the necessary models, resulting in warnings and errors like:

WARNING parsing POST /api/v1/workspaces within code_gate_api.
Cannot parse response for status code 201 (Could not find reference in parsed models or enums), response will be omitted from generated client
Reference(ref='#/components/schemas/FullWorkspace-Output')
...
Unable to parse schema /components/schemas/FullWorkspace-Output
Unable to parse this part of your OpenAPI document: : Attempted to generate duplicate models with name "FullWorkspace"
...
Unable to parse schema /components/schemas/WorkspaceConfig-Output
Unable to parse this part of your OpenAPI document: : Attempted to generate duplicate models with name "WorkspaceConfig"

This makes it difficult to reliably generate clients that cover all workspace-related endpoints.

Suggested Solution:
Consider renaming the schemas with the -Output suffix to something distinct that won't clash after normalization. For example:

  • FullWorkspace-Output -> FullWorkspaceOutput
  • WorkspaceConfig-Output -> WorkspaceConfigOutput

Ensure all $ref pointers throughout the openapi.json file are updated accordingly.

This change would improve the spec's compatibility with standard OpenAPI tooling and make client generation more robust

Additional Context

No response

@lukehinds lukehinds changed the title [Task]: OpenAPI Spec: Duplicate Model Name Conflict (FullWorkspace/FullWorkspace-Output, WorkspaceConfig/WorkspaceConfig-Output) [Task]: OpenAPI Spec: Duplicate Model Name Conflict Apr 27, 2025
@lukehinds
Copy link
Contributor Author

@peppescg / @alex-mcgovern would this need patching in codegate-ui (generate post a PR merging to fix the above)?

@peppescg
Copy link
Contributor

@peppescg / @alex-mcgovern would this need patching in codegate-ui (generate post a PR merging to fix the above)?

Yep, once we merge this fix we need to update the openapi.json in the UI( we have a script that do it automatically ), and generate all the ts interfaces and endpoint wrappers

@peppescg
Copy link
Contributor

peppescg commented Apr 27, 2025

@lukehinds free feel to assign to me I can handle both BE and FE

lukehinds added a commit that referenced this issue Apr 27, 2025
Renamed schemas ending with '-Input' and '-Output' (e.g., FullWorkspace-Input, WorkspaceConfig-Output) to avoid duplicate model name errors during client generation (e.g., FullWorkspaceInput, WorkspaceConfigOutput).

Updated all corresponding $ref references within the OpenAPI specification. This resolves warnings and errors encountered when running `make generate-client`.

Resolves: #1371
@lukehinds
Copy link
Contributor Author

@peppescg sorry I just seen your message, I pushed f41b68b

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

No branches or pull requests

2 participants