question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variables/Parameters in Links

See original GitHub issue

The 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:open
  • Created 6 years ago
  • Reactions:12
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
LukasRoscommented, Aug 21, 2017

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.

2reactions
xorcuscommented, Apr 9, 2019

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 OAS Schema 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 of Schema Object (same as in Response Object) b) In Runtime Expressions, redefine the fragment:

fragment = a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901)  

by allowing for the optional non-negative-integer prefix, having semantics explained in Relative JSON Pointer:

fragment = [ <non-negative-integer> ] <a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901)>

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 unique id). 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found