OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.81k stars 6.58k forks source link

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

Open MelleD opened 8 months ago

MelleD commented 8 months ago

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]

ch4mpy commented 7 months ago

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:

Bragolgirith commented 6 months ago

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 :)

skaba commented 2 months ago

@Bragolgirith That generates a client not a server

skaba commented 2 months ago

Can we also add support in kotlin generator