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

Support the notion of a collection of name/value pairs where the type of the value is known

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.01_CSD01
    • Fix Version/s: V4.01_CSD02
    • Component/s: Vocabularies
    • Labels:
      None
    • Proposal:
      Hide

      1) Define a complex type "Dictionary" in OData.Core as an open complex type with no properties.
      2) Define a Validation term "OpenPropertyTypeConstraint" whose value is a collection of qualified type names. It can be applied to an open entity or complex type definition and constrains open properties of that type to the specified values.
      3) Define a Validation term "DerivedTypeConstraint" whose value is a collection of qualified type names. It can be added to a property (or TypeDefinition) to constrain the derived types of that property. If a specified type is not a derived type of the property to which it is applied then it is ignored.

      Show
      1) Define a complex type "Dictionary" in OData.Core as an open complex type with no properties. 2) Define a Validation term "OpenPropertyTypeConstraint" whose value is a collection of qualified type names. It can be applied to an open entity or complex type definition and constrains open properties of that type to the specified values. 3) Define a Validation term "DerivedTypeConstraint" whose value is a collection of qualified type names. It can be added to a property (or TypeDefinition) to constrain the derived types of that property. If a specified type is not a derived type of the property to which it is applied then it is ignored.
    • Resolution:
      Show
      https://github.com/oasis-tcs/odata-vocabularies/commit/0b13cb2d0e969bcb375cc885f30f60ecea6f5500

      Description

      There is currently no easy way (read: without specifying an additional wrapper entity type) of specifying a, what most people would likely refer to as a, dictionary, or a collection of name/value pair, in which I can specify the type of the values!

      So where we would need to do something today like:

      <EntityType Name="ValueType">
      <Key>
      <PropertyRef Name="Key"/>
      </Key>
      <Property Name="Key" Type="Edm.String" Nullable="false"/>
      <Property Name="PropA" ... />
      ...
      </EntityType>

      <EntityType Name="ValueTypeDictionaryWrapper">
      <Key>
      <PropertyRef Name="Name"/>
      </Key>
      <Property Name="Name" Type="Edm.String" Nullable="false"/>
      <NavigationProperty Name="Value" Type="ns.ValueType" Nullable="false"/>
      </EntityType>

      <AnyStructuredType Name="ValueTypeDictionaryContainer">
      ...
      <NavigationProperty Name="Values" Type="Collection(ns.ValueTypeDictionaryWrapper)" Nullable="false"/>
      ...
      </AnyStructuredType>

      Note that the wrapper has to be an entity type to be able to use the name (key) to index into the 'dictionary'. This is even a bit weirder if what we are putting in the dictionary is actually complex types that one would want to treat just like a collection of that complex type.

      The payload would look something like this:

      {
      "@odata.context": "$metadata#AnyStructuredType(Values(Value))/$entity",
      ...,
      "Values": [{
      "Name": "foo",
      "Value":

      { "Key": "38hfgs8", "PropA": "APropA_value", ... }

      ,
      "Name": "bar",
      "Value":

      { "Key": "f93d8r3", "PropA": "APropA_value", ... }

      ,
      ...
      }],
      ...
      }

      Needless to say that this JSON representation of an, expanded, payload doesn't look like what a typical JSON consumer would expect and it requiring the wrapped value to be expanded as well..

      So what I'm looking at being able to do is, using the same example, do something like:

      <EntityType Name="ValueType">
      <Key>
      <PropertyRef Name="Key"/>
      </Key>
      <Property Name="Key" Type="Edm.String" Nullable="false"/>
      <Property Name="PropA" ... />
      ...
      </EntityType>

      <AnyStructuredType Name="ValueTypeDictionaryContainer">
      ...
      <NavigationProperty Name="Values" Type="Dictionary(ns.ValueTypeDictionaryWrapper)" Nullable="false"/>
      ...
      </AnyStructuredType>

      And the resulting JSON payload for requests would look something like:

      {
      "@odata.context": "$metadata#AnyStructuredType(Values)/$entity",
      ...,
      "Values": {
      "foo":

      { "Key": "38hfgs8", "PropA": "APropA_value", ... }

      ,
      "bar":

      { "Key": "f93d8r3", "PropA": "APropA_value", ... }

      ,
      ...
      },
      ...
      }

      Note the more intuitive typical JSON response and that we don't need to expand the value in the wrapper any longer.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              hubert.heijkers Hubert Heijkers
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: