Prism mocks of strings with format: duration
are sometimes malformed, causing validation errors at random #2650
Description
Current Behavior
Prism-generated dynamic mock responses of type: string
and format: duration
randomly produce non-valid duration strings such as "P725387655M58009976655DT"
and "P"
, resulting in errors. Rerunning the same GET call produces errors unpredictably.
Expected Behavior
A dynamic response of format: duration
should always pass validation.
Steps to Reproduce
- Snippet from my valid API definition for GET response:
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
min:
type: string
format: duration
max:
type: string
format: duration
average:
type: string
format: duration
total:
type: string
format: duration
- Prism-mocked response body and error (first run):
{
"average": "P1038276829W",
"max": "P725387655M58009976655DT",
"min": "P1629484W",
"total": "P960507355Y99894M87085DT9121M"
}
[VALIDATOR] ✖ error Violation: response.body.max Response body property max must match format "duration"
3. Prism-mocked response body and error (second run, same query parameters):
{
"average": "P",
"max": "P",
"min": "P718W",
"total": "P"
}
[VALIDATOR] ✖ error Violation: response.body.max Response body property max must match format "duration"
[VALIDATOR] ✖ error Violation: response.body.average Response body property average must match format "duration"
[VALIDATOR] ✖ error Violation: response.body.total Response body property total must match format "duration"
Environment
- Version used: 5.12.0
- Environment name and version (e.g. Chrome 39, node.js 5.4): Node 22.7.0
- Operating System and version (desktop or mobile): macOS Sonoma