OpenAPITools / OpenAPITools/openapi-generator

[Question] What is vars and allVars used for?

Open
#12,785 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

More of a question than a bug report: I discovered in the addVars method of the DefaultCodegen the following code snippet

        if (allProperties != null) {
            Set<String> allMandatory = allRequired == null ? Collections.emptySet()
                    : new TreeSet<>(allRequired);
            // update "vars" with parent's properties (all, required)
            addVars(m, m.allVars, allProperties, allMandatory);
            m.allMandatory = allMandatory;
        }

Why is vars updated with the properties from allVars? Doesn't vars contain only the properties from the schema objects properties-block in contrast to allVars, which contains cumulatively all properties from the parents plus the own properties?

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 with the DefaultCodegen.addVars method and trace how vars, allVars, allProperties, and allMandatory are populated. Check the related model-generation flow to determine whether the current behavior is intentional. Done means documenting the distinction and explaining why parent properties are passed through addVars.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.