Class OpenApiServerBasePath

java.lang.Object
com.arc_e_tect.gradle.doppelganger.scan.OpenApiServerBasePath

public final class OpenApiServerBasePath extends Object
Resolves the path portion of an OpenAPI root document's first servers[].url entry, e.g. servers: [{url: "http://localhost:9011/crm-service"}] resolves to "/crm-service".

A verification source that captures the literal path used against a real, running server (as opposed to one relative to a controller's own @RequestMapping, such as a REST Assured request built with RestAssured.basePath cleared) naturally includes this server-url path - typically a reverse-proxy or servlet context path - in what it captures, even though neither the OpenAPI paths: keys nor the @RestController mappings themselves ever declare it. RestDocsScanner strips it, when configured, before comparing captured paths against declared-and-implemented endpoints.

  • Method Details

    • resolve

      public static String resolve(File rootDocument)
      Resolves rootDocument's first server URL's path component, normalised via PathTemplates.normalize(String).
      Parameters:
      rootDocument - the root OpenAPI document
      Returns:
      the normalised base path (e.g. "/crm-service"), or "" when the document declares no servers, the first server's URL has a blank or root path, or the document cannot be parsed