Class RestDocsScanner
java.lang.Object
com.arc_e_tect.gradle.doppelganger.scan.RestDocsScanner
- All Implemented Interfaces:
ContractVerificationSource
ContractVerificationSource for Spring RestDocs, recognising two independent call-chain
shapes for the same underlying convention - a request-builder call paired with a
document(...) call somewhere in the same method body:
spring-restdocs-mockmvc:mockMvc.perform(get(...)/post(...)/put(...)/ delete(...)/patch(...))together with.andDo(document(...)).spring-restdocs-restassured:given(...).filter(document(...))... when().get(...)/post(...)/put(...)/delete(...)/patch(...)- the verb call directly scoped on a call namedwhen.
Matches by simple method name only, the same way ControllerScanner matches mapping
annotations by simple name, so this scanner needs neither Spring MVC Test, Spring RestDocs, nor
REST Assured on its own classpath.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newRestDocsScannerthat strips no base path from captured paths.RestDocsScanner(String basePathToStrip) Creates a newRestDocsScannerthat stripsbasePathToStrip- typically resolved viaOpenApiServerBasePath.resolve(java.io.File)- from the leading segments of every path it captures, when present. -
Method Summary
-
Constructor Details
-
RestDocsScanner
public RestDocsScanner()Creates a newRestDocsScannerthat strips no base path from captured paths. -
RestDocsScanner
Creates a newRestDocsScannerthat stripsbasePathToStrip- typically resolved viaOpenApiServerBasePath.resolve(java.io.File)- from the leading segments of every path it captures, when present. A REST Assured request built against a running server naturally includes this server-url path (e.g. a servlet context path) in the literal path it captures, even though neither the OpenAPI documentation nor the@RestControllermapping it verifies ever declares it.- Parameters:
basePathToStrip- the base path to strip, e.g."/crm-service"; blank ornulldisables stripping
-
-
Method Details
-
scan
public List<com.arc_e_tect.gradle.detector.core.model.Endpoint> scan(File rootDir) throws IOException ScansrootDirrecursively and returns every endpoint this source found verification evidence for.The returned
Endpoint.declaringClass()andEndpoint.methodSignature()identify the test (or contract file) that supplied the evidence, not a production@RestController.- Specified by:
scanin interfaceContractVerificationSource- Parameters:
rootDir- the directory to scan recursively; scanning a non-existent or non-directory path returns an empty list rather than failing- Returns:
- possibly-empty list of verified endpoints, never
null - Throws:
IOException- if a file underrootDircannot be read
-