Skip to content

Linter reports duplicate parameters when multi-referencing path items #2829

@onavratil-monetplus

Description

@onavratil-monetplus

Describe the bug

The linter reports

Operations must have unique `name` + `in` parameters. Repeats of `in:header` + `name:x-duplicate`.

even though there is no conflict

To Reproduce

Given this yaml

openapi: 3.1.0
info:
  title: Sample API
  version: 0.0.1
  contact:
    email: onavratil@monetplus.cz
  description: mock
  license:
    name: Proprietary
    identifier: proprietary
servers:
  - url: '{address}'
    description: | 
      Local development server
    variables:
      address:
        default: 'http://localhost:8080'
        description: 'Server address'
security: []
tags:
  - name: test
    description: test.
paths:
  /sample:
    get:
      summary: sample
      description: Sample desc
      operationId: opId
      tags:
        - test
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  sample:
                    type: string
        4XX:
          description: FAIL
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
      callbacks:
        test:
          'some-uri':
            $ref: '#/components/pathItems/test-pi'
        test2:
          'some-uri-2':
            $ref: '#/components/pathItems/test-pi'
components:
  pathItems:
    test-pi:
      post:
        summary: test
        description: XYZ
        operationId: test23
        parameters: 
          - name: x-duplicate
            in: header
            required: true
            schema:
              type: string

Note that there are multiple references of the pathItem in callback. I have a common "pathItem component for notification callbacks" that report some event and i use it in multiple /paths in the callback. In the example above, i put two webhooks under one /path just for simplicity, but the behavior is the same.

The linter evaluates this as duplicate parameter, although there are in separate webhooks:

$ redocly lint api.yaml 
No configurations were provided -- using built in recommended configuration by default.

validating api.yaml...
[1] api.yaml:26:7 at #/paths/~1sample/get/parameters/0

Operations must have unique `name` + `in` parameters. Repeats of `in:header` + `name:x-duplicate`.

24 |   /sample:
25 |     get:
26 |       summary: sample
27 |       description: Sample desc
 … |       < 28 more lines >
56 |             $ref: '#/components/pathItems/test-pi'
57 | components:
58 |   pathItems:

Error was generated by the operation-parameters-unique rule.


api.yaml: validated in 37ms

❌ Validation failed with 1 error.
run `redocly lint --generate-ignore-file` to add all problems to the ignore file.

Expected behavior

Api passes linter

Redocly version(s)

$ redocly --version
2.31.3

Node.js version(s)

$ node --version
v25.5.0

Additional context

I guess it relates to this file

import type { UserContext } from '../../walk.js';

Note that I tried to reproduce this without using path item references, but failed. The bug must somehow related to the path item being referenced - perhaps the walk function then does not invoke enter on multiple occurances of the same ref

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't workingp3

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions