Uploaded image for project: 'Olingo'
  1. Olingo
  2. OLINGO-1452

Metadata Validation Does Not Enforce that Key Field Exists in EntityType Definition

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • (Java) V4 4.7.1
    • (Java) V4 4.7.1
    • odata4-client
    • None
    • Linux, OSX, Windows.

    Description

      Using the Olingo XML Metadata validation methods, they correctly catch the case where there is no Key property defined in the metadata for a given EntityType definition.  

      For example, this will produce an error:

      <?xml version="1.0" encoding="utf-8"?>
      <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
        <edmx:DataServices>
          <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="org.example">
            <EntityType Name="SomeEntityType">
              <Property Name="SomeEntityTypeKey" Type="edm.String" Nullable="false" />
            </EntityType>
          </Schema>
          <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Default">
            <EntityContainer Name="Container">
              <EntitySet Name="SomeEntityType" EntityType="org.example.SomeEntityType"/>
            </EntityContainer>
          </Schema>
        </edmx:DataServices>
      </edmx:Edmx>

       

      However, the Key can be defined without the EntityType's Property definition for that field being present, and this is something that the metadata validation does not catch. 

      <?xml version="1.0" encoding="utf-8"?>
      <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
        <edmx:DataServices>
          <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="org.example">
            <EntityType Name="SomeEntityType">
              <Key>
                <PropertyRef Name="SomeEntityTypeKey"/>
              </Key>
            </EntityType>
          </Schema>
          <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Default">
            <EntityContainer Name="Container">
              <EntitySet Name="SomeEntityType" EntityType="org.example.SomeEntityType"/>
            </EntityContainer>
          </Schema>
        </edmx:DataServices>
      </edmx:Edmx>

       

      This ticket was created to request that XML metadata validation check both whether a Key is present, and that the defined key also has a corresponding Property definition in the metadata. Otherwise, metadata validation should fail. 

      Attachments

        Activity

          People

            Unassigned Unassigned
            joshd Joshua Darnell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: