swagger-api / swagger-api/swagger-codegen

[golang] Default to pointers for non-primitive types

Open
#2,330 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Go Enhancement: General General: Discussion help wanted
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

It generates code like this currently:

type JobWrapper struct {
    Job  Job  `json:"job,omitempty"`
}

Same with slices and what not.

It would be nice (and probably what most people would want) to have it use pointers, eg:

type JobWrapper struct {
    Job *Job  `json:"job,omitempty"`
}

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

The issue provides Go struct examples but no file or test path. Start by finding the Go code-generation templates responsible for model fields; done means non-primitive fields such as Job are emitted as pointers while primitive fields retain their current behavior, with coverage for the generated output.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.