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.

$ref only works on first level, broken on nested objects

See original GitHub issue

What did you do

I tried to generate markdown files for schemas:

./schemas/core.schema.json

{
  "$id": "https://example.org/core.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "foo": {
      "type": "object",
      "properties": {
        "bar": {
          "$ref": "https://example.org/extension.json#"
        }
      }
    },
    "profiling": {
      "$ref": "https://example.org/extension.json#"
    }
  },
  "required": [],
  "additionalProperties": false
}

./schemas/extension.schema.json

{
  "$id": "https://example.org/extension.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Baz",
  "type": "string",
  "enum": ["foo", "bar"]
}

using jsonschema2md -d ./schemas -o ./generated/schemas.

What did you expect to happen

I expect references to generate the appropriate links.

What happened

Apparently, only ref for profiling was resolved. For foo.bar that did not work:

# Schema

https://example.org/core.json

| Abstract            | Extensible | Status       | Identifiable | Custom Properties | Additional Properties | Defined In                           |
| ------------------- | ---------- | ------------ | ------------ | ----------------- | --------------------- | ------------------------------------ |
| Can be instantiated | No         | Experimental | No           | Forbidden         | Forbidden             | [core.schema.json](core.schema.json) |

## Schema Hierarchy

- `https://example.org/core.json`
- [Baz](extension.schema.md) `https://example.org/extension.json`

# Properties

| Property                | Type     | Required | Nullable | Defined by    |
| ----------------------- | -------- | -------- | -------- | ------------- |
| [foo](#foo)             | `object` | Optional | No       | (this schema) |
| [profiling](#profiling) | Baz      | Optional | No       | (this schema) |

## foo

`foo`

- is optional
- type: `object`
- defined in this schema

### foo Type

`object` with following properties:

| Property | Type | Required |
| -------- | ---- | -------- |
| `bar`    |      | Optional |

#### bar

`bar`

- is optional
- type: reference

##### bar Type

<!--
####
The following link is broken
####
-->
- []() – `https://example.org/extension.json#`

## profiling

`profiling`

- is optional
- type: Baz
- defined in this schema

### profiling Type

<!--
####
But this one works!
####
-->
- [Baz](extension.schema.md) – `https://example.org/extension.json#`

What’s your environment

  • Operating System: macOS latest
  • node.js version: v12.5.0
  • jsonschema2md version: 2.1.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
trieloffcommented, Jul 19, 2019

@mikespokefire thank you for the fix, I just merged it.

0reactions
trieloffcommented, Jul 19, 2019

🎉 This issue has been resolved in version 2.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

$ref definition does not work in structures nested to more then ...
This is a continuation of #934, nested $ref $ref definition does not work in structures nested to more then one level.
Read more >
vue.js - Vue - access nested childs using ref - Stack Overflow
I tried sent this.$refs from child level to console, but it's empty. How should I set ref name in nested elements and then...
Read more >
This Trick Changed the Way I Access Nested Objects in ...
The optional chaining operator allows you to access deeply nested objects without having to validate that each nested reference is valid.
Read more >
Using ES6 To Destructure Deeply Nested Objects in ... - ITNEXT
Alright, so to access property values two levels deep, first wrap the original property inside the top level object (in this case props...
Read more >
Deeply Nested Objects and Redux | Pluralsight
First, came the component state and soon it was not enough to keep up with the increasing complexities of SPA (Single Page Applications)....
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