OpenAPITools / OpenAPITools/openapi-generator
[REQ][GO] Optionally use public fields for request fields
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
Request structs in generated golang client code contain private members, which makes testing them directly more difficult. It forces either reflection or using a mock server and parsing JSON.
Describe the solution you'd like
It would be helpful if the field names could be set to public instead, controlled by a configuration option to avoid a breaking change.
Describe alternatives you've considered
Additional context
I believe this change just involves the paramName field used in the api mustache template, and so new logic could be added to AbstractGoCodegen to control how the paramName is generated.
If I'm overlooking anything in the existing codebase, or if people have other strategies for testing their requests, I would definitely love to hear your input!
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
Start with AbstractGoCodegen and the api mustache template, focusing on how the paramName field is generated. Trace how generator configuration options are defined and passed into the template. Done means an option can select public request fields without changing the default, and generated Go request structs reflect that choice.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100