3

I am trying to validate an incoming XML payload via API gateway. To be specific, I actually don't even care about the schema, I just want to make sure that the body is not empty (and maybe that it is valid XML if I can get that functionality). I see a variety of posts from years ago stating that XML input validation is not yet supported in API Gateway.

Can somebody confirm if this is still the case? To provide a specific example, I have a model like this:

{
  "$schema" : "http://json-schema.org/draft-04/schema#",
  "title" : "Test Schema",
  "type" : "object",
  "minProperties": 1,
  "properties": {
      "account_id": {
        "type": "string",
        "pattern": "[A-Za-z]{6}[0-9]{6}"
      }
  },
  "required": ["account_id"]
}

If I add request body validation using this model for content type "application/json" all is well, but if I do the same for content type "application/xml" no validation is performed.

MrName
  • 2,363
  • 17
  • 31
  • At the risk of asking the obvious, are you actually setting a `Content-Type: application/xml` header in the request (in the client)? The actual content type is not sniffed by the service, and it's assumed to be `application/json` if the client sends no `Content-Type` header in the request. – Michael - sqlbot Jul 23 '18 at 22:34
  • Yes I am, thanks though, good call. – MrName Jul 23 '18 at 22:38
  • Hmmm... looking more closely at the docs, it looks like XML isn't supported, but hard to confirm. I guess that's why you're asking. :) – Michael - sqlbot Jul 23 '18 at 23:01
  • Lol yes, I don't see any mention of it in the docs. I can understand not being able to validate XML schema, but it seems like a pretty valid (and simple) use case (make sure the payload is not empty). – MrName Jul 24 '18 at 14:01
  • I think the answer here is that only json validation is supported via API Gateway and any other type of validation requires custom code, but will leave this open in case somebody else has good ideas. – MrName Jul 24 '18 at 15:18

1 Answers1

2

Yes APIGW only supports json payload validation.

Vishal
  • 635
  • 4
  • 9
  • Does that mean that e.g. `Content-Type: multipart/form-data` is not validated at all, although a valid schema definition exists? Why on earth don't you guys mention this in the docs? I spent hours trying to get this working... – Paul Michalik Mar 10 '19 at 12:11