znsio / specmatic

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

specmatic not sending Cookie in API calls even when it is a required param #1289

Open sumityadav29 opened 1 month ago

sumityadav29 commented 1 month ago

Description Specmatic does not send Cookie in the API calls even when it is a required parameter for the API. This leads to failure of API call and ultimately of the specmatic API contract test even when the implementation is actually respecting the contract

I suspect this is happening because of dynamic http headers being removed the request but I can be wrong

I have tried adding an example for the param like below but still no luck

        - name: session_id
           in: cookie
           required: true
           schema:
             type: string
           description: A required cookie parameter that contains the session ID.
           examples:
             syn_200:
               value: 1234

Steps to reproduce run specmatic contract test on an api spec which contains required Cookie param for a path

example opeanapi spec

openapi: 3.0.3
info:
  title: TODO API
  description: API to retrieve a list of TODO items, requiring a cookie for authentication.
  version: 1.0.0
paths:
  /todos:
    get:
      summary: Get a list of TODO items
      description: Retrieves a list of TODO items. Requires a valid session cookie for authentication.
      parameters:
        - name: session_id
          in: cookie
          required: true
          schema:
            type: string
          description: A required cookie parameter that contains the session ID.
      responses:
        '200':
          description: A list of TODO items
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                    title:
                      type: string
                    completed:
                      type: boolean
              examples:
                example-success:
                  summary: Successful TODO list retrieval
                  value:
                    - id: 1
                      title: "Buy groceries"
                      completed: false
                    - id: 2
                      title: "Pay utility bills"
                      completed: true

Expected behavior I am expecting the Cookie param to be sent in the API call just like query and path params

System Information:

pranavgawri commented 1 month ago

Hi, @sumityadav29

Thanks for sharing the details, we will check and get back to you asap.