Variables/Parameters in Links
See original GitHub issueThe OpenAPI v3 links feature allows specifying related operations. To me, however, the spec was not clear on whether it’s possible and if, how to define links that require an additional variable for the call.
To give a practical example, assume there’s a GET /users
operation to list all users and a GET /users/{id}
operation to get details about an individual user. I could add the latter as a link to the former but this link requires an additional piece of information, specifically which user from the list I want to receive details for.
{
"links" : {
"details" : {
"operationId" : "getUserDetails",
"parameters": {
"id" : "$response.body#/*/id"
}
}
}
}
Is that possible or even desired to express with the links feature? If yes, is *
the right syntax for a placeholder in JSON pointer? If not, is there another way?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:12
- Comments:18 (10 by maintainers)
Top Results From Across the Web
A Beginner's Guide to URL Parameters - SEMrush
To identify a URL parameter, refer to the portion of the URL that comes after a question mark (?). URL parameters are made...
Read more >Use URL Variables to Pass Data - Alchemer Help
URL Variables make for a quick method for pre-populating existing data into a survey. With a simple query added to the end of...
Read more >URL parameters - How to pass it to the destination URL
You can pass URL parameter values to your tracking destination URL using the options available in ClickMeter. ... You can also add multiple ......
Read more >What are URL parameters? | Learn SEO - Botify
URL parameters (also known as “query strings”) are a way to structure additional information for a given URL. Parameters are added to the...
Read more >A guide to URL parameter handling - SALT.agency®
URL parameters are variables concatenated to the end of the page URL after a question mark, and separated by '&' symbols when multiple ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, thanks for your quick reply and the clarification, so I’ve understood links are always 1:1 pointers to other operations, never 1:n. I think that 1:n links with variables are a really interesting feature and would love to see them in a future version of the OAS.
I guess the use of hypermedia is not in line with OAS design-time
Link Object
as it requires link information in the runtime response. What I had in mind is something similar to JSON Hyper-Schema and relative JSON pointers, as described by @handrews in his comment on Jan 5, 2018, but without needing separate hyper-schema resources. Ideally, all links would be included in the OAS API spec.As explained in Relative JSON Pointer, section 6, the fragment identifiers do not apply to relative pointers.
Would it be possible to have
links
in OASSchema Object
, allowing for the<non-negative-integer>
prefix of JSON pointers (i.e. using Relative JSON pointers) as part of the standard OAS spec?As far as I am aware, the only changes needed in the OAS are: a) Add
links
as a regular property ofSchema Object
(same as inResponse Object
) b) In Runtime Expressions, redefine thefragment
:by allowing for the optional
non-negative-integer
prefix, having semantics explained in Relative JSON Pointer:This is a backward-compatible change.
If
<non-negative-integer>
is not there, JSON Pointer is absolute. If present, JSON pointer is relative. In majority of use cases, the evaluation of links does not depend on context in which a Schema Object is found, but rather on a Schema Object property (e.g. the uniqueid
). Therefore, in a simplified client implementation, it should be sufficient to support evaluating only relative JSON pointers starting with zero, i.e. having the<non-negative-integer>
set to zero.