Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-4181

Fix API Breakage: Workaround for OpenAPI Generator v7.17.0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • None
    • swatch-api, swatch-tally
    • False
    • Hide

      None

      Show
      None
    • False
    • Impediment
    • subs-swatch-lightning

      A configuration workaround needs to be implemented to fix a broken code-generation tool update (v7.16.0 to v7.17.0), which unintentionally caused API code to be generated incorrectly, requiring only regression testing to verify the solution.

       

      Fix bump org.openapitools:openapi-generator-maven-plugin from 7.16.0 to 7.17.0

      In https://github.com/RedHatInsights/rhsm-subscriptions/pull/5155, it bumped the openapi Maven plugin version to use 7.17.0 which includes the following breaking change:

      • in 7.16.0, the "@Path" annotation was at class level:
      @Path("/v1/opt-in")
      public interface OptInApi {
          @DELETE
          @Path("/v1/opt-in")
          void deleteOptInConfig();
          
          @GET  
          @Path("/v1/opt-in")
          OptInConfig getOptInConfig();
      }
      
      • in 7.17.0, this annotation is now at method levels:
      public interface OptInApi {
          @DELETE
          @Path("/v1/opt-in")
          void deleteOptInConfig();
          
          @GET
          @Path("/v1/opt-in") 
          OptInConfig getOptInConfig();
      }
      

      This breaking change was introduced in commit 808d106e0c6 "[jaxrs] Support jackson option (true by default)" which I think it was not intentional. I reported the issue by https://github.com/OpenAPITools/openapi-generator/issues/22279.

      Solutions

      Using "<interfaceOnly>false</interfaceOnly>" seems to be causing many more problems. Another solution could be to declare the API like:

      @Component
      @ApplicationPath("/api/rhsm-subscriptions")
      public class JaxrsApplication extends Application {
        
        @Override
        public Set<Class<?>> getClasses() {
          Set<Class<?>> classes = new HashSet<>();
          // Recursos que implementan APIs generadas
          classes.add(OptInResource.class);
          classes.add(InstancesResource.class);
          classes.add(TallyResource.class);
          classes.add(InternalTallyResource.class);
          classes.add(VersionResource.class);
          classes.add(OpenApiResource.class);
          classes.add(InternalTallyApiResource.class);
          return classes;
        }
      }
      

      The above is just an idea, it's untested and it needs to take into account the "api" and "worker" profiles.

      Acceptance Criteria

      • Configure the generated API using the latest released OpenApi Maven generator.
      • Verify whether the conduit service also needs the changes to use the latest OpenApi Maven generator.
      • About testing, this should be only regression testing.

              Unassigned Unassigned
              jcarvaja@redhat.com Jose Carvajal Hilario
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: