OpenAPITools / OpenAPITools/openapi-generator

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

Open
#24,936 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the Java spring generator's clientRegistrationId implementation with the kotlin-spring generator and its spring-declarative-http-interface templates. Update the Kotlin generator documentation and verify that the option emits @ClientRegistrationId on generated interfaces when the stated library and Spring Boot settings are used.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, openapi, spring
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.