You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide an OpenAPI file which contains error in the schema.
Run prism as validation proxy, it is unable to report the error in the schema, and request/response validation always pass.
Current Behavior
No error reported. No matter the request/response violates the schema or not. All errors are silently hidden.
Expected Behavior
It should report that the OpenAPI schema is invalid.
Steps to Reproduce
Save the below OpenAPI which contains typo into file openapi.yaml
Start a local server to serve the API (see code below). The server response violates the schema.
Run Prism: prism proxy openapi.yaml http://localhost:8023
Use any HTTP client to send a request: GET http://127.0.0.1:4010/car/1
No error reported. Actually there are two mistakes:
OpenAPI schema invalid
Response message violates schema
openapi: 3.0.0info:version: 1.0.0title: Test APIservers:- url: /test/v1paths:/car/{id}:get:parameters:- name: idin: pathrequired: trueschema:type: stringresponses:
'200':description: OKcontent:application/json:schema:$ref: '#/components/schemas/Car'components:schemas:Car:type: obj # <-- typo, should be "object"required:- wheelsproperties:wheels:type: number
@aleung Thank you for reporting this! We agree that not swallowing this error for AJV would be ideal.
Here's the solution we propose:
instead of catching the error, log out a warning message about the invalid schema but proceed as it does today
We would gladly accept a PR that implements the proposed solution above.
In the meantime, you could use Spectral to validate your spec before starting up Prism with it. That would tell you if your entire spec is valid before using it.
Context
Provide an OpenAPI file which contains error in the schema.
Run prism as validation proxy, it is unable to report the error in the schema, and request/response validation always pass.
Current Behavior
No error reported. No matter the request/response violates the schema or not. All errors are silently hidden.
Expected Behavior
It should report that the OpenAPI schema is invalid.
Steps to Reproduce
openapi.yaml
prism proxy openapi.yaml http://localhost:8023
GET http://127.0.0.1:4010/car/1
Environment
Analysis
prism/packages/http/src/validator/validators/utils.ts
Line 140 in a1360b3
In the validation function Avj throw an error about invalid schema. But
tryCatch
just ignore it and not being converted to an error.The text was updated successfully, but these errors were encountered: