Skip to content

Duplicate generated model classes #911

Description

@GipHub123

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis points to a verified bug in the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions