OpenAPITools / OpenAPITools/openapi-generator
[BUG] CodegenModel allVars doesn't contain all variables
Open
Nobody has claimed this yet.
Issue: Bug
- 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 (example)?
- 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
CodegenModel.allVars does not contain all variables.
openapi-generator version
6.0.1
OpenAPI declaration file content or url
openapi: 3.0.1
info:
version: 1.0.0
title: Example
license:
name: MIT
servers:
- url: http://api.example.xyz/v1
paths:
/person:
post:
operationId: create
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/AbstractPerson"
description: order to create
required: true
responses:
'200':
description: OK
components:
schemas:
AbstractPerson:
type: object
discriminator:
propertyName: gender
properties:
name:
type: string
required:
- name
Male:
type: object
allOf:
- $ref: "#/components/schemas/AbstractPerson"
properties:
footballs:
type: integer
Female:
type: object
allOf:
- $ref: "#/components/schemas/AbstractPerson"
properties:
high-heels:
type: integer
required:
- high-heels
Generation Details
I used a AbstractKotlinCodegen, e.g. KotlinClientCodegen.
Steps to reproduce
use openapi def and add
// allVars
{{#allVars}}
// {{name}}
{{/allVars}}
// requiredVars
{{#requiredVars}}
// {{name}}
{{/requiredVars}}
// optionalVars
{{#optionalVars}}
// {{name}}
{{/optionalVars}}
to data_class.mustache OR add a breakpoint in AbstractKotlinCodegen.fromModel
Related issues/PRs
Suggest a fix
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 AbstractKotlinCodegen.fromModel and reproduce the issue using the OpenAPI declaration in the report. Add the diagnostic blocks to data_class.mustache, compare allVars with requiredVars and optionalVars for the inherited schemas, and confirm that all expected variables are present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100