Ng galien claude/add clientregistrationid annotation rm tc0#23807
Ng galien claude/add clientregistrationid annotation rm tc0#23807wing328 wants to merge 11 commits into
Conversation
…face
Add support for the @ClientRegistrationId annotation in Spring HTTP Interface
generated clients to enable OAuth2 authentication integration with Spring Security.
Changes:
- Add new clientRegistrationId configuration option in SpringCodegen
- Update api.mustache template to include @ClientRegistrationId annotation
- Add import for org.springframework.security.oauth2.client.annotation.ClientRegistrationId
- Process clientRegistrationId in postProcessOperationsWithModels
- Add sample configuration and example output
The @ClientRegistrationId annotation automatically associates OAuth2 tokens
with HTTP requests when using Spring Security 7.0+ HTTP Service Client integration.
Usage:
openapi-generator-cli generate -g spring \
--library spring-http-interface \
--additional-properties clientRegistrationId=my-oauth-client \
-i spec.yaml -o ./output
Related documentation:
https://docs.spring.io/spring-security/reference/features/integrations/rest/http-service-client.html
Move the @ClientRegistrationId annotation from individual methods to the interface class level, following Spring Security's recommended practice. Changes: - Update api.mustache to place annotation on interface declaration - Modify SpringCodegen to set clientRegistrationId on operations map - Update sample code to show class-level annotation - Update README with improved example and explanation This approach is cleaner and avoids repeating the annotation on every method, as recommended in Spring Security documentation.
Add tests to verify: - @ClientRegistrationId annotation is generated when option is set - Annotation is not present when option is not configured Also regenerate complete samples for spring-http-interface-oauth config. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Upgrade Spring Boot from 3.1.3 to 3.5.0 - Add spring-boot-starter-oauth2-client dependency @ClientRegistrationId requires Spring Security 6.5+ (Spring Boot 3.5+) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add README.md to .openapi-generator-ignore to preserve custom docs - Include proper OAuth2ClientHttpRequestInterceptor configuration example - Document Spring Boot 3.5+ / Spring Security 6.5+ requirements Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Restore Spring Boot 3.5.0 and spring-boot-starter-oauth2-client dependency in the spring-http-interface-oauth pom (template default is now 3.3.13, but @ClientRegistrationId requires 6.5+/Boot 3.5+). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tps://github.com/ng-galien/openapi-generator into ng-galien-claude/add-clientregistrationid-annotation-rmTC0
|
@ng-galien can you please review the build errors? https://github.com/OpenAPITools/openapi-generator/actions/runs/26021733653/job/76484768481?pr=23807 |
There was a problem hiding this comment.
3 issues found across 69 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/client/petstore/spring-http-interface-oauth/README.md">
<violation number="1" location="samples/client/petstore/spring-http-interface-oauth/README.md:56">
P2: The documented minimum Spring Security version is incorrect for `@ClientRegistrationId`; this annotation is available starting in Spring Security 7.0.</violation>
<violation number="2" location="samples/client/petstore/spring-http-interface-oauth/README.md:96">
P2: The configuration example is incomplete for `@ClientRegistrationId`: it adds the OAuth2 interceptor but does not configure `HttpServiceProxyFactory` with `ClientRegistrationIdProcessor`.</violation>
</file>
<file name="samples/client/petstore/spring-http-interface-oauth/pom.xml">
<violation number="1" location="samples/client/petstore/spring-http-interface-oauth/pom.xml:47">
P1: Missing OAuth2 client dependency for generated `@ClientRegistrationId` annotations causes compilation failure.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| ### Requirements | ||
|
|
||
| - Spring Boot 3.5+ | ||
| - Spring Security 6.5+ |
There was a problem hiding this comment.
P2: The documented minimum Spring Security version is incorrect for @ClientRegistrationId; this annotation is available starting in Spring Security 7.0.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/spring-http-interface-oauth/README.md, line 56:
<comment>The documented minimum Spring Security version is incorrect for `@ClientRegistrationId`; this annotation is available starting in Spring Security 7.0.</comment>
<file context>
@@ -0,0 +1,108 @@
+### Requirements
+
+- Spring Boot 3.5+
+- Spring Security 6.5+
+
+### Application Properties
</file context>
| .requestInterceptor(interceptor) | ||
| .build(); | ||
|
|
||
| HttpServiceProxyFactory factory = HttpServiceProxyFactory |
There was a problem hiding this comment.
P2: The configuration example is incomplete for @ClientRegistrationId: it adds the OAuth2 interceptor but does not configure HttpServiceProxyFactory with ClientRegistrationIdProcessor.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/spring-http-interface-oauth/README.md, line 96:
<comment>The configuration example is incomplete for `@ClientRegistrationId`: it adds the OAuth2 interceptor but does not configure `HttpServiceProxyFactory` with `ClientRegistrationIdProcessor`.</comment>
<file context>
@@ -0,0 +1,108 @@
+ .requestInterceptor(interceptor)
+ .build();
+
+ HttpServiceProxyFactory factory = HttpServiceProxyFactory
+ .builderFor(RestClientAdapter.create(restClient))
+ .build();
</file context>
|
update: i pushed bbeae12 to update the mustache templates as well. |
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-parent</artifactId> | ||
| <version>3.3.13</version> | ||
| <version>3.5.0</version> |
There was a problem hiding this comment.
looks like updating this will break current supported use cases: https://github.com/OpenAPITools/openapi-generator/actions/runs/26022364837/job/76486919726?pr=23807
so i suggest we update this and address any broken code in a separate PR instead.
There was a problem hiding this comment.
update: filed #23809 to update it and the templates (which broke) as well and all tests passed
based on #22726
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Adds a
clientRegistrationIdoption to the Spring generator to emit@ClientRegistrationIdonspring-http-interfaceclients, enabling OAuth2 token propagation with Spring Security. Also updates thespring-http-interfacepom template to Spring Boot 3.5.0 and adds a conditionalspring-boot-starter-oauth2-clientdependency when the option is used.New Features
clientRegistrationIdadditional property inSpringCodegen.@ClientRegistrationId("...")for API interfaces inspring-http-interface.org.springframework.security.oauth2.client.annotation.ClientRegistrationIdimport inapi.mustache.pom-sb3.mustacheto use Spring Boot3.5.0and addspring-boot-starter-oauth2-clientwhenclientRegistrationIdis set.Docs & Samples
docs/generators/spring.mdanddocs/generators/java-camel.md.bin/configs/spring-http-interface-oauth.yamland sample atsamples/client/petstore/spring-http-interface-oauth.SpringCodegenTestto verify the annotation is generated.Written for commit bbeae12. Summary will update on new commits. Review in cubic