我正在使用 Sphinx 记录我的 JSON Schema 以将其托管在 ReadTheDocs 上。
当我在我的主模式文件中有我的定义时,一切都很好。但我想将我的定义移动到外部 json 文件中。
我的代码从
"$ref": "#/definitions/positiveNumber"
至
"$ref": "./general.definitions.json#/definitions/positiveNumber"
我的general.definitions.json
文件如下所示:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/andrejellema/GlobalCoffeeDataStandard/master/schema/general.definitions.json",
"title": "General definitions",
"definitions": {
"percentage": {
"title": "The percentage, 0-100",
"description": "The percentage, from 0 to 100 with decimals allowed",
"$comment": "Duplicate in /productionCosts.json",
"type": "number",
"minimum": 0,
"maximum": 100
},
"positiveNumber": {
"title": "A positive number > 0",
"description": "A positive number starting at 0 with decimals allowed",
"type": "number",
"minimum": 0
},
"greaterThanZero": {
"title": "The positive number, greater than 0",
"description": "A positive number starting at greater than 0 with decimals allowed",
"type": "number",
"exclusiveMinimum": 0
},
"yesNo": {
"title": "Yes-No enumeration",
"type": "string",
"enum": [
"Yes",
"No"
]
}
}
}
我失败的第一个内容:
.. literalinclude:: ../../schema/general.definitions.json#/definitions/positiveNumber
:language: json
:linenos:
:caption: Object description
我的第一个有效内容:
.. literalinclude:: ../../schema/global-unique-id.json
:language: json
:linenos:
:caption: Object description
当我打电话时,make html
我收到此错误:
[...]\docs\source\explanation.rst:1360: WARNING: Include file '[...]\\schema\\general.definitions.json#\\definitions\\positiveNumber' not found or reading it failed
该文件存在于该位置。似乎 Sphinx 没有正确处理 JSON 指针。
我能做些什么来解决这个问题?