Request validation fails if there are multiple servers in the specification with different path

Issue #385 new
Szabolcs Stremler created an issue

If the specification contains multiple servers and the path of the servers are different, then the request which is sent to the second server fails. The validator always takes the path of the first server.

servers:
  - url: 'https://test.com/path'
  - url: 'https://test.com/alternative-path'

Only the first test passes.

    @Test
    public void validate_withTheFirstServer_shouldSucceed() {
        final Request request = SimpleRequest.Builder
                .get("/path/users")
                .build();

        assertPass(classUnderTest.validateRequest(request));
    }

    @Test
    public void validate_withTheSecondServer_shouldSucceed() {
        final Request request = SimpleRequest.Builder
                .get("/alternative-path/users")
                .build();

        assertPass(classUnderTest.validateRequest(request));
    }
{
    "key" : "validation.request.path.missing",
    "level" : "ERROR",
    "message" : "No API path found that matches request '/alternative-path/users'.",
    "context" : {
      "requestPath" : "/alternative-path/users",
      "requestMethod" : "GET"
    }
}

https://bitbucket.org/strsz/swagger-request-validator/commits/8c39726cfcd56ce2efe396be9d0751ac8c8a402e

Comments (1)

  1. Log in to comment