swagger-api / swagger-api/swagger-codegen
[JAVA] method clash on inherited model when overloaded property is not in first position
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
i encountered this error while generating a subclass, i don't think it's intended, version 3.0.24
the fix i found is simple enough, i just put the referenced property to overload in first position (see correct code, children property)
wrong code:
NodeToMerge:
allOf: # Combines the Node and the following model, (inheritance)
- $ref: '#/components/schemas/Node'
- type: object
required:
- children
properties:
nodeType:
type: string
markNodeToAdd:
type: boolean
markNodeToAddSingle:
type: boolean
description: only for css purpose
markNodeToRemove:
type: boolean
markNodeToModify:
type: boolean
newNodeIfModified:
$ref: '#/components/schemas/NodeToMerge'
mergeProcessed:
type: boolean
description: indicates the node has been processed for adding or removal
idModificaNodo:
type: number
description: unique id assigned when a node is detected as changed (not really necessary)
checkedByUser:
type: boolean
description: indicates the user checked this node (it reverse the add/remove processor)
childrenWhenFlat:
type: array
xml:
name: children
wrapped: false
items:
$ref: '#/components/schemas/NodeToMerge'
example: null
children:
type: array
items:
$ref: '#/components/schemas/NodeToMerge'
Node:
type: object
required:
- name
- id
- children
properties:
id:
type: integer
format: int64
description: Node id from table 'Anagrafica Nodo'
idView:
type: string
description: Node view id composed from anagrafica_nodo id and strings generated by the frontend
idRel:
type: string
description: id of the node (must be unique) in the format <id_relazione_albero>-<id_anagrafica_nodo
idParent:
type: integer
format: int64
description: parent Node id from table 'Anagrafica Nodo'
idRelParent:
type: array
items:
type: string
description: id of the parent node (must be unique) in the format <id_relazione_albero>-<id_anagrafica_nodo
name:
type: string
example: nome nodo XY
expanded:
type: boolean
default: false
description: indicates if node should be expanded during tree rendering
children:
type: array
xml:
name: children
wrapped: false
items:
$ref: '#/components/schemas/Node'
example: null
status:
type: string
description: status of node
enum:
- active
- up
- down
slaFactor:
type: number
description: 'SLA factor [0, ...1]'
example: 1
type:
type: string
description: type of node
enum:
- C
- T
- P
periodActivation:
type: string
description: 'ni_anno_attivazione ni_mese_attivazione table ANAGRAFICA_NODO'
periodDismissal:
type: string
description: 'ni_anno_scadenza ni_mese_scadenza table ANAGRAFICA_NODO'
ods:
type: string
example: '08:00 18:00 da Lun a Ven, 09:30 13:30 Sabato'
sla:
type: number
order:
type: integer
description: 'order of child node in regard to its parent and siblings'
xml:
name: Node
correct code:
NodeToMerge:
allOf: # Combines the Node and the following model, (inheritance)
- $ref: '#/components/schemas/Node'
- type: object
required:
- children
properties:
children:
type: array
items:
$ref: '#/components/schemas/NodeToMerge'
nodeType:
type: string
markNodeToAdd:
type: boolean
markNodeToAddSingle:
type: boolean
description: only for css purpose
markNodeToRemove:
type: boolean
markNodeToModify:
type: boolean
newNodeIfModified:
$ref: '#/components/schemas/NodeToMerge'
mergeProcessed:
type: boolean
description: indicates the node has been processed for adding or removal
idModificaNodo:
type: number
description: unique id assigned when a node is detected as changed (not really necessary)
checkedByUser:
type: boolean
description: indicates the user checked this node (it reverse the add/remove processor)
childrenWhenFlat:
type: array
xml:
name: children
wrapped: false
items:
$ref: '#/components/schemas/NodeToMerge'
example: null
description: 'children not rendered by tree widget, needed for when the tree is rendered flat otherwise the resulting tree loses children info (usecase: deleting a TI node)'
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
Reproduce Java subclass generation with the Node and NodeToMerge schemas shown in the issue, comparing the two allOf property orders. The issue names no repository files or tests; done means generation no longer fails or produces a method clash when the inherited children property is not first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100