express-openapi-validator icon indicating copy to clipboard operation
express-openapi-validator copied to clipboard

Array validation incorrect

Open elliotdickison opened this issue 4 years ago • 0 comments

Describe the bug This is accepted as valid spec and will allow any array:

schema: {
  type: "array",
  additionalProperties: true,
},

To Reproduce Load up an OpenAPI spec containing the above schema and set validateApiSpec to true.

Actual behavior express-openapi-validator accepts the spec as valid

Expected behavior express-openapi-validator should throw with an invalid spec error

Examples and context The official OpenAPI spec indicates that an items property is required for arrays and does not mention an additionalProperties field. The correct equivalent of the schema above might be something like:

schema: {
  type: "array",
  items: {
    type: "object",
    additionalProperties: true,
  },
},

P.S. Love this library, it's been awesome to work with!

elliotdickison avatar Aug 02 '21 21:08 elliotdickison