-
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
Feature suggestion: "Backlinks" - Links defined the inverse of the way they are currently #2196
Comments
It would also be better for tooling (e.g. automated testing etc) If you want to make a The other way around, as currently, it's not possible. Because, potentially, the tool does not know the location of the doc where the |
This is exactly what Im looking for. We need to start at an api and work our way back through a list of dependencies setting up everything so we can then run the api we started with. |
+1 to this enhancement request. We have actually already implemented this capability in our tooling with a spec extension,
This is a much more compact way of expressing links, particularly when coupled with referenced parameters -- a single |
Since posting the original issue I have also developed an implementation of this idea for use in some tooling I'm building I will document it and post back here with a concrete proposal |
For context I am in early stages of building tooling around automation of integration tests for app backends which span multiple services. One important building block, for this tool to be able to cut out manual test-definition boilerplate, is to be able to derive a dependency graph of the endpoints which are exposed across multiple services. OpenAPI's ability to have URI references which span across independent API docs is very useful for this. However I found three areas where vanilla OpenAPI 3.0 is insufficient:
I think these first two would be generally useful for many use-cases. The last one is maybe a bit more specific to my particular tool use-case:
I have documented here the extension properties I defined in order to get this library working: (it is still WIP but I can now successfully derive a dependency graph at least) The parts that are relevant to this thread are You may ignore the parts about |
And a basic example: openapi: 3.0.0
paths:
/2.0/users/{username}:
get:
operationId: getUserByName
parameters:
- name: username
in: path
required: true
schema:
type: string
responses:
'200':
description: The User
content:
application/json:
schema:
$ref: '#/components/schemas/user'
/repositories/{username}:
get:
operationId: getRepositoriesByOwner
parameters:
- name: username
in: path
required: true
schema:
type: string
x-backlinks:
Get User by Username:
operationId: getUserByName
response: "200"
parameters:
username: $response.body#/username This shows a "backlink" from the We use a runtime expression (as found elsewhere in OpenAPI) to get a value from the |
After applying OAS extensively towards many different applications, like AWS API Gateway, client generation, documentation, design, and many other things, I MUST request that this be brought to the forefront of discussion for the TSC. Of the many proposals around this topic, any would do. I don't think the problem is the how, it's the why. Therefore rather than being noise amongst the other great proposals on this thread, I will advocate for why this is a paramount need for OAS. DocumentationEvery set of backend services, whether micro or monolithic, has operations dependent upon responses from the others. It's almost safe to say, that for documentation purposes, if there are no fragments of a request body that aren't from another operation's response body, the two requests don't belong in the same spec because they'd have nothing to do with each other. It's a common process for any type of modeling tool to granularly define relationships. Whether it be an ERD or a Function Call Graph, there needs to be a way for description. Further, it's often ambiguous whether identically named parameters are in fact the same or sourced from other responses without explicit declaration. For one to make assumptions about parameters based off name in a large OAS inevitably leads to bugs. Common, Practical Use Cases
Design/ArchitectureHardly ever do entire request bodies comprise of a singular response attribute. In fact, if this were the case, one could argue that it's almost certainly flawed API Design. If an entire request body is to be sourced from a response body, why wouldn't the original operation that returned said response not just make the request on the client's behalf? The current implementation of having: The Future and BeyondThe OAS and what it aims to do are truly something great. Using OAS it's possible to document web request for both the human and machine. One of the last things missing is the ability to further describe the relationships each operation might play into another. Should this "last mile" problem be solved, developers integrating with API's might not ever need to even write a line of code nor converse with it's maintainers. @darrelmiller, @whitlockjc, @earth2marsh, @MikeRalphson, @webron, @usarid, Please do consider/reconsider this enhancement during your next TSC. |
Absolutlly agree with the idea, as process are incremental: => Forward referencing adds unnecessary complexity to common feature. Nice to have:
|
Would be great if Links on Objects would be possible forward and backwar: |
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: |
I would like the be able to define Links, but in the inverse of the way Links are currently implemented.
Take the example from the docs:
If you imagine a system of microservices with many interlinked API schemas... There are going to be dozens of other endpoints in different services which can make use of the
userId
that results from thePOST /users
operation. Some of these services will be maintained by different teams, and their API schemas will be in a separate repos etc.In that context it feels to me quite "back to front" to collect all of these links under the
POST /users
operation responses, and that instead it would make more sense to define the link on the other side of the relation.For example on the
GET /users/{userId}
operation, it would be awesome to have a way to specify that{userId}
can be obtained from#/paths/~1users~1/post/responses/201/content/id
.(Possibly as an extension to the Parameters? it would also be useful to be able to set fields in the request body this way, as suggested here ).
In these cases it would be much easier to maintain if the "consumer" API specifies where to get its prerequisites from, rather than having the "producer" API try to list all of the places its data can potentially be used, which is what the Links feature provides currently.
possibly related: #2122 #1594 #1593
The text was updated successfully, but these errors were encountered: