$ref only works on first level, broken on nested objects
See original GitHub issueWhat 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:
- Created 4 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@mikespokefire thank you for the fix, I just merged it.
🎉 This issue has been resolved in version 2.1.2 🎉
The release is available on:
Your semantic-release bot 📦🚀