-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
openapi link vs hypermedia link to represent relationships in APIs #2122
Comments
Note that
The OAS does not suggest using design-time |
thanks for the correction.
i dont understand .. there is a way with OAS in order to associate link to string field that represent hypermedia link ? if yes could you please do an example ? It would be useful if OAS allow to use this field in link definition in order to describe that the content of owner field is the link to operationId getOwner. |
being able to use OAS link with basic Hypermedia links would be great. Tho some apis might include relations array in resources. this are spec for some predefined relation types but one can define custom relations as well. With that approach response of {
"items": [
{
"id": 1,
"name": "mewfoxy",
"links": [
{ "rel": "self", "href": "http://myApi.com/cat/1" },
{
"rel": "http://myApi.com/relationshps#owner",
"href": "http://myApi.com/user/66"
}
]
},
{
"id": 2,
"name": "mewFoo",
"links": [
{ "rel": "self", "href": "http://myApi.com/cat/2" },
{
"rel": "http://myApi.com/relationshps#owner",
"href": "http://myApi.com/user/11"
}
]
}
],
"links": [
{ "rel": "self", "href": "http://myApi.com/cats" },
{ "rel": "next", "href": "http://myApi.com/cats?page=2" },
{ "rel": "last", "href": "http://myApi.com/cats?page=20" }
]
}
|
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: |
Hi All,
Suppose i have a resourse Dog and a Resource Owner. i can design Dog in openapi in the following way:
in this way the client can use ownerId to get the owner data calling the api /owners/x
in this way when the client get a Dog get also all the info of the owner. The disvantages is the verbosity of response.. for each Dog the client obtain also all the info of the owner.
What is the best way to design this typical situation in openapi ? in general i think the third solution is better as reported in rest best practices.
But reading the new openapi feature link
Links are one of the new features of OpenAPI 3.0. Using links, you can describe how various values returned by one operation can be used as input for other operations. This way, links provide a known relationship and traversal mechanism between the operations. The concept of links is somewhat similar to hypermedia, but OpenAPI links do not require the link information present in the actual responses.
i have some doubts... reading above i understood that the better solution in openapi is to use the first solution extended using Link
My idea is correct ? why openapi not suggest to use hypermedia link for relationship?
The text was updated successfully, but these errors were encountered: