[BUG][3.1] "Failed to get the schema name: null" for a schema with additionalProperties: false that has an additionalProperties: true property
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
Start with OpenAPINormalizer.isSelfReference and fixSelfReferenceSchema, using the stack trace and reproducer in the issue to follow how a schema without $ref reaches ModelUtils.getSimpleRef. Check the existing normalizer tests for self-reference handling and add coverage for the supplied OpenAPI 3.1 schema; done when generation no longer logs the warning. Pull request #25605 is already open against this issue.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Version
openapi-generator 7.27.0. Verified with kotlin-spring; the warning comes from the core OpenAPINormalizer, so it should not depend on the generator. OpenAPI 3.1.0 spec.
Reproducer
openapi: 3.1.0
info:
title: repro
version: 1.0.0
paths:
/things:
post:
operationId: createThing
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Thing'
responses:
'200':
description: ok
components:
schemas:
Thing:
type: object
additionalProperties: false
properties:
state:
type: object
additionalProperties: true
Run a generator on it (verified with kotlin-spring).
Actual
WARN ModelUtils - Failed to get the schema name: null
Code path (stack trace from a patched ModelUtils):
ModelUtils.getSimpleRef(ModelUtils.java:397)
OpenAPINormalizer.isSelfReference(OpenAPINormalizer.java:949)
OpenAPINormalizer.fixSelfReferenceSchema(OpenAPINormalizer.java:940)
OpenAPINormalizer.normalizeComponentsSchemas(OpenAPINormalizer.java:869)
OpenAPINormalizer.normalize(OpenAPINormalizer.java:442)
DefaultGenerator.configureGeneratorProperties(DefaultGenerator.java:272)
fixSelfReferenceSchema checks schema.getAdditionalProperties() instanceof Schema and then calls isSelfReference(name, ap), which calls getSimpleRef(ap.get$ref()).
For Thing, getAdditionalProperties() at that point is a Schema with every field null, including $ref, rather than the boolean false. So getSimpleRef(null) logs the warning.
Without the nested additionalProperties: true property, the same schema reaches the method with ap=false and no warning is logged. The empty Schema appears only when a property carries additionalProperties: true. I did not trace which earlier normalization step rewrites it.
Expected
No warning. An additionalProperties schema without a $ref cannot be a self-reference, so isSelfReference should return false when subSchema.get$ref() == null, without calling getSimpleRef. The generated output is not affected by this bug.
Suggested fix
protected boolean isSelfReference(String name, Schema subSchema) {
return subSchema != null && subSchema.get$ref() != null
&& name.equals(ModelUtils.getSimpleRef(subSchema.get$ref()));
}
I searched existing issues for "Failed to get the schema name" (the matches were about unrelated $ref resolution) and for fixSelfReferenceSchema (#17755, unrelated).
- Linguagem predominante
- Java
- Estrelas
- 26.9k
- Forks
- 7.8k
- Merge médio
- 2d 10h
- PRs com merge (30d)
- 180
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Inclui um Dockerfile ou arquivo Docker Compose
- Tem um 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 OpenAPITools/openapi-generator
-
Issue: Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
OpenAPITools/openapi-generator#25643 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
OpenAPITools/openapi-generator#25640 ·
Mantenedores costumam responder em até 1 dia
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)Talvez já em andamento @Inf1mum assumiu há 2 dias. AbertaIssue: Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
OpenAPITools/openapi-generator#25567 ·
Mantenedores costumam responder em até 1 dia
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twiceTalvez já em andamento @Inf1mum assumiu há 9 dias. AbertaIssue: Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
OpenAPITools/openapi-generator#25524 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. AbertaEnhancement: Feature
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
OpenAPITools/openapi-generator#25364 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de OpenAPITools/openapi-generator
Issues semelhantes
-
bug emitter:client:csharp
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
microsoft/typespec#12572 · 1 comentário · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
Mantenedores costumam responder em até 1 dia
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationTalvez já em andamento @amalsaidov assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
needs-area-label
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 2 dias
-
area/ai area/backend component/zeebe kind/task
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia