openapi-tools / swagger-maven-plugin

Maven plugin to activate the Swagger Core library to generate OpenAPI documentation.
MIT License
70 stars 45 forks source link

Supporting API generation from Webflux Functional Endpoint #80

Closed kmozaid closed 3 years ago

kmozaid commented 3 years ago

Hi, I am using springdoc-openapi-webflux-ui to generate documentation from functional endpoints in my reactive application. The generated document is only available on runtime (when app is running). I want to generate document in compile phase and wanted to use this plugin but its unable to detects apis. Can we add support for it?

A sample route function from the demo

    @Bean
    RouterFunction<ServerResponse> routerFunction() {
        return SpringdocRouteBuilder.route().GET("/coffees", this::all, ops -> ops.beanClass(CoffeeService.class).beanMethod("getAllCoffees")).build()
                .and(route().GET("/coffees/{id}", this::byId, ops -> ops.beanClass(CoffeeService.class).beanMethod("getCoffeeById")).build())
                .and(route().GET("/coffees/{id}/orders", this::orders, ops -> ops.beanClass(CoffeeService.class).beanMethod("getOrdersForCoffeeById")).build());
    }
langecode commented 3 years ago

Thanks for your request. The plugin was very specifically tailored to be a thin wrapper around the functionality provided by the Swagger libraries. So I guess your use-case would call for another plugin possibly you could create something that could activate the runtime logic to generate the documentation at compile time - that is pretty much what the plugin does with Swagger.

kmozaid commented 3 years ago

Thank you for responding. The springdoc-openapi suggest to use spring-boot-maven-plugin which will basically start the app then another plugin springdoc-openapi-maven-plugin to pull the generated yaml from the server and copy it local build machine and then push to artifactory if needed. But the problem is, my microservice has very complex startup logic, for instance, it uses Hashicorp Vault with kubernetes authentication mechanism, so I can not start the app in build slave machine. This springdoc-openapi finds api paths from Spring Handler Mapping, I am not sure, Without app startup, How I can trigger the runtime logic provided by springdoc-openapi in a new plugin. Anyway I will look for an alternative. thanks again.