swagger-ui
swagger-ui copied to clipboard
Supplying a malformed JSON payload correctly returns a "SyntaxError: Unexpected token" but it is returned as a 200 status code.
Swagger-ui version: 2.2.8
/reports/generate/{templateName}:
post:
summary: Combine provided data with the specified markup template to generate a complete report and optionally create and store as a PDF attachment in Salesforce.
description: Generates a complete report using the specified template and returns the completed markup. Will also create and store PDF attachment in Salesforce if employeeId and sfId (CAD SF ID) are specified.
parameters:
- name: templateName
in: path
description: The name of the desired template.
required: true
type: string
- name: data
in: body
description: The data payload required to generate a report using the desired template.
required: true
schema:
type: object
properties:
employeeId:
type: string
sfId:
type: string
reportName:
type: string
reportData:
type: object
If you supply a random string for the body (data) the response body correctly contains the parsing error SyntaxError: Unexpected token but the status code is 200.

Similarly, if you supply an empty JSON payload it correctly says ValidationError: "data" is required but again the response code is 200.

Can you try the latest version?
Updating swagger-ui to 3.0.16 did not solve the issue.
Nevermind I'm dumb. My error route handler in express wasn't reading the status code from the error given back.