Niels Bertram created CXF-7637:
----------------------------------
Summary: Using SwaggerToOpenApiConversionFilter with JAXRS
extension mappings will never engage the filter
Key: CXF-7637
URL: https://issues.apache.org/jira/browse/CXF-7637
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 3.2.1
Reporter: Niels Bertram
Using the {{SwaggerToOpenApiConversionFilter}} with
{{JAXRSServerFactoryBean.setExtensionMappings()}} will stop the filter from
executing even if the correct path is called. I think this is caused by the
filter calling
[reqCtx.getUriInfo().getPath()|https://github.com/apache/cxf/blob/9f727a9e1cbc5df87b752a3b7aa4bca94357e613/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/openapi/SwaggerToOpenApiConversionFilter.java#L45]
which when extension mapping is enabled, will strip off the {{.json}} or any
other extensions and then set the path to {{openapi}} only, which does not
match the hard coded value {{openapi.json}}.
Not sure but looks to me that it is probably not a bad idea to strip the
extension (i.e. json, yml, yaml etc.) off the path and then compare just
{{openapi}}.
Basic configuration that should trigger this bug.
{code:java}
@Bean
public Server rsServer(JacksonJsonProvider jsonProvider) {
JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
// enable the use of .json, .yaml or .xml extensions on the resource path
endpoint.setExtensionMappings(new HashMap<Object, Object>() {{
put("json", "application/json");
put("yml", "application/yaml");
put("yaml", "application/yaml");
put("xml", "application/xml");
}});
endpoint.setProvider(openApiConversionFilter());
...
return endpoint.create();
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)