Class DoppelgangerApiFinder

java.lang.Object
com.arc_e_tect.gradle.doppelganger.detect.DoppelgangerApiFinder

public class DoppelgangerApiFinder extends Object
Determines which endpoints are both declared in the OpenAPI documentation and implemented by a @RestController method, but have no matching verification evidence from any configured ContractVerificationSource - i.e. which endpoints are "doppelganger APIs".

This does not delegate to api-detector-core's ContractSetOperations.difference(...), even though both sides are List<Endpoint>: SpringCloudContractScanner produces genuinely concrete, resolved paths (e.g. "/items/1", taken from a contract's own example request), not templates - unlike the paths ControllerScanner, OpenApiEndpointCollector, RestDocsScanner, and OpenApiRequestValidatorScanner all produce, which are always templates. ContractSetOperations' shared matching requires both sides to be templates with aligned placeholders, so it would never recognise a Spring Cloud Contract example for "/items/{id}" as verifying it. This class instead matches candidates against verified entries directly via PathMatcher.matchesConcrete(String, String), which accepts a concrete path on one side and a template on the other - the comparison Prompt 3 anticipated wouldn't always "line up cleanly" through the shared generic operation.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new DoppelgangerApiFinder.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<com.arc_e_tect.gradle.detector.core.model.Endpoint>
    findDoppelgangers(List<com.arc_e_tect.gradle.detector.core.model.Endpoint> declaredAndImplemented, List<com.arc_e_tect.gradle.detector.core.model.Endpoint> verified)
    Returns every endpoint in declaredAndImplemented that has no matching entry in verified.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DoppelgangerApiFinder

      public DoppelgangerApiFinder()
      Creates a new DoppelgangerApiFinder.
  • Method Details

    • findDoppelgangers

      public List<com.arc_e_tect.gradle.detector.core.model.Endpoint> findDoppelgangers(List<com.arc_e_tect.gradle.detector.core.model.Endpoint> declaredAndImplemented, List<com.arc_e_tect.gradle.detector.core.model.Endpoint> verified)
      Returns every endpoint in declaredAndImplemented that has no matching entry in verified.
      Parameters:
      declaredAndImplemented - endpoints both declared in the OpenAPI documentation and implemented by a @RestController method
      verified - endpoints with verification evidence from any enabled ContractVerificationSource
      Returns:
      the endpoints with no verification evidence, in the order they were passed in