springdoc / springdoc.github.io

Library for OpenAPI 3 with spring-boot
https://springdoc.org
Apache License 2.0
9 stars 42 forks source link

Fix documentation for programmatic RouterFunctions #39

Closed johnellinwood closed 1 year ago

johnellinwood commented 2 years ago

Edit: This is just a documentation fix. On the main springdoc page for the programmatic openapi feature, you should point out that the route() method in your example is not the normal route() method from functional spring webflux routing. Looking more closely at the example code and javadocs, I see you have a [SpringdocRouteBuilder.route()](https://javadoc.io/static/org.springdoc/springdoc-openapi-webflux-core/1.6.6/org/springdoc/webflux/core/fn/SpringdocRouteBuilder.html#route()) that is completely different than the normal spring RouterFunctions.route() method that people are used to calling.

The fact these are different methods isn't mentioned in your documentation, and since you do a static import in the example code, it was really easy to miss.

Original:

Describe the bug You can't create a RouterFunction with programmatic openapi details

@Bean RouterFunction<ServerResponse> myroute() {
  return route().GET("/foo", HANDLER_FUNCTION, ops -> ops.operationId("hello")).build()
}

like the documentation says here.

To Reproduce Steps to reproduce the behavior:

Expected behavior

Additional context

johnellinwood commented 2 years ago

To further clarify this. I'm just trying to add openapi details programmatically. I currently have annotations on my RouterFunctions and HandlerFunctions. But a lot of these are exactly the same except for operationId and return types, so I'm trying to create some generic functions to apply the openapi information to them. To do this, I need to use the programmatic openapi interface. The only way I can see to do this is with the org.springdoc.core.fn.builders.apiresponse.Builder api and somehow attach it to the RouterFunction. But i don't see any way to do that, since the methods in the examples don't exist in the latest spring webflux.

johnellinwood commented 2 years ago

Hey, so I think this is a documentation issue. On the main springdoc page for the programmatic openapi feature, you should point out that the route() method in your example is not the normal route() method from functional spring webflux routing. Looking more closely at the example code and javadocs, I see you have a [SpringdocRouteBuilder.route()](https://javadoc.io/static/org.springdoc/springdoc-openapi-webflux-core/1.6.6/org/springdoc/webflux/core/fn/SpringdocRouteBuilder.html#route()) that is completely different than the normal spring RouterFunctions.route() method that people are used to calling.

The fact these are different methods isn't mentioned in your documentation, and since you do a static import in the example code, it was really easy to miss.

bnasslahsen commented 1 year ago

@johnellinwood,

If you have bugs in the documentation, please feel free to update directly the related .adoc files.

bnasslahsen commented 1 year ago

closed as no activity