Duplicate generated model classes

Aperta
#911 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
java

Direzione di ricerca

Inizia tracciando i metodi generati di RolesClient e i modelli Role, GetRoleResponseContent e CreateRoleResponseContent mostrati nel report. Confronta i relativi schemi e campi obbligatori, quindi verifica che le operazioni equivalenti riutilizzino lo stesso tipo di modello e che i campi API obbligatori non siano più rappresentati come Optional.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Java
Stelle
319
Fork
155
Merge medio
1g 1h
PR unite (30g)
12

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di auth0/auth0-java

Tutte le issue di auth0/auth0-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.