specmatic
specmatic copied to clipboard
The named examples are not being picked up correctly when there is no response example for 204 responses.
Description
When specifying 204 status code in OpenAPI spec, we do not specify the response schema/example since 204 always returns No-content
as the response.
Although, we can specify the request example.
Expected behavior I would want specmatic to make use of the request example while running the contract test.
Actual behaviour Specmatic does not make use of the request example and generates random values for the contract test.
Steps to reproduce
- Implement a simple API which returns 204 and adheres to following schema -
openapi: 3.0.3
info:
title: My service
description: My service
version: 1.0.0
servers:
- url: 'https://localhost:8080'
paths:
/api/nocontent:
post:
requestBody:
content:
application/json:
schema:
type: string
examples:
204_OK:
value: "hibob"
responses:
204:
description: No content
- Run contract test using specmatic
- Observe that, the value "hibob" is not getting used by specmatic while hitting this endpoint during the contract test.
System Information:
- Specmatic version: 1.3.10
- JDK version: 17