Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sumityadav29 opened this issue Sep 11, 2024 · 2 comments
Assignees
Labels
enhancement Improvement to an existing feature

Comments

@sumityadav29
Copy link

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:

  • OS & version: MacOS 14.3
  • Specmatic version: 2.0.17
  • JDK version: 21
@pranavgawri
Copy link
Contributor

Hi, @sumityadav29

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

@pranavgawri pranavgawri self-assigned this Nov 12, 2024
@pranavgawri pranavgawri added needs_verification Issue is to be verified and confirmed enhancement Improvement to an existing feature and removed needs_verification Issue is to be verified and confirmed labels Nov 12, 2024
@pranavgawri
Copy link
Contributor

Hi @sumityadav29,

I apologize for the delayed response on this issue. You're right - Specmatic currently doesn't support cookie parameters in API calls, even when specified as required in the OpenAPI spec.

I've marked this as an enhancement since this would be a valuable addition to our cookie parameter handling capabilities. We'll keep you posted on the progress through this issue.

Thank you for taking the time to report this with such clear examples, it really helped!

Thanks,
Pranav

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants