Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to define link headers #667

Open
ePaul opened this issue Apr 22, 2016 · 0 comments
Open

Make it easier to define link headers #667

ePaul opened this issue Apr 22, 2016 · 0 comments
Labels
headers http Supporting HTTP features and interactions param serialization Issues related to parameter and/or header serialization

Comments

@ePaul
Copy link
Contributor

ePaul commented Apr 22, 2016

RFC 5988, section 5 is defining the LinkHTTP header.
It is mainly used on responses to GET requests (but can happen on any kind of response), but can also be used sensible as request headers for PUT, and possibly for the (less common) LINK and UNLINK methods.

It can look like this:

Link: <http://example.com/TheBook/chapter2>; rel="previous";
      title="previous chapter"

or this (having a list of two links):

Link: </TheBook/chapter2>;
      rel="previous"; title*=UTF-8'de'letztes%20Kapitel,
      </TheBook/chapter4>;
      rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel

(Examples are from the RFC.) As usual with HTTP headers, you could have written this last example also in two headers, like this:

    Link: </TheBook/chapter2>;
          rel="previous"; title*=UTF-8'de'letztes%20Kapitel
    Link: </TheBook/chapter4>;
          rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel

I would like to be able to define that a link with a certain relation type (the value of the rel attribute) will/might be available in the response (or must/can be sent in a request). Currently (with OpenAPI 2.0), the best I came up with was this:

      responses:
        200:
          description: Retrieval was successful.
          headers:
            Link:
              type: string
              description: |
                Links to related resources, in the format defined by
                [RFC 5988](https://tools.ietf.org/html/rfc5988#section-5).
                This will include a link with relation type `next` to the
                next page, if there is a next page.

I guess I could make this an array and use collectionFormat: csv, though I'm not sure how either of these would handle the two-headers version.

For OpenAPI.next (i.e. 3.0, if possible) I would like some better way of doing this, including to say links of which relation are expected to be there (but not forbidding other ones, of course).

I might be that the "parameters can have schemas" (in #654) with serialization strategies (in #665) might help here, if it gets extended to response headers, too, and we get a special serialization strategy for those kinds of headers.

Any other ideas?

@handrews handrews added http Supporting HTTP features and interactions param serialization Issues related to parameter and/or header serialization labels Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
headers http Supporting HTTP features and interactions param serialization Issues related to parameter and/or header serialization
Projects
None yet
Development

No branches or pull requests

2 participants