openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[REQ] Add a Spring Http interface to Server/Client generator

Open MelleD opened this issue 2 years ago • 4 comments

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

Spring has its own Http interface description, which will be further developed in the future to use server and client code.

As an example, the Spring Open Feign was already announced as a feature completed and was no longer developed further because Spring continues to maintain and develop its own Http interface. For this reason, a new generator would be great for this.

see https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-http-interface

Spring Open Feign The library spring cloud-openfeign [https://github.com/spring-cloud/spring-cloud-openfeign] is in maintenance mode. Still there are bugfixes and fixes for {color:#1f2328}vulnerability fixes but no further development.

Here is the official announcement: [https://spring.io/blog/2022/12/16/spring-cloud-2022-0-0-codename-kilburn-has-been-released]

Spring Cloud OpenFeign feature complete announcement

Since Spring now provides its own interface HTTP clients solution, starting with 2022.0.0, we're going to treat Spring Cloud OpenFeign as feature complete. This means that the Spring Cloud team will no longer be adding new features to the module. We will still fix bugs and security issues, and we will also consider and review small pull requests from the community

Thats the new way: [https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-http-interface]

MelleD avatar Feb 22 '24 09:02 MelleD

I would add that it would be great to have an option to generate just DTOs & interfaces (optionally decorated with @HttpExchange).

I frequently need advanced customization of REST clients (proxy configuration, Bearer header authorization, ...) and use different implementations depending on the context (WebClient in reactive apps, RestClient in servlet, one could prefer the venerable RestTemplate, ...). So, I'd prefer to provide the REST client bean myself and mix it with a generated @HttpExchange using HttpServiceProxyFactory.

In other words, it would be great if we could have some control on what is generated (where the generator stops):

  1. just DTOs (model), ideally with a choice of the coupling (pure POJOs or records with optional annotations for validation, JSON serialization from a choice of libs, Lombok, ...)
  2. "vanilla" interfaces (plain Java interfaces without coupling to Jackson, OpenAPI, etc.)
  3. @HttpExchange (in a client app) or@RequestMapping (in a server app)
  4. tooling (utils, services optionally exposed as beans, etc.)

I'd be super happy if I could configure the generator to get:

  • records without any annotation at step 1 (maybe optionals for nullable values)
  • @HttpExchange at step 3
  • nothing at all at step 4

ch4mpy avatar Mar 29 '24 16:03 ch4mpy

I was also curious about this, and a spring server generator with a spring-http-interface sub-template seems to exist already: https://openapi-generator.tech/docs/generators/spring (haven't tested it though)

But a client generator would be awesome - yes please :)

Bragolgirith avatar Apr 15 '24 15:04 Bragolgirith

@Bragolgirith That generates a client not a server

skaba avatar Aug 27 '24 14:08 skaba

Can we also add support in kotlin generator

skaba avatar Aug 27 '24 14:08 skaba

@Bragolgirith That generates a client not a server

The generator from the link explicitly specifies:

generator type SERVER Generates a Java SpringBoot Server application using the SpringDoc integration.

From what I see there's still no client generator for Spring's HTTP Interface, nor does the existing java client generator support a sub-template for it.

Bragolgirith avatar May 02 '25 14:05 Bragolgirith

@Bragolgirith you should better read the spring generator CONFIG OPTIONS. The spring-http-interface value of the library generates the client code from an @HttpExchange interface to consume a REST API.

ch4mpy avatar May 02 '25 20:05 ch4mpy