Skip to content

Instantly share code, notes, and snippets.

@thomasdarimont
Last active March 24, 2025 13:05
Show Gist options
  • Save thomasdarimont/06906788dc721ae84ddcab1f420eb877 to your computer and use it in GitHub Desktop.
Save thomasdarimont/06906788dc721ae84ddcab1f420eb877 to your computer and use it in GitHub Desktop.
API Sketch - Using different types to restrict available fields
class ClientCreate extends ClientUpdate {
    String type;
    // properties manadatory for creation
}

class ClientUpdate{
    String name;
    String description;
    // updatable properties
}


@Path("/clients")
@POST
Response create(ClientCreate client) {

    ...
}

@Path("/clients/{clientUuid}")
@PUT
Response update(@PathParam("clientUuid") String clientUuid, ClientUpdate client) {

    ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment