2017-09-05 82 views
1

我已经在intellij环境中创建了我自己的架构,它运行良好,但仍然存在向架构提供intellij的自动完成问题,例如,如果在json中定义了对象“car”,则为
模式,然后intellij可以认识到模式中有这样的对象,intellij将通过编码json给出它作为建议,我面临的问题是建议包含模式中定义的所有对象,但期望是要获取的另一个舀下定义的对象的对象
这是我自己的模式的一些代码:Json架构自动完成属性

{ 
    "$schema": "http://json-schema.org/draft-04/schema#", 
    "title": "Pipe File", 
    "type": "object", 
    "definitions": { 
    "Pipe": { 
     "type": "object", 
     "properties": { 
     "components": { 
      "$ref": "#/definitions/components" 
     } 
     }, 
     "required": [ 
     "components" 
     ] 
    }, 
    "components": { 
     "description": "section which defines the pipes in the file", 
     "type": "array", 
     "minItems": 1, 
     "items": { 
     "oneOf": [ 
      { 
      "$ref": "#/definitions/setValuesComponent" 
      }, 
      { 
      "$ref": "#/definitions/invokeWebServicesComp" 
      } 
     ] 
     } 
    }, 
    "setValuesComponent": { 
     "type": "object", 
     "properties": { 
     "name": { 
      "type": "string" 
     }, 
     "type": { 
      "enum": [ 
      "setValuesComp" 
      ] 
     }, 
     "out": { 
      "type": "object", 
      "properties": { 
      "dateFormat": { 
       "$ref": "#/definitions/setValuesCompOut" 
      }, 
      "dateTimeFormat": { 
       "$ref": "#/definitions/setValuesCompOut" 
      }, 
      "dateFormatBank": { 
       "$ref": "#/definitions/setValuesCompOut" 
      } 
      } 
     }, 
     "condition": { 
     } 
     }, 
     "required": [ 
     "name", 
     "type", 
     "out" 
     ] 
    }, 
    "setValuesCompOut": { 
     "type": "object", 
     "properties": { 
     "exprValue": { 
      "type": "string" 
     }, 
     "ctxEntry": { 
      "type": "string" 
     }, 
     "value": { 
      "type": "string" 
     }, 
     "exprConst": { 
      "type": "string", 
      "pattern": "(Class|class)\\.\\w+\\.\\w+" 
     } 
     }, 
     "anyOf": [ 
     { 
      "required": [ 
      "exprValue" 
      ] 
     }, 
     { 
      "required": [ 
      "ctxEntry" 
      ] 
     }, 
     { 
      "required": [ 
      "value" 
      ] 
     }, 
     { 
      "required": [ 
      "exprConst" 
      ] 
     } 
     ] 
    }, 
    "invokeWebServicesComp": { 
     "type": "object", 
     "properties": { 
     "name": { 
      "type": "string" 
     }, 
     "type": { 
      "enum": [ 
      "invokeWebServices" 
      ] 
     }, 
     "mode": { 
      "enum": [ 
      "innerJoin", 
      "leftJoin", 
      "union", 
      "parallelJoin" 
      ] 
     }, 
     "method": { 
      "type": "string" 
     }, 
     "headers": { 
      "$ref": "#/definitions/invokeWebServicesCompHeaders" 
     }, 
     "dataFilePath": { 
      "type": "string" 
     }, 
     "restRelativeUrl": { 
      "type": "string" 
     }, 
     "in": { 
      "$ref": "#/definitions/invokeWebServicesCompIn" 
     }, 
     "out": { 
      "$ref": "#/definitions/invokeWebServicesCompOut" 
     } 
     }, 
     "required": [ 
     "type", 
     "name", 
     "out", 
     "in" 
     ] 
    }, 
    "invokeWebServicesCompOut": { 
     "type": "object", 
     "patternProperties": { 
     "doc": { 
      "type": "string", 
      "pattern": ".+" 
     } 
     } 
    }, 
    "invokeWebServicesCompHeaders": { 
     "type": "object", 
     "patternProperties": { 
     ".{1,}": { 
      "type": "string", 
      "pattern": ".+" 
     } 
     } 
    }, 
    "invokeWebServicesCompIn": { 
     "type": "object", 
     "patternProperties": { 
     ".{1,}": { 
      "type": "string", 
      "pattern": ".+" 
     } 
     } 
    }, 
    "properties": { 
     "pipes": { 
     "description": "section which defines the mandatory pipes object in the file", 
     "type": "object", 
     "patternProperties": { 
      ".{1,}": { 
      "$ref": "#/definitions/Pipe" 
      } 
     } 
     } 
    }, 
    "required": [ 
     "pipes" 
    ] 
    } 
} 

所以我期望的是,当对象的类型确定为“setValuesComp”时,自动完成将提示相关属性,这意味着它不会建议属于“invokeWebServicesComp”而不属于“setValuesComponent”的属性。 this picture show the auto complete problem in my real environment

回答

0

您的JSON模式似乎无效。下面的JSON内容应该存在于对象类型中。

"properties": { 
    "pipes": { 
    "description": "section which defines the mandatory pipes object in the file", 
    "type": "object", 
    "patternProperties": { 
     ".{1,}": { 
     "$ref": "#/definitions/Pipe" 
     } 
    } 
    } 
}, 
"required": [ 
    "pipes" 
] 

在您的模式中,它作为“定义”的一部分存在。请进行更正,然后检查是否能够得到这些建议。