hapi-openapi icon indicating copy to clipboard operation
hapi-openapi copied to clipboard

On outputvalidation true, the invalid date-time value results in 500 Internal Server Error

Open openmohan opened this issue 6 years ago • 2 comments

With outputvalidation sets to true, if the response has data time field in it and has wrong type value, the entire result fails with 500 response code.

eg:

DataResponse - 
{
  name: "test", audit:{"created_at": "test"}
}

If the response schema is 
  DataResponse:
    type: object
    description: "stock model"
    properties:
      name:
        type: string
        description: "stock model"
        example: "XYZ"
      audit:
        $ref: '#/definitions/Audit'
    required:
    - name
    - audit
  Audit:
    type: object
    description: "audit on the stock view"
    properties:
      created_at: 
        title: Created At
        description: "when the object is created"
        type: string
        readOnly: true
        format: date-time

yo --version - 3.1.0

openmohan avatar Jul 20 '19 18:07 openmohan

What is the expected result? If server is validating response, and response is wrong, it is a server error.

tlivings avatar Oct 18 '19 15:10 tlivings

Actually the date is passed from request. And in that case it should throw 400 with proper error message, right?

openmohan avatar Oct 19 '19 16:10 openmohan