redoc icon indicating copy to clipboard operation
redoc copied to clipboard

Pattern properties do not load external $refs

Open tfedor opened this issue 2 years ago • 3 comments

Describe the bug Pattern properties do not load external $refs, it seems to work if the $refs are local, but I didn't properly test it

Expected behavior $refs should properly load external files

Minimal reproducible OpenAPI snippet(if possible) test.yaml

openapi: 3.1.0
info:
  title: "Example"
  version: "1.0"
  description: "Example"
paths:
  "/test/":
    get:
      summary: Example
      responses:
        200:
          description: List of shops and their details
          content:
            "application/json":
              schema:
                type: object
                properties:
                  "working":
                    $ref: "testobj.yaml"
                patternProperties:
                  "not-working":
                    $ref: "testobj.yaml"

testobj.yaml

type: object
properties:
  key:
    type: number

Screenshots image

tfedor avatar Aug 17 '23 22:08 tfedor

Just ran into this myself. All other $ref's are properly bundled, but every $ref inside patternProperties is not resolved and left as is, leading to an any type.

uncaught avatar Aug 22 '23 08:08 uncaught

Thanks for the issue and explanation @tfedor. I had a quick look at it and it's not clear to me what's technically correct here. OpenAPI supports $refs in quite specific limited locations, but JSON Schema would probably think this was valid, and Redoc will typically attempt to resolve whatever you give it. Moving the references into the same file produces what I think you were expecting (example attached). openapi.yaml.txt

lornajane avatar Aug 22 '23 08:08 lornajane