Skip to content

[REQ] [kotlin-spring] Add clientRegistrationId for spring-declarative-http-interface (parity with Java spring) #24936

Description

@rkudryashov

Is your feature request related to a problem? Please describe.

When generating a Kotlin HTTP Interface client with kotlin-spring + library=spring-declarative-http-interface (Spring Boot 4 / Security 7), the generated API interfaces do not include @ClientRegistrationId. Without that annotation, Spring Security’s OAuth2 HTTP Service Client integration does not attach tokens for client_credentials (or other registrations).

The Java spring generator already supports this via clientRegistrationId (library=spring-http-interface, useSpringBoot4=true) — see PR #22726 and the spring generator docs. kotlin-spring has no equivalent option, so Kotlin users must post-process generated *Api.kt files.

Describe the solution you'd like

Add a clientRegistrationId config option to kotlin-spring with the same semantics as the Java spring generator:

  • When set, and library=spring-declarative-http-interface (with Boot 4 / Security 7 as required), emit @ClientRegistrationId("<id>") on the generated interface.
  • Document the option in kotlin-spring docs.

Example:

generatorName: kotlin-spring
library: spring-declarative-http-interface
additionalProperties:
  useSpringBoot4: "true"
  interfaceOnly: "true"
  clientRegistrationId: assistant

Expected:

@ClientRegistrationId("assistant")
interface DocumentsApi {
    // ...
}

Describe alternatives you've considered

  1. Gradle doLast workaround: inject @ClientRegistrationId into generated *Api.kt after generation (what we do today).
  2. Switch the client generator to Java spring + spring-http-interface (works, but mixes Java clients into a Kotlin service and splits server/client generators).
  3. Manual/non-generated HTTP interfaces.

Additional context

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions