Inheritance support
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 20/100
Direção de pesquisa
Reproduza os exemplos mínimos de OpenAPI da issue no playground com spring 2021.5 e localmente com 2023.1.2. Compare a saída gerada de ParentSchema e ChildSchema com a hierarquia de classes separada esperada e determine então se o suporte à herança é pretendido e qual comportamento deve ser documentado ou alterado.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Kotlin
- Estrelas
- 56
- Forks
- 11
- Merge médio
- 4d 10h
- PRs com merge (30d)
- 8
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de openapi-processor/openapi-processor-spring
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
openapi-processor/openapi-processor-spring#524 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
openapi-processor/openapi-processor-spring#334 · 2 comentários ·
Mantenedores costumam responder em até 2 dias
-
enhancement
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 42/100
openapi-processor/openapi-processor-spring#150 · 3 comentários ·
Mantenedores costumam responder em até 2 dias
-
undecided
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
openapi-processor/openapi-processor-spring#101 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
log unknown optionsAbertaenhancement undecided
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
openapi-processor/openapi-processor-spring#51 ·
Mantenedores costumam responder em até 2 dias
Todas as issues de openapi-processor/openapi-processor-spring
Issues semelhantes
-
help wanted needs investigation priority: low
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
LeanBitLab/LeanType#883 ·
Mantenedores costumam responder em até 1 dia
-
Heavy legs 1.12–1.17: compiler corpus goldens not regenerated for #4770Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
intellij-elixir/intellij-elixir#4782 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
komikku-app/komikku#1983 ·
Mantenedores costumam responder em até 1 dia
-
ERR_CLEARTEXT_NOT_PERMITTEDAbertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Seb3thehacker/gearslip#121 ·