Bundle references into definitions
See original GitHub issueLet’s say we have a schema that has external references to another schema’s definitions:
foo.json
{
"definitions": {
"foo": {
"properties": {
"a": {
"$ref": "./bar.json#/definitions/bar"
},
"b": {
"$ref": "./bar.json#/definitions/bar"
},
"c": {
"$ref": "./bar.json#/definitions/bar"
}
}
}
}
}
bar.json
{
"definitions": {
"bar": {
"properties": {
"a": {
"type": "string"
},
"b": {
"type": "number",
"maximum": 20
}
}
}
}
}
When using parser.bundle('foo.json')
to bundle the external references, this is the resulting schema:
{
"definitions": {
"foo": {
"properties": {
"a": {
"properties": {
"a": {
"type": "string"
},
"b": {
"type": "number",
"maximum": 20
}
}
},
"b": {
"$ref": "#/definitions/foo/properties/a"
},
"c": {
"$ref": "#/definitions/foo/properties/a"
}
}
}
}
}
While this is a valid schema, it seems more straightforward to copy the definition for bar
into definitions
, especially if it is referenced in multiple places:
{
"definitions": {
"foo": {
"properties": {
"a": {
"$ref": "#/definitions/bar"
},
"b": {
"$ref": "#/definitions/bar"
},
"c": {
"$ref": "#/definitions/bar"
}
}
},
"bar": {
"properties": {
"a": {
"type": "string"
},
"b": {
"type": "number",
"maximum": 20
}
}
}
}
}
Can this be done somehow?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Bundle Definition & Meaning - Merriam-Webster
1 · to make into a bundle. bundle the magazines together ; 2 · to hustle or hurry unceremoniously. bundled the children off...
Read more >bundle - WordReference.com Dictionary of English
an item wrapped for carrying; package:He brought in a few bundles from the car. ; a large amount of something; a lot of:He's...
Read more >Bundle definition and meaning | Collins English Dictionary
1. a number of things tied, wrapped, or otherwise held together · 2. a package or parcel · 3. a bunch, collection, or...
Read more >Bundle - definition of bundle by The Free Dictionary
1. a number of things or a quantity of material gathered or loosely bound together: a bundle of sticks. · 2. something wrapped...
Read more >BUNDLE resources - IBM
A BUNDLE resource defines a CICS bundle, a unit of deployment for an application. A bundle is a collection of CICS resources, artifacts,...
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 FreeTop 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
Top GitHub Comments
This ability is super helpful for creating files that are used by other class generator tools.
Are there any plans to have an option to create the shared definition entries automatically?
When maintaining multiple files, it’s kind of hard to remember/enforce that the definition entry is created along with the other references. And if those references ever change you need to make sure to go update the definition entry as well.
You can accomplish this by referencing
bar
in thedefinitions
section, like this: