External definitions with $ref JSON-pointer
See original GitHub issueGeneral information
I want to reuse external enumerations for several main schemas. There is a problem referencing external definitions. According to the schema documentation we should be able to reference external definitions with reference like this : “$ref” : “[url]#/definitions/[type]” As pointed in several sites like this: http://www.tothenew.com/blog/using-definitions-internal-to-json-schema-and-external-to-json-schema-version-draft-v4/
- json-editor version: 1.3.5
Expected behavior
To have a drop-down with the values defined in the external definition when referencing another json at the same level as the main document with : “$ref”: “./enums.json#/definitions/types” “$ref”:“enums.json#/definitions/types”
Actual behavior
The enums.json file is actually found and fetched with an ajax call.
The field is broken and displays a drop-down with property types (string, object, etc…)
Steps to reproduce the behavior
Two schema files defined in the same project folder
main.json
{
"$schema":"http://json-schema.org/draft-04/schema#",
"type":"object",
"definitions":{
"envInternal":{
"type":"string",
"enum":[
"Production",
"UAT",
"Performance",
"Development",
"Test"
]
}
},
"properties":{
"brokenDropDown":{
"title":"Environment",
"$ref":"enums.json#/definitions/envExternal"
},
"workingDropDown":{
"title":"Environment",
"$ref":"#/definitions/envInternal"
}
}
}
enums.json
{
"$schema":"http://json-schema.org/draft-04/schema#",
"definitions":{
"envExternal":{
"type":"string",
"enum":[
"Production",
"UAT",
"Performance",
"Development",
"Test"
]
}
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (2 by maintainers)
Top GitHub Comments
@pmk65 To some extend it seems to address the same issue. Although this change is made on top of an older code and I don’t think it is applicable straight away. So when I have time I will try to push my modifications for a review. I think I have addressed two more issues :
I think I fixed this in #928