azure api management (apim) schema validation case sensitive

61 views Asked by At

I am currently using validate-content to validate the request body against api spec. when I set action="prevent" and allow-additional-properties="false", it is returns error when I pass property name with a different case in the request body. What can I do to ignore the case?

I tried to set action to detect and go through the error list detect but did not work

1

There are 1 answers

3
Ikhtesam Afrin On

AFAIK, validate-content validates the definition of the schema including the case of properties and types.

You can ignore the case of the property by using action="detect" which will not interrupt request or response processing but you will get the error message in Trace.

I have used the below policy-

<validate-content  unspecified-content-type-action="prevent"  max-size="102400"  size-exceeded-action="prevent"  errors-variable-name="requestBodyValidation"> 
<content  type="application/json"  validate-as="json"  action="detect"  schema-id="myschema"  allow-additional-properties="false"  />  
</validate-content>

In my schema, property name is in small case but while testing I am passing below request body.

{
"Name": "Afreen"
}

I am getting 200 OK result.

enter image description here

But you can see the detail execution of validate-content in trace.

enter image description here

References- .net - Azure APIM Validate-Content Inbound policy, Validate Request Body - Stack Overflow.