Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7637

Using SwaggerToOpenApiConversionFilter with JAXRS extension mappings will never engage the filter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2.1
    • 3.2.2, 3.1.15
    • JAX-RS
    • None
    • Unknown

    Description

      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() 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.

        @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();
        }
      

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            niels.bertram Niels Bertram
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: