OpenAPITools / OpenAPITools/openapi-generator

[BUG][GO-GIN-SERVER] Conflict route

Open
#3,546 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Server: Go
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)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

Server can't start after generation

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /v2/                      --> pet-server/go.Index (3 handlers)
[GIN-debug] POST   /v2/pet                   --> pet-server/go.AddPet (3 handlers)
[GIN-debug] DELETE /v2/pet/:petId            --> pet-server/go.DeletePet (3 handlers)
[GIN-debug] GET    /v2/pet/findByStatus      --> pet-server/go.FindPetsByStatus (3 handlers)
[GIN-debug] GET    /v2/pet/findByTags        --> pet-server/go.FindPetsByTags (3 handlers)
[GIN-debug] GET    /v2/pet/:petId            --> pet-server/go.GetPetById (3 handlers)
panic: wildcard route ':petId' conflicts with existing children in path '/v2/pet/:petId'

openapi-generator version
➜  personal openapi-generator version
4.0.3
OpenAPI declaration file content or url
➜  personal wget https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml
Command line used for generation
➜  personal openapi-generator generate -i petstore.yaml -g go-gin-server -o pet-server
Steps to reproduce
docker build -t pet-server:local .
docker run --rm pet-server:local

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

Regenerate the server from petstore.yaml with the go-gin-server generator, then run the generated pet-server container to reproduce the conflicting routes. Inspect the generated route registration associated with /v2/pet and verify that the server starts without the wildcard conflict while preserving the listed pet endpoints.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.