Skip to content

hyper-schema, the self link, and response envelopes #107

Closed
@handrews

Description

@handrews

Given a legacy API with a response envelope, is it reasonable to put a fragment on a self link pointing to the actual resource representation inside the envelope? In Draft 04, the "home" link relation was defined for this purpose, as far as I can tell. I was not a fan of its specific details, but adjusting for an envelope is a common use case for legacy APIs.

This, of course, is assuming we want to be able to work with legacy APIs at all.

Example instance returned from GET /foo/12345:

{
    "metaData": {...},
    "actualData": {...}
}

Example of self link with fragment (you also need extended templating to map the template variable for the envelope document to the id inside the envelope):

{
    "definitions": {
        "foo": {
            ...,
            "links": [{"rel": "self", "href": "/foo/{id}#/actualData"}]
        }
    },
    "type": "object",
    "properties": {
        "metaData": {...},
        "actualData": {"$ref": "#/definitions/foo"}
    },
    "links": [{
        "rel": "self",
        "href": "/foo/{id}",
        "hrefVars": {"id": "0/actualData/id"}
    }]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions