Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add springboot's http interface generator #383

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mirror-kt
Copy link
Contributor

@mirror-kt mirror-kt commented Mar 8, 2025

SpringBoot's HTTP Interface is a declarative http client like Retrofit or OpenFeign.
https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-http-interface

Since SpringBoot has now removed OpenFeign from the official project and seems to be focusing on this HTTP Interface, we thought it reasonable to add support for it and implemented it.

This client supports ResponseEntity and suspend methods, so we move the relevant code to ClientGeneratorUtils and so on.

generatedAnnotationFile()
)

private fun generatedAnnotationFile(): SimpleFile {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @GeneratedClient annotation is not required for the feature itself, but SpringBoot often has use cases where classes are searched for using annotations, and this is what it is for

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this annotation defined? I cannot see any class imports

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is generated in the same location as the client's interface.
Since they are in the same package, there should be no need for an import statement.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure about this, it feels wrong to be generating a random annotation just in case it is useful. Could developers instead define their own annotation and add it to the implementation classes?

Copy link
Contributor Author

@mirror-kt mirror-kt Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, like creating an option like --http-client-annotations <annotation FQCN> and annotating the generated clients?

It seems useful not only for this client type, so I'll do it in another PR and revert it in this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #386 and revert @GeneratedClient in this PR

@cjbooms
Copy link
Owner

cjbooms commented Mar 8, 2025

Thanks for the contribution, happy to accept this. Few minor questions

@mirror-kt mirror-kt force-pushed the feature/spring-http-interface branch from 3b1c712 to 3daa162 Compare March 10, 2025 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants