Spring Data REST: non-exported association schemas renamed to <Name>Response since 3.1.1 (breaking), applied inconsistently
维护者通常 1 天内回复
@wn1331 已经在做这个了。
开始于 2026年11月11日。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- java, kotlin, openapi, spring-boot
调研方向
Start with SpringDocDataRestUtils.updateResponseSchemaProperty and the entityInoMap lookup keyed by getSimpleName(), as introduced by PR #3334. Reproduce with an entity that has a non-exported repository, comparing a Set association, a nullable single association, and a non-null single association in the generated /v3/api-docs. Done means the naming rule is consistent across those shapes and @Schema(name) is honoured, which first requires agreeing on the intended behaviour with maintainers.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
After upgrading springdoc-openapi-starter-webmvc-ui from 3.0.2 to 3.1.1 (still present in 3.2.0), component schemas for entities that are not exported repositories are renamed. For example, CustomerRelationship becomes CustomerRelationshipResponse in the generated spec. This changes generated client type names in a minor release.
This comes from #3334 (fix for #3136), which makes SpringDocDataRestUtils.updateResponseSchemaProperty rewrite such association properties to a <Name>Response copy. The filtering itself makes sense, but the side effects are surprising:
-
Breaking rename in a minor version. Nothing in #3334 or the release notes mentions that schema names change.
-
Inconsistent behaviour. Only two property shapes are rewritten: a direct
$refanditems(collections).Set<CustomerRelationship>is rewritten, so the spec containsCustomerRelationshipResponse.- A nullable single association (
var region: CustomerRegion?) is emitted in OpenAPI 3.1 asoneOf: [{$ref: CustomerRegion}, {type: null}]. It is skipped, so the plainCustomerRegionstays. - A non-null single association (
CustomerRegion) is rewritten toCustomerRegionResponse.
Similar relations therefore get different names depending on cardinality and nullability.
-
@Schema(name)is only honoured if it differs from the class name.entityInoMapis keyed bydomainType.getSimpleName()and looked up with the schema name.@Schema(name = "CustomerRelationship")onCustomerRelationshipis ignored and the suffix is still added.@Schema(name = "Foo")works because the lookup misses and no copy is created.
To Reproduce
- Spring Boot 4.x,
spring-boot-starter-data-rest, springdoc 3.1.1 or 3.2.0, OpenAPI 3.1. - Entity
Customerwith:@OneToMany(fetch = FetchType.LAZY) var relationships: Set<CustomerRelationship> = emptySet() @ManyToOne(fetch = FetchType.LAZY) var region: CustomerRegion? = nullCustomerRelationshipandCustomerRegionare entities with no exported repository. - Compare
/v3/api-docson 3.0.2 and 3.1.1:- 3.0.2:
#/components/schemas/CustomerRelationship - 3.1.1+:
#/components/schemas/CustomerRelationshipResponse;regionstill referencesCustomerRegion.
- 3.0.2:
Expected behavior
- Schema names stay stable across a minor upgrade, or the change is documented as breaking.
- Handling is consistent for collections, nullable singles (
oneOf/allOfwrappers), and non-null singles. - An explicit
@Schema(name = …)is respected even when it equals the class name, or the suffix is configurable (for example a property to disable the rename).
Workaround
Customize the generated schemas yourself to rename or strip the suffix, or use a @Schema(name) that differs from the class name.
- 主要语言
- Java
- 星标
- 3.7k
- 派生
- 605
- 平均合并
- 2 天 11 小时
- 30 天内合并 PR
- 17
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
springdoc/springdoc-openapi 的其他 Issue
-
MCP: OpenApiSchemaConverter drops types from OpenAPI 3.1 type arrays可能已有人在做 @mariodavid 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 30/100
springdoc/springdoc-openapi#3427 ·
维护者通常 1 天内回复
-
enhancement upstream
难度 4/5 3-5 天 新手友好度 48/100
springdoc/springdoc-openapi#3324 · 2 条评论 ·
维护者通常 1 天内回复
-
enhancement upstream
难度 3/5 1-2 天 新手友好度 55/100
springdoc/springdoc-openapi#3309 · 4 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 springdoc/springdoc-openapi 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
line/centraldogma#1397 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
vert-x3/vertx-mail-client#268 ·
-
desktop edt not responding
难度 1/5 1-3 小时 新手友好度 86/100
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
physical
难度 2/5 1-3 小时 新手友好度 74/100
antonyrag/ragleap-core#1339 ·