Skip to content

Nested $refs in OpenApi definitions silently fail to be resolved #94

@s-o-r-o-u-s-h

Description

@s-o-r-o-u-s-h

Description

When a response schema resolves through a chain of $refs, the generated handler
returns an empty string as the response body. No error is thrown and the status
code is still 200 — the body is just "". It happens with both msw/node and msw/browser servers.

Reproduction steps

Check out the following repository that reproduces the issue:
https://github.com/s-o-r-o-u-s-h/msw-source-issue

Expected behavior

It either needs to throw an error indicating that chaining multiple $refs is not supported or should resolve them recursively.

Initial assessment

I guess somewhere inside of src/open-api/utils/dereference.ts after line 21 should change to check if resolving a $ref will point to another $ref or not instead of hastily using pointerToPath(), but I'm not sure. I might be wrong.

Setup

  • Node: v24.16.0
  • @msw/source: 0.6.1
  • msw: 2.14.6
  • OS: Ubuntu 26.04 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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