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: README.md
+17-2
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ Typescript API for Space Cloud
3
3
4
4
## Worker API
5
5
6
-
Sample usage
6
+
### Sample usage
7
7
```ts
8
8
import { Server } from"@spacecloud-io/worker";
9
9
import { z } from"zod";
@@ -21,7 +21,7 @@ const router = server.router();
21
21
// Register a query object.
22
22
router.query("operate") // `opId` is the name of the operation
23
23
.method("GET") // Defaults to `GET` for queries and `POST` for mutations
24
-
.url("/v1/operate") // Defaults to `${baseURL}/${opId}`
24
+
.url("/v1/operate") // Defaults to `${baseUrl}/${opId}`
25
25
.input(z.object({ name: z.string() }))
26
26
.output(z.object({ greeting: z.string() }))
27
27
.fn(async (_ctx, req) => {
@@ -30,4 +30,19 @@ router.query("operate") // `opId` is the name of the opera
30
30
31
31
// Start the express http server.
32
32
server.start();
33
+
```
34
+
35
+
The worker generates the some additional routes as shown below:
36
+
37
+
```
38
+
# Routes created to expose the OpenAPI specification generated
39
+
[GET] `${baseUrl}/openapi.json`
40
+
[GET] `${baseUrl}/openapi.yaml`
41
+
```
42
+
43
+
### Saving OpenAPI specification to disk
44
+
45
+
Simply add the flag `--save-openapi` flag to save the autogenerated Open API specification in yaml format. Use the `-f, --file <path>` flag to control the file path. The specification will be persisted at `${file}/openapi.yaml`.
0 commit comments