prism
prism copied to clipboard
Enum example is not picked up as mock response
Describe the bug
When defining an example value for an enum, the mock server will still return the first item in the ENUM as response.
To Reproduce
- Given this OpenAPI document
openapi: 3.0.3
tags:
- name: Example
description: Example
info:
title: Example enum response
contact:
name: Example
description: >-
Example
version: '1'
servers:
- url: http://localhost
description: localhost
paths:
'/enum':
get:
tags:
- Example
description: >-
get Enum
operationId: getEnum
responses:
'200':
description: enum
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum:
- FAILURE
- SUCCESS
example: SUCCESS
- Run this CLI command
prism mock openApi.yaml
- See result
The endpoint
/enum
returns status: FAILURE
Expected behavior
As the example: SUCCESS
is added to the document i expect this value of the enum to be returned.
Additional context
editor.swagger.io does pick up the specified example value instead of the first value of the enum
Environment (remove any that are not applicable):
- Library version: 4.5.0
For now, we recommend the work-around of re-ordering enums to place the desired static mock response first, but we've got this on our radar!