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

PUT doesn't handle env variables as parameters #151

Open
promahos opened this issue Feb 4, 2025 · 1 comment
Open

PUT doesn't handle env variables as parameters #151

promahos opened this issue Feb 4, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@promahos
Copy link

promahos commented Feb 4, 2025

Describe the bug
When parameter is set with all section in a ref data file and filled with env variable, it's not resolved for PUT operation.
Example of ref data:

all:
  id: $$NEW_ID

where NEW_ID was set to "1"

And path like /Brand/{id}

will result in .../Brand/1 for GET (which is expected),
but in .../Brand/$$NEW_ID for PUT (which is not expected).

To Reproduce

  1. Reference data file "reference.yml" :
all:
  id: $$NEW_ID
  1. Set $$NEW_ID as env variable, define its value
  2. Run cats --contract=${CONTRACT_URL} --server=${SERVER_URL} --httpMethods=GET,PUT --refData="reference.yml" setting

Expected behaviour
Env variable is replaced by it's value for PUT request.

Environment:

Key Value
OS Name Mac OS X
OS Version 14.6
OS Arch amd64
Binary Type native
Cats Version 13.1.0
Cats Build 2025-01-17T06:37:06Z
Term Width 211
Term Type xterm-256color
Shell /bin/zsh

Example of OpenApi:

openapi: 3.0.0
info:
  title: Brand API
  version: "1.0.0"

paths:
  /Brand/{id}:
    get:
      summary: Retrieve a brand by ID
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: A brand object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Brand'
        '404':
          description: Brand not found

    put:
      summary: Update a brand by ID
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Brand'
      responses:
        '200':
          description: Updated brand object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Brand'
        '400':
          description: Invalid input

components:
  schemas:
    Brand:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
      required:
        - id
        - name
@promahos promahos added the bug Something isn't working label Feb 4, 2025
@en-milie
Copy link
Contributor

en-milie commented Feb 6, 2025

Hi @promahos. Thank you for reporting this. It's fixed now and will be available in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants