Skip to content

Conversation

@TiPo4u4eK
Copy link

Support for static resources

@bnasslahsen
Copy link
Collaborator

@TiPo4u4eK,

Could you please provide a more detailed description of the feature you’ve added?
Additionally, the MVC implementation is required for feature parity when it;'s possible—please include it as well.

@TiPo4u4eK
Copy link
Author

TiPo4u4eK commented Nov 3, 2025

Sure, @bnasslahsen

This feature enables support for serving resources, making it possible to expose them through OpenAPI documentation. In the current SpringDoc implementation, using RouterFunction and RouterOperation for routing and documenting endpoints requires special handling. Without necessary adjustments to RouterFunctionVisitor, attempting to access the OpenAPI documentation would fail. This is required feature because many organizations enforce the explicit use of RouterOperation when defining routes with RouterFunction.

For example, I used ClassPathResource to serve icons, which then process with ResourcesRouterFunction for handling of resources.

I don't think MVC requires any updates. Resources are commonly served through the ResourceHandlerRegistry in a configuration class, like so:

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/icons/**")
                .addResourceLocations("classpath:/icons/")
                .setCachePeriod(3600);
    }
}

To include such resource handling in documentation, the most common approach is to use a custom io.swagger.v3.oas.models.OpenAPI. There may be other ways, but this is the most common way I've seen to provide resources in OpenAPI documentation.

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

Successfully merging this pull request may close these issues.

2 participants