znsio / specmatic

Turn your contracts into executable specifications. Contract Driven Development - Collaboratively Design & Independently Deploy MicroServices & MicroFrontends.
https://specmatic.io
MIT License
275 stars 51 forks source link

Match example content types to spec media types #1269

Closed joelrosario closed 3 weeks ago

joelrosario commented 3 weeks ago

What:

Given a spec like the following:

openapi: 3.0.3
info:
  title: Simple API
  version: 1.0.0
paths:
  /:
    post:
      summary: Simple POST endpoint
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - field
              properties:
                field:
                  type: string
          application/merge-patch+json:
            schema:
              type: object
              required:
                - different
              properties:
                different:
                  type: string
      responses:
        '200':
          description: A simple string response
          content:
            application/json:
              schema:
                type: object
                required:
                  - field
                properties:
                  field:
                    type: string
            application/merge-patch+json:
              schema:
                type: object
                required:
                  - different
                properties:
                  different:
                    type: string

...having multiple response media types within the same status code, if the example has Content-Type headers in request and response, they should be matched and loaded in the scenarios for the specific request-response media type combination.

How:

Checklist: