OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Go] name collision

Open
#16,844 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Looks like the configuration.go file is exporting severals types that may conflict / collide with names in the API specs. Example: APIKey, Configuration, ServerConfigurations, etc...

openapi-generator version

v7.0.1

OpenAPI declaration file content or url
openapi: 3.0.2
info:
  title: Test API
  version: '0.0'
  contact:
    name: Curvegrid
  description: Test API.
servers:
  - url: 'https://localhost:8080'
tags:
  - name: tests
paths:
  /bug:
    get:
      operationId: test-bug
      summary: Test bug
      description: A test endpoint.
      tags:
        - tests
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIKey'
components:
  schemas:
    APIKey:
      title: APIKey
      type: object
      description: An APIKey.
      properties:
        label:
          type: string
      required:
        - label
Generation Details
Steps to reproduce

Generate the code and check if the code is valid / contain types with the same name.

Related issues/PRs
Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by generating the Go client from the YAML example and inspect the generated configuration.go, especially the exported types named in the report. Confirm the APIKey schema collides with generated names, then verify that the generated code remains valid without same-name types.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.