You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/docs/docs/open-api.mdx
+69-2Lines changed: 69 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,65 @@ This will only work for the schemas of the body, responses and individual query
93
93
94
94
You can see an example of its usage in the code snippet above.
95
95
96
+
## Extending Operations with Additional OpenAPI Fields
97
+
98
+
We do not provide first-party support to set all possible OpenAPI fields on the operations such as the `security` field. In addition, you may have some specific needs to modify the fields already set by `ts-rest` such as the `tags` field.
99
+
100
+
Therefore, we have provided an `operationMapper` option to allow you to modify the OpenAPI fields of the operations. This is a callback function, that will receive the operation object and the contract endpoint, and must return a valid OpenAPI operation object.
101
+
A common way to provide data to this function is to utilize the `metadata` field of the contract endpoint. However, feel free to come up with a different solution to doing this if you would not like to include this data in your contracts.
Don't worry if you don't use express or Nest, whatever library you want to use is OK our OpenAPI returns a plain JSON object which is fully compliant with the OpenAPI spec.
143
202
144
-
## Enabling `operationId`'s (Recommended!)
203
+
## Enabling `operationId`s (Recommended!)
204
+
205
+
You can set `setOperationId` to either `true` or `concatenated-path` to set `operationId`s on your endpoints.
206
+
207
+
In the case of setting it to `true`, it will use only the endpoint name from your contract. You have to ensure that the endpoint names are unique across the entire contract.
145
208
146
-
If your contract has unique names for all of your endpoints, you can enable `operationId`'s by setting `setOperationId` to `true` in the options:
209
+
In the case of setting it to `concatenated-path`, it will use the endpoint name concatenated with the path through the nested contract.
210
+
This is useful when you have multiple endpoints with the same name but different paths. This will result in longer but more descriptive `operationId`s.
0 commit comments