serverless-openapi-documenter 0.0.71 → 0.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -1
- package/package.json +1 -1
- package/src/definitionGenerator.js +879 -730
- package/test/unit/openAPIGenerator.spec.js +241 -200
package/README.md
CHANGED
|
@@ -751,6 +751,8 @@ requestModels:
|
|
|
751
751
|
|
|
752
752
|
#### `methodResponses`
|
|
753
753
|
|
|
754
|
+
`methodResponses` is a mandatory property and should include the `responseBody` and `description` properties.
|
|
755
|
+
|
|
754
756
|
You can define the response schemas by defining properties for your function event.
|
|
755
757
|
|
|
756
758
|
For an example of a `methodResponses` configuration for an event see below:
|
|
@@ -763,6 +765,12 @@ methodResponse:
|
|
|
763
765
|
responseModels:
|
|
764
766
|
application/json: "CreateResponse"
|
|
765
767
|
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
|
|
766
774
|
responseHeaders:
|
|
767
775
|
X-Rate-Limit-Limit:
|
|
768
776
|
description: The number of allowed requests in the current period
|
|
@@ -788,6 +796,53 @@ responseModels:
|
|
|
788
796
|
application/xml: "CreateResponseXML"
|
|
789
797
|
```
|
|
790
798
|
|
|
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
|
+
|
|
791
846
|
##### `responseHeaders`
|
|
792
847
|
|
|
793
848
|
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"
|
|
|
882
937
|
|
|
883
938
|
## Example configuration
|
|
884
939
|
|
|
885
|
-
Please view the example [serverless.yml](test/serverless-tests/
|
|
940
|
+
Please view the example [serverless.yml](test/serverless-tests/best/serverless.yml).
|
|
886
941
|
|
|
887
942
|
## Notes on schemas
|
|
888
943
|
|