Skip to content

Support for Spring WebMvc.fn #546

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

Closed
nlochschmidt opened this issue Apr 7, 2020 · 5 comments
Closed

Support for Spring WebMvc.fn #546

nlochschmidt opened this issue Apr 7, 2020 · 5 comments

Comments

@nlochschmidt
Copy link

nlochschmidt commented Apr 7, 2020

You have a note on https://springdoc.org/ saying:

Spring-weblfux with Functional Endpoints, will be available in the future release

However, I haven't seen any mention on supporting WebMvc.fn (classic servlets): https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#webmvc-fn

Do you already have an idea on how this could be supported? Given that this approach doesn't have a convenient place to put any annotations, I wonder how feasible it actually is.

Since the Functional Endpoints for Servlets are now pretty much stable, I am guessing that more people are going to ask for this.

As a side-note, here are two examples on how other libraries are solving this problem:

  • HTTP4K is using a meta dsl
  • Jooby is using a combination of build-time byte code analysis + annotation on handler functions
@bnasslahsen
Copy link
Collaborator

Hi @nlochschmidt,

This is a new feature added since 5.2 Release.
The functional endpoints were first available in spring-webflux since 5.0.
And should be addressed first, before the Support for Spring WebMvc.fn.
The approach should the same for Spring WebMvc.fn, once it will be addressed for spring-webflux.

For the moment, we are still focusing on the core functionality of the library.
You can also contribute to add this support. This might accelerate the release of this functionality.

@nlochschmidt
Copy link
Author

Ok thanks.

I actually would love to prototype this, however since I don't have a massive amount of time, I was wondering which approach might be most interesting to the maintainers of springdoc.

I guess it is probably possible to get the root RouterFunction(s) from the spring context and add them to the existing mappings and then later use a RouterFunctions.Visitor in OpenApiResource to construct the right OpenAPI model from it.

However the main question I have now is where we should attach the OpenAPI3 annotations or whether we should skip the annotation and directly let the developer add OpenAPI values to the RouterFunctions somehow.

The latter could be possible by adding a DocumentedRouterFunction to springdoc that is functionally just a wrapper that is directly forwarding every request, but has an additional field for OpenAPI values.

Maybe @poutsma has an idea on how we could make this work best?

I haven't done anything with the reactive stack yet, but the RouterFunctions implementation looks pretty much identical. So likely the implementation in SpringDoc will be very similar as well.

@poutsma
Copy link

poutsma commented Apr 14, 2020

I don't know much about OpenAPI, but any kind of router functions inspection should indeed use the visitor mechanism.

@bnasslahsen
Copy link
Collaborator

@nlochschmidt,

The support is added and available with the latest stable release.

@nlochschmidt
Copy link
Author

Great! Thank you so much 👍

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

No branches or pull requests

3 participants