Duplicate generated model classes
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
- Domain
- api, backend-api-design
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
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
- 156
- Avg merge
- 20h 46m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from auth0/auth0-java
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
auth0/auth0-java#887 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
auth0/auth0-java#842 · 2 comments ·
-
ManagementApiBuilder.domain() builds an invalid URL when the domain includes https:// or a trailing slashPossibly taken @RaphaelFakhri claimed this 33 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
auth0/auth0-java#945 ·
-
feature request
Difficulty 4/5 3-5 days Newbie friendliness 25/100
auth0/auth0-java#944 · 1 comment ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 25/100
auth0/auth0-java#897 ·
All issues in auth0/auth0-java
Similar issues
-
desktop grp:about type:graphics-bug ui-public
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 2 days
-
EC2 SSH agent launch fails with NullPointerException when HTTP proxy has no password configuredOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jenkinsci/ec2-plugin#2051 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
it-at-m/Wahllokalsystem#3846 ·
Maintainers usually reply within 2 days