swagger-api / swagger-api/swagger-codegen

io.swagger.codegen.v3.CodegenModel class has public member variables

Open
#9,144 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

The CodegenModel class declares all the member variables as public. Interestingly they also provider getter/setter methods for all of them. The DefaultGenerator code directly references the member variables breaking encapsulation and preventing wrapping of these classes using (for instance) the decorator pattern. There is no reason to do this. These members should be declared as private or protected.

Swagger-codegen version

v3.0.4

Suggest a fix/enhancement

Make these member variables private/protected and avoid use of this pattern. Remove direct access of member variables from associated code.

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 locating the CodegenModel class and the DefaultGenerator code that directly accesses its member variables. Review the existing getter and setter methods, then identify associated direct field access that must be replaced. Done means the fields are private or protected and the affected code no longer accesses them directly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.