[Spring] Add clientRegistrationId option for OAuth2 HTTP Interface

Merged
NG
6mo ago
+9393-0

Summary

Adds support for generating Spring HTTP Interface clients with the @ClientRegistrationId annotation to enable OAuth2 with Spring Security.

Changes

  • Add clientRegistrationId additional property and CLI option to SpringCodegen
  • Update spring-http-interface template to import and apply @ClientRegistrationId on the interface when set
  • Add unit tests for the new option
  • Include a sample config and generated sample demonstrating usage

Generated Code Example

@ClientRegistrationId("petstore-oauth")
public interface PetApi {

    @HttpExchange(
        method = "GET",
        value = "/pet/{petId}",
        accept = { "application/json" }
    )
    ResponseEntity<PetDto> getPetById(@PathVariable("petId") Long petId);
}

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work.
  • Run the following to build the project and update samples. Commit all changed files.
  • File the PR against the correct branch: master
  • @mention the technical committee members

Java Spring Technical Committee: @cachescrubber @welshm @MelleD @atextor @manedev79 @javisst @borsch @banlevente @Zomzog @martin-mfg