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
- 155
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 12
Contributor 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 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 25/100
auth0/auth0-java#897 ·
-
feature request
Difficulty 1/5 Under an hour Newbie friendliness 50/100
auth0/auth0-java#754 · 2 comments ·
All issues in auth0/auth0-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
checkstyle/test-configs#263 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/cloudstack#14222 ·
-
[BUG]茶杯方块在取茶时会引发崩溃 Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
1.0.0-alpha2 Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/dpdp-accelerator#272 ·