Instance value (null) not found in enum

Issue #209 new
Geoffrey Wiseman created an issue

Trying out swagger-request-validator and I’m getting:

{ 
  "messages" : [ {
    "key" : "validation.request.body.schema.allOf",
    "level" : "ERROR",
    "message" : "Instance failed to match all required schemas (matched only 0 out of 2)",
    "additionalInfo" : [ "/allOf/0: Instance type (null) does not match any allowed primitive type (allowed: [\"string\"])", "/allOf/0: Instance value (null) not found in enum (possible values: [\"TWENTY_PAY\",\"LIFE_PAY\"])", "/allOf/0: Instance type (null) does not match any allowed primitive type (allowed: [\"string\"])", "/allOf/1: Instance type (null) does not match any allowed primitive type (allowed: [\"object\"])" ],
    "context" : {
      "requestPath" : "/quotes",
      "apiRequestContentType" : "application/json",
      "location" : "REQUEST",
      "requestMethod" : "POST"
    }
  } ]
}

I've got an OpenAPI spec, the request has an enum, the property isn’t required … so why is swagger-request-validator complaining about a null?

Comments (7)

  1. Geoffrey Wiseman reporter

    FWIW, I’m working around this for now by customizing Jackson within RestAssured to not submit properties (inclusion set to ignore nulls), in case anyone else hits this and there isn’t a validator solution yet.

  2. Geoffrey Wiseman reporter

    Yeah, I think we moved to OAS 3 and added nullability since then; not sure what the right move would be in OAS 2, given that it’s a vendor extension?

  3. Log in to comment