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

Response validation incorrectly fails for `undefined` values for additionalProperties

Open ghost91- opened this issue 2 years ago • 0 comments

Describe the bug When using a schema that has additionalProperties set to some type, and when then returning an object that has an additional property set to undefined, the response validation fails. Instead, it should ignore the undefined values, because they will be filtered out when serializing the response to JSON.

To Reproduce Steps to reproduce the behavior.

  • Create an OpenAPI spec that has some response with
    additionalProperties:
      type: string
    
  • Activate response validation
  • Return an object that has an additional property set to undefined

Actual behavior undefined values make validation of additionalProperties fail

Expected behavior undefined values are ignored for validation additionalProperties in response validation

ghost91- avatar Jul 12 '23 15:07 ghost91-