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

link object scope #1593

Closed
dret opened this issue May 29, 2018 · 4 comments
Closed

link object scope #1593

dret opened this issue May 29, 2018 · 4 comments
Labels
links Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk

Comments

@dret
Copy link
Contributor

dret commented May 29, 2018

am i correct to assume that currently link objects are just per response? if so, i am wondering if it might be useful to be able to support a different scope for link objects?
for example, it might be useful to be able to easily say that a home link (proposed in mnot/I-D#41 and documented at https://mnot.github.io/I-D/json-home/#link-relation) should be considered present in all responses.
this would complicate the processing model because then the effective response of an OpenAPI -described API would be the union of the received response, plus all added link object links that apply to the context of the response. but it would be a rather powerful to support hypermedia in a way that allows OpenAPI to support links without requiring them in all responses.

@tedepstein
Copy link
Contributor

@dret, I don't believe there is currently any way to specify links at the path item or API level. It's strictly response-level for now.

However, you can define reusable Link Objects in /components/links and reference these in the response links.

this would complicate the processing model because then the effective response of an OpenAPI -described API would be the union of the received response, plus all added link object links that apply to the context of the response.

Note that inclusion of links has no effect on the actual response payload or response headers. Links are design-time metadata, providing information that clients can use to present and/or traverse links to other resources. The client must have access to the OpenAPI document (or to some link-aware artifact generated from the OpenAPI document) in order to comprehend these links.

Each link is defined by a runtime expression that can include static text and/or references to information in the request or response.

You're right to say that allowing links at API-level, path-level or method-level incurs some added complexity. But that complexity would fall on the client, who has to collect the full set of applicable links from all of the containing contexts. It wouldn't have any effect on the response sent from the server.

@dret
Copy link
Contributor Author

dret commented May 29, 2018 via email

@tedepstein
Copy link
Contributor

Each link is defined by a runtime expression that can include static text and/or references to information in the request or response.

yes, but that's how the link target is computed, right? it doesn't make
the link source any more flexible, or am i misunderstanding it?

I don't think you're misunderstanding it. Runtime expressions are only used in the parameters and requestBody of a link. (They're also used as keys in callbacks, but that's out of scope for this discussion, I think.)

Runtime expressions don't affect the link source; i.e., they don't specify a scope for the link. That scope is always a single response where the link is declared.

Runtime expressions only affect the link target. And runtime expressions are still limited, even in their ability to specify the link target:

  • The target must always be an operation, not a path item (which could have multiple operations), nor an arbitrary resource identified by a URL.
  • The URL of the target is determined by the Server Object specified in the link, plus the relative path (key) of the Path Item that contains the target Operation. That Path Item can use path parameters, which can be resolved by runtime expressions. The Server Object's url can have Server Variables, but these are not resolved by runtime expressions. Server Variables are determined by the server, presumably on startup. AFAICT, OpenAPI doesn't specify Server Variable resolution; it's implementation-defined.

@handrews handrews added the Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk label May 24, 2024
@handrews
Copy link
Member

This scale of change is best discussed in Moonwalk (and can be backported if relevant and we decide to keep the 3.x line going). Closing in favor of:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
links Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk
Projects
None yet
Development

No branches or pull requests

4 participants