-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
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:
paths:
/users:
post:
responses:
'201':
links:
GetUserByUserId: # <---- arbitrary name for the link
operationId: getUser
# or
# operationRef: '#/paths/~1users~1{userId}/get'
parameters:
userId: '$response.body#/id'
description: >
The `id` value returned in the response can be used as
the `userId` parameter in `GET /users/{userId}`.
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 the POST /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.