specmatic icon indicating copy to clipboard operation
specmatic copied to clipboard

The named examples are not being picked up correctly when there is no response example for 204 responses.

Open yogeshnikam671 opened this issue 10 months ago • 0 comments

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

  1. 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 
  1. Run contract test using specmatic
  2. 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

yogeshnikam671 avatar Apr 12 '24 10:04 yogeshnikam671