Getting error while trying to validate the header against oas policy

When I'm trying to validate the request content against the oas policy by passing the required header named X-My-Header which is an type of array, there were no errors when I sent one value in that header but whenever I'm trying to send multiple values in it Teja_0-1675767130076.png
Getting error like this:

 

"OASValidation OpenAPI-Spec-Validation-1 with resource \"oas://OpenAPI-Spec-Validation-1.yaml\": failed with reason: \"[ERROR - Parameter 'X-My-Header' expected an array style of 'simple' [explode=false].: []]\""

 

I got to know that for headers default serialization method is simple style with 

explode=false which means comma-separated values But even when Im sending in that way also getting error


Here is the spec parameter part: (using spec version 3.0.1)

 

X-My-Header:
      name: X-My-Header
      in: header
      description: test
      required: true
      schema:
        type: array
        items:
          type: number
          enum: 
            - 1
            - 2

 

 Please help me here. Thanks in advance

2 4 622
4 REPLIES 4

I'm sending in the same format only which u mentioned but still getting the same error from OAS policy.

Teja_0-1676266974840.png

 

Hello @kurtkanaskie@dchiesa1 I have the same issue as well, is there an issue with this function? any help is appreciated.

I just tested this using your exact parameter in my Apigee X org and it's working as expected ("runtimeVersion": "1-11-0-apigee-8").

curl "https://$HOST/oas/v3/persons?required=ok" --header 'x-my-header: 2'
OK

curl "https://$HOST/oas/v3/persons?required=ok" --header 'x-my-header: 3'
{
  "fault": {
    "faultstring": "OASValidation OAS-ValidateRequestYAML with resource \"oas://persons_oas_v3.yaml\": failed with reason: \"[ERROR - Instance value (3) not found in enum (possible values: [1,2]): []]\"",
    "detail": {
      "errorcode": "steps.oasvalidation.Failed"
    }
  }
}

 

@Teja Did you try setting explode property to true ? 

X-My-Header:
      name: X-My-Header
      in: header
      description: test
      required: true
      style: simple
      explode: true
      schema:
        type: array
        items:
          type: number
          enum: 
            - 1
            - 2