Skip to content

OAS: External references in path items are broken #3030

Open
@ben-lc

Description

@ben-lc

Expected Behavior

An external reference can be used on a path item with $ref key as specified in openapi 2+ specs :
Allows for a referenced definition of this path item. The referenced structure MUST be in the form of a Path Item Object. In case a Path Item Object field appears both in the defined object and the referenced object, the behavior is undefined. See the rules for resolving Relative References.
Adding an external reference should throw no error if it references a valid path item and should be handled by apicurio dereferencer.

Actual Behavior

In source mode an issue is thrown Path Item Reference must refer to a valid Path Item Definition . When preview or export with dereferencement is done an error is thrown.

Steps to Reproduce the Problem

  1. open an openapi spec
  2. in source mode add for example
paths:
    /stuffs:
        $ref: >-
            https://raw.githubusercontent.com/Apicurio/apicurio-data-models/refs/heads/1.x/src/test/resources/fixtures/dereference/oai3/domino-issue-1366.expected.json#/paths/~1addresslookup

  1. save the doc
  2. try to preview the spec

Specifications

  • apicurio studio: 0.2.62.Final
  • apicurio data models: 1.1.30

Cause

The referenced path item node can't be fetched because / must be unescaped from ~1 to get correct path item key . (see Apicurio/apicurio-data-models#858).

The second error during dereference is because the Dereferencer class in apicurio-data-models doesn't implement path item case. It tries to add the referenced node into components and then change originel external ref to an internal one. But path items can't be defined in components. The referenced node is supposed to be "merged" according the spec.

Proposed fix

I can write a PR to fix the second issue. I propose to do a simple non recursive merge of the external path item properties into the internal one and ignore external path item properties if they are already defined in internal path item (since spec says In case a Path Item Object field appears both in the defined object and the referenced object, the behavior is undefined).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions