Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-843

Nullable as anyOf or as OData-specific keyword

    XMLWordPrintable

    Details

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

      Applied

    • Proposal:
      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.
    • Resolution:
      Show
      https://www.oasis-open.org/committees/download.php/56552/odata-json-csdl-v4.0-wd01-2015-09-24.docx

      Description

      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 }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              handl Ralf Handl
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: