Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Duplicate generated model classes

未关闭
#911 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
冷清
技术栈
java

调研方向

首先跟踪报告中显示的生成的 RolesClient 方法以及 Role、GetRoleResponseContent 和 CreateRoleResponseContent 模型。比较它们的 schema 和必填字段,然后验证等效操作是否复用同一种模型类型,以及必需的 API 字段是否不再表示为 Optional。

由索引模型根据 Issue 内容生成。

描述

bug
Checklist
  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.
Description
   RolesClient {

    public SyncPagingIterable<Role> list(ListRolesRequestParameters request) {
        return this.rawClient.list(request).body();
    }
	
	
    public GetRoleResponseContent get(String id) {
        return this.rawClient.get(id).body();
    }

    public CreateRoleResponseContent create(CreateRoleRequestContent request) {
        return this.rawClient.create(request).body();
    }
}

Duplicate generated model classes.

The generated SDK appears to create separate model classes for list, get and create operations, even when they represent the same resource and contain identical properties.

For example, a list() operation may return a Role model, while the corresponding get() operation returns a GetRoleResponseContent model, despite both models appearing to be structurally identical.

Using different model classes for the same resource makes the SDK inconsistent and adds unnecessary complexity for consumers. It would be preferable to reuse the same model type across operations whenever the underlying schemas are equivalent.

public final class Role {
    private final Optional<String> id;
    private final Optional<String> name;
    private final Optional<String> description;
    private final Map<String, Object> additionalProperties;

}

public final class GetRoleResponseContent{
    private final Optional<String> id;
    private final Optional<String> name;
    private final Optional<String> description;
    private final Map<String, Object> additionalProperties;
}

public final class CreateRoleResponseContent {
    private final Optional<String> id;
    private final Optional<String> name;
    private final Optional<String> description;
    private final Map<String, Object> additionalProperties;
}

Fields such as id and name are required by the API, yet they are generated as Optional. This is misleading and results in unnecessary code such as role.getId().get(), while IDEs still warn that the value may be absent.

Reproduction
Additional context

No response

auth0-java version

3.10.0

Java version

21.0.1

主要语言
Java
星标
319
派生
155
平均合并
4 小时 49 分钟
30 天内合并 PR
11

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

auth0/auth0-java 的其他 Issue

查看 auth0/auth0-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。