[BUG][3.1] "Failed to get the schema name: null" for a schema with additionalProperties: false that has an additionalProperties: true property
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- Java
- Star
- 26.9k
- Fork
- 7.8k
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 180
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenAPITools/openapi-generator
-
Issue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
OpenAPITools/openapi-generator#25643 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
OpenAPITools/openapi-generator#25640 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)Có thể đã có người làm @Inf1mum đã nhận 2 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
OpenAPITools/openapi-generator#25567 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twiceCó thể đã có người làm @Inf1mum đã nhận 9 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
OpenAPITools/openapi-generator#25524 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởEnhancement: Feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenAPITools/openapi-generator#25364 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của OpenAPITools/openapi-generator
Issue tương tự
-
bug emitter:client:csharp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/typespec#12572 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationCó thể đã có người làm @amalsaidov đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-area-label
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
area/ai area/backend component/zeebe kind/task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày