OpenAPITools / OpenAPITools/openapi-generator
[BUG][Golang] Redeclaration error when a parameter has the name 'r'
Nobody has claimed this yet.
- 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?
- 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
I have a parameter with the name r. This causes a redeclaration error in the request builder since the name of the receiver is also r. A small example has been reproduced below.
openapi-generator version
7.14.0
OpenAPI declaration file content or url
Run openapi-generator-cli generate -i api.yaml -o output -g go and look at the output/api_default.go file.
openapi: 3.0.3
info:
title: test
version: 1.0.0
paths:
/test:
get:
parameters:
- name: r
in: query
style: form
required: true
schema:
type: integer
responses:
200:
description:
Test description
content:
application/json:
schema:
type: integer
Suggest a fix
The receiver should not get the same name as the parameter. A single r as the parameter name could be renamed to something like r_ to avoid the conflict.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run openapi-generator-cli generate -i api.yaml -o output -g go using the supplied OpenAPI declaration and inspect output/api_default.go. Confirm the parameter r conflicts with the request-builder receiver, then trace the Go generator template or source that names that receiver. Done means generated Go code compiles without a redeclaration error while preserving the parameter name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100