Relationships are an important part of an API or a data model: People have Friends, People have Hobbies, which are shared by other People, ...
OData represents relationships as a special kind of property, a so-called navigation property which allows retrieving related entities, and also retrieving an entity together with related entities:
As the last example shows it makes sense to model navigation properties just as "data" properties in the /definitions section as they may be part of the response if requested with $expand. It is also necessary to tag them as special properties, and include additional metadata about the relationship:
"Products": {
"type": "array",
"items": {
"$ref": "#/definitions/ODataDemo.Product"
},
"x-relationship": {
"partner": "Category",
"onDelete": {
"action": "Cascade"
} }
}
}
},
Partner is the navigation property in the target type that leads back to the current type, onDelete describes potential side-effects of deleting an entity of the current type, and referentialConstraints describe value dependencies to the related entity.
Anyone else having similar concepts/constructs in their APIs that would make it worth making this a first-class concept in OpenAPI?
Relationships are an important part of an API or a data model: People have Friends, People have Hobbies, which are shared by other People, ...
OData represents relationships as a special kind of property, a so-called navigation property which allows retrieving related entities, and also retrieving an entity together with related entities:
http://services.odata.org/V4/(S(n4bk11pfsypujadnvn5jtwic))/TripPinServiceRW/People('russellwhyte')
http://services.odata.org/V4/(S(n4bk11pfsypujadnvn5jtwic))/TripPinServiceRW/People('russellwhyte')/Friends
http://services.odata.org/V4/(S(n4bk11pfsypujadnvn5jtwic))/TripPinServiceRW/People('russellwhyte')?$expand=Friends
As the last example shows it makes sense to model navigation properties just as "data" properties in the
/definitionssection as they may be part of the response if requested with$expand. It is also necessary to tag them as special properties, and include additional metadata about the relationship:Partner is the navigation property in the target type that leads back to the current type, onDelete describes potential side-effects of deleting an entity of the current type, and referentialConstraints describe value dependencies to the related entity.
Anyone else having similar concepts/constructs in their APIs that would make it worth making this a first-class concept in OpenAPI?