Skip to content

Relationship properties #601

@ralfhandl

Description

@ralfhandl

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Moved to MoonwalkIssues that can be closed or migrated as being addressed in Moonwalklinks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions