Inheritance support
Les mainteneurs répondent en général sous 2 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 20/100
Piste de recherche
Reproduisez les exemples OpenAPI minimaux de l’issue dans le playground avec spring 2021.5 et localement avec 2023.1.2. Comparez la sortie générée de ParentSchema et ChildSchema avec la hiérarchie de classes séparées attendue, puis déterminez si la prise en charge de l’héritage est prévue et quel comportement devrait être documenté ou modifié.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Quite impressed with the toolset you created here.
I was curious about inheritance support so I tried it out with a minimal example:
openapi: 3.0.2
info:
title: edit me
version: 1.0.0
paths:
/nothing:
description: dummy
get:
responses:
'200':
description: empty
content:
'application/json':
schema:
$ref: '#/components/schemas/ChildSchema'
components:
schemas:
ParentSchema:
type: object
properties:
parentAttr:
type: string
ChildSchema:
allOf:
- $ref: '#/components/schemas/ParentSchema'
- type: object
properties:
childAttr:
type: string
This yields a ChildSchema.java consisting of everything from the parent and child model:
public class ChildSchema {
@JsonProperty("parentAttr")
private String parentAttr;
@JsonProperty("childAttr")
private String childAttr;
public String getParentAttr() {
return parentAttr;
}
public void setParentAttr(String parentAttr) {
this.parentAttr = parentAttr;
}
public String getChildAttr() {
return childAttr;
}
public void setChildAttr(String childAttr) {
this.childAttr = childAttr;
}
}
Now specifying a discriminator results in inheritance in the generated code (at least for the openapi-generator project):
openapi: 3.0.2
info:
title: edit me
version: 1.0.0
paths:
/nothing:
description: dummy
get:
responses:
'200':
description: empty
content:
'application/json':
schema:
$ref: '#/components/schemas/ChildSchema'
components:
schemas:
ParentSchema:
type: object
discriminator:
propertyName: className
properties:
parentAttr:
type: string
ChildSchema:
allOf:
- $ref: '#/components/schemas/ParentSchema'
- type: object
properties:
childAttr:
type: string
For this a special propertyName of className is used. If I run that in your playground with spring 2021.5 it complains about the property name which is not wrong strictly speaking:
The discriminator 'className' is not a property of this schema (code: 134)
If I run this locally with 2023.1.2 then this does not error but does not generate two classes with one inheriting from each other:
public class ChildSchema {
@JsonProperty("parentAttr")
private String parentAttr;
@JsonProperty("childAttr")
private String childAttr;
public String getParentAttr() {
return parentAttr;
}
public void setParentAttr(String parentAttr) {
this.parentAttr = parentAttr;
}
public String getChildAttr() {
return childAttr;
}
public void setChildAttr(String childAttr) {
this.childAttr = childAttr;
}
}
Expected result would have been:
public class ParentSchema {
@JsonProperty("parentAttr")
private String parentAttr;
public String getParentAttr() {
return parentAttr;
}
public void setParentAttr(String parentAttr) {
this.parentAttr = parentAttr;
}
}
public class ChildSchema extends ParentSchema {
@JsonProperty("childAttr")
private String childAttr;
public String getChildAttr() {
return childAttr;
}
public void setChildAttr(String childAttr) {
this.childAttr = childAttr;
}
}
Now this expectation could of course be wrong. My question now would be if this inheritance use case is supported and/or if I would have to do something differently to get the desired result. Thanks.
- Langage dominant
- Kotlin
- Étoiles
- 56
- Forks
- 11
- Merge moyen
- 4 j 10 h
- PR mergées (30 j)
- 8
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de openapi-processor/openapi-processor-spring
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
openapi-processor/openapi-processor-spring#524 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
openapi-processor/openapi-processor-spring#334 · 2 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
enhancement
Difficulté 3/5 1-2 jours Accessibilité débutants 42/100
openapi-processor/openapi-processor-spring#150 · 3 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
undecided
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
openapi-processor/openapi-processor-spring#101 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
log unknown optionsOuverteenhancement undecided
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
openapi-processor/openapi-processor-spring#51 ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de openapi-processor/openapi-processor-spring
Issues similaires
-
help wanted needs investigation priority: low
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
LeanBitLab/LeanType#883 ·
Les mainteneurs répondent en général sous 1 jour
-
Heavy legs 1.12–1.17: compiler corpus goldens not regenerated for #4770Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
intellij-elixir/intellij-elixir#4782 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
komikku-app/komikku#1983 ·
Les mainteneurs répondent en général sous 1 jour
-
ERR_CLEARTEXT_NOT_PERMITTEDOuvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Seb3thehacker/gearslip#121 ·