question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recursive external $ref gets resolved to itself when `bundle`

See original GitHub issue

Input:

openapi: 3.0.2
info:
  version: 1.0.0
  title: Reproduction sample
  description: OpenAPI sample that exposes the problem
paths:
  /:
    get:
      description: get
      responses:
        default:
          description: response
          content: {}
components:
  schemas:
    Link:
      $ref: https://json-schema.org/draft-04/hyper-schema#/definitions/linkDescription

Code:

const parser = new JsonSchemaRefParser();
const spec = await parser.bundle(spec);

Output:

openapi: 3.0.2
info:
  version: 1.0.0
  title: Reproduction sample
  description: OpenAPI sample that exposes the problem
paths:
  "/":
    get:
      description: get
      responses:
        default:
          description: response
          content: {}
components:
  schemas:
    Link: # see bellow
      "$ref": "#/components/schemas/Link/properties/schema/properties/not/definitions/linkDescription"

It most likely has something to do with the fact that the ref is recursive.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
philsturgeoncommented, May 1, 2020

I’m not sure what you mean, I wasn’t offering options. The first code block was how I would expect it to be resolved, as you were expecting a “definitions” to be created for you by json-schema-ref-resolver and that’s not how it works.

The second code block was me asking if you could try something out to see if it also created unexpected behavior. I was not at this point suggesting you change everything at your company. 😃

1reaction
JamesMessingercommented, Dec 12, 2018

Weird. Thanks for reporting it. Will investigate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does git fail to fetch specific valid submodule for a given ...
Running this command after cloning (and receiving the error) solved my problem: git submodule update --force --recursive --init --remote.
Read more >
Structuring a complex schema — Understanding JSON ...
When evaluating a $ref , an implementation uses the resolved identifier to retrieve the referenced schema and applies that schema to the instance....
Read more >
How to use the acorn/dist/walk.recursive function in acorn - Snyk
To help you get started, we've selected a few acorn examples, based on popular ways it is used in public projects. ; function...
Read more >
utils/tools.py - external/swarming.client - Git at Google
Recursive calls count as a single call (i.e. only the time spent in the outer. call is recorded). Autoregisters itself in a global...
Read more >
Sub::Recursive - Anonymous memory leak free ... - MetaCPAN
This particular example isn't a closure as it doesn't reference any lexicals outside itself (and thus could've been written as a named subroutine)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found