Duplicate generated model classes

Open
#911 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java

Research direction

Start by tracing the generated RolesClient methods and the Role, GetRoleResponseContent, and CreateRoleResponseContent models shown in the report. Compare their schemas and required fields, then verify that equivalent operations reuse one model type and that required API fields are no longer represented as Optional.

Written by the indexing model from the issue text.

Description

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

Dominant language
Java
Stars
319
Forks
155
Avg merge
1d 1h
Merged PRs (30d)
12

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from auth0/auth0-java

All issues in auth0/auth0-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.