Inheritance support
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 20/100
Línea de trabajo
Reproduce los ejemplos mínimos de OpenAPI del issue en el playground con spring 2021.5 y localmente con 2023.1.2. Compara la salida generada de ParentSchema y ChildSchema con la jerarquía de clases separada esperada y determina después si se pretende admitir la herencia y qué comportamiento debería documentarse o cambiarse.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Kotlin
- Estrellas
- 56
- Forks
- 11
- Merge medio
- 4 d 10 h
- PR fusionados (30 d)
- 8
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openapi-processor/openapi-processor-spring
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
openapi-processor/openapi-processor-spring#524 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
openapi-processor/openapi-processor-spring#334 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
openapi-processor/openapi-processor-spring#150 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
-
undecided
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
openapi-processor/openapi-processor-spring#101 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
log unknown optionsAbiertoenhancement undecided
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
openapi-processor/openapi-processor-spring#51 ·
Los mantenedores suelen responder en 2 días
Todos los issues de openapi-processor/openapi-processor-spring
Issues similares
-
help wanted needs investigation priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
LeanBitLab/LeanType#883 ·
Los mantenedores suelen responder en 1 día
-
Heavy legs 1.12–1.17: compiler corpus goldens not regenerated for #4770Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
intellij-elixir/intellij-elixir#4782 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
komikku-app/komikku#1983 ·
Los mantenedores suelen responder en 1 día
-
ERR_CLEARTEXT_NOT_PERMITTEDAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Seb3thehacker/gearslip#121 ·