Nullable as anyOf or as OData-specific keyword

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major
    • V4.0_WD01
    • Affects Version/s: V4.0_WD01
    • Component/s: CSDL JSON
    • None
    • Environment:

      Applied

    • Hide

      Propose: for primitive types, represent as:
      "type":["string","null"],
      "format":"date-time"

      For non-primitive types, use existing json schema.

      See if we can add "nullable" to json-schema.

      Show
      Propose: for primitive types, represent as: "type": ["string","null"] , "format":"date-time" For non-primitive types, use existing json schema. See if we can add "nullable" to json-schema.
    • Show
      https://www.oasis-open.org/committees/download.php/56552/odata-json-csdl-v4.0-wd01-2015-09-24.docx

      JSON Schema treats null as a separate data type, requiring an "anyOf" construct for nullable properties:

      "Supplier":{
      "anyOf":[

      { "$ref":"#/definitions/ODataDemo.Supplier" }

      ,

      { "type":"null" }

      ],

      If we accept that OData-unaware JSON Schema validators will complain wrongly if they encounter a null value, we could shorten this to

      "Supplier":

      { "$ref":"#/definitions/ODataDemo.Supplier", "nullable":true }

      This would increase readability for humans and OData-aware machines and significantly reduce the optical size of the JSON CSDL due to the reduced number of line breaks added by pretty printers and JSON Viewers. The actual byte size reduction isn't significant.

      Combined with ODATA-842 this would reduce

      "Created":{
      "anyOf":[
      {
      "allOf":[

      { "$ref":"http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#/definitions/Edm.DateTimeOffset" }

      ],
      "pattern":"(^[^.]*$|[.][0-9]

      {1,6}

      $)"
      },

      { "type":"null" }

      ]
      }

      to just

      "Created":

      { "type":"string", "format":"date-time", "precision":6 "nullable":true }

            Assignee:
            Unassigned
            Reporter:
            handl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: