Can JSON integer attributes be referenced?

前端 未结 2 1294
温柔的废话
温柔的废话 2021-01-26 11:03

I have the following JSON schema that I want to validate and Python unittest.

{
    \"properties\": {

        \"traffic_parameters\" {

            \"capacity\"         


        
相关标签:
2条回答
  • 2021-01-26 11:37

    The JSON Reference spec doesn't place any limits on what can be $ref'd, but in practice, any validator that I have ever seen only supports $refs that point to a JSON Schema. I'm not sure why none ever supported that functionality, but I have yet to see a case where I thought it was a good idea to do such a thing.

    In the recently released JSON Schema draft-06, the common practice of supporting only JSON Schemas became a rule. So, even if you do find a validator that supports $refing integers, I wouldn't recommend using it because it will make it harder to upgrade in the future.

    0 讨论(0)
  • 2021-01-26 11:43

    This won't work this way. $ref references must always point to schemas. So it can be an object or a boolean, but not a number.

    0 讨论(0)
提交回复
热议问题