2

I am trying the api gateway validation example from here https://github.com/rpgreen/apigateway-validation-demo . I observed that from the given swagger.json file, minItems is not imported into the models which got created during the swagger import.

"CreateOrders": {
  "title": "Create Orders Schema",
  "type": "array",
  "minItems" : 1,
  "items": {
    "type": "object",
    "$ref" : "#/definitions/Order"
  }
}

Because of this when you give an empty array [ ] as input, instead of throwing an error about minimum items in an array, the api responds with a message 'created orders successfully'.

When I manually add the same from the API gateway console UI, it seems to work as expected. Am i missing something or this is a bug in the importer?

srisaiswaroop
  • 195
  • 10

1 Answers1

2

This is a known issue with the Swagger import feature of API Gateway.

From http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html

The maxItems and minItems tags are not included in simple request validation. To work around this, update the model after import before doing validation.

MikeD at AWS
  • 3,565
  • 16
  • 15