Skip to content

Commit fd49c95

Browse files
committed
update README for link objects
1 parent 3c0612d commit fd49c95

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

README.md

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,8 @@ requestModels:
751751

752752
#### `methodResponses`
753753

754+
`methodResponses` is a mandatory property and should include the `responseBody` and `description` properties.
755+
754756
You can define the response schemas by defining properties for your function event.
755757

756758
For an example of a `methodResponses` configuration for an event see below:
@@ -763,6 +765,12 @@ methodResponse:
763765
responseModels:
764766
application/json: "CreateResponse"
765767
application/xml: "CreateResponseXML"
768+
links:
769+
getDataLink:
770+
operation: getData
771+
description: The id created here can be used to get Data
772+
parameters:
773+
contentId: $response.body#/id
766774
responseHeaders:
767775
X-Rate-Limit-Limit:
768776
description: The number of allowed requests in the current period
@@ -788,6 +796,53 @@ responseModels:
788796
application/xml: "CreateResponseXML"
789797
```
790798

799+
##### `links`
800+
801+
The `links` property allows you to define how operations are linked to each other:
802+
803+
```yml
804+
links:
805+
linkName:
806+
operation: getContent
807+
description: The contentId created here can be used to get content
808+
parameters:
809+
contentId: $response.body#/contentId
810+
```
811+
812+
Where we are specifying operation, this should map to the function name:
813+
814+
```yml
815+
functions:
816+
createContent:
817+
events:
818+
- httpApi:
819+
path: /
820+
method: POST
821+
documentation: ...
822+
getContent:
823+
events:
824+
- http:
825+
path: /{contentId}
826+
method: POST
827+
documentation: ...
828+
```
829+
830+
If our example link was attached to the **createContent** function, and we wanted the `contentId` that was created to be used on the **getContent** function in the `contentId` parameter, we'd specify the `operation` property as **getContent**. If however, you had specified an operationId in the documentation to override the automatically created one:
831+
832+
```yml
833+
getContent:
834+
events:
835+
- http:
836+
path: /{contentId}
837+
method: POST
838+
documentation:
839+
operationId: getMyContent
840+
```
841+
842+
You can refer to the `operationId` that you created.
843+
844+
You can read more about [links](https://swagger.io/docs/specification/links/) on the swagger.io site and in the [OpenAPI](https://spec.openapis.org/oas/v3.0.3#link-object) specification. They don't seem widely supported just yet, but perhaps they'll improve your documentation.
845+
791846
##### `responseHeaders`
792847

793848
The `responseHeaders` property allows you to define the headers expected in a HTTP Response of the function event. This should only contain a description and a schema, which must be a JSON schema (inline, file or externally hosted).
@@ -882,7 +937,7 @@ This will set the `Cache-Control` Response Header to have a value of "no-store"
882937

883938
## Example configuration
884939

885-
Please view the example [serverless.yml](test/serverless-tests/serverless%202/serverless.yml).
940+
Please view the example [serverless.yml](test/serverless-tests/best/serverless.yml).
886941

887942
## Notes on schemas
888943

0 commit comments

Comments
 (0)