-
Notifications
You must be signed in to change notification settings - Fork 0
/
openapi.ts
62 lines (55 loc) · 1.48 KB
/
openapi.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { generateOpenApiDocument } from "trpc-openapi";
import { ExtendedDocument, ExtendedOperationObject } from "./extended-types";
import { appRouter } from "./router";
const openApiDocument = generateOpenApiDocument(appRouter, {
title: "Speakeasy Bar API",
description: "An API to order drinks from the Speakeasy Bar",
version: "1.0.0",
baseUrl: "http://localhost:3000",
docsUrl: "http://example.com/docs",
tags: ["drinks"],
});
openApiDocument.tags = [
{
name: "drinks",
description: "Operations related to drinks",
},
];
openApiDocument.components = {
...openApiDocument.components,
schemas: openApiDocument?.components?.schemas || {},
};
(openApiDocument as ExtendedDocument)["x-speakeasy-retries"] = {
strategy: "backoff",
backoff: {
initialInterval: 500,
maxInterval: 60000,
maxElapsedTime: 3600000,
exponent: 1.5,
},
statusCodes: ["5XX"],
retryConnectionErrors: true,
};
if (
openApiDocument.paths &&
openApiDocument.paths["/find"] &&
openApiDocument.paths["/find"].get
) {
(openApiDocument.paths["/find"].get as ExtendedOperationObject)[
"x-speakeasy-name-override"
] = "searchDrink";
(openApiDocument.paths["/find"].get as ExtendedOperationObject)[
"x-speakeasy-retries"
] = {
strategy: "backoff",
backoff: {
initialInterval: 500,
maxInterval: 60000,
maxElapsedTime: 3600000,
exponent: 1.5,
},
statusCodes: ["5XX"],
retryConnectionErrors: true,
};
}
export { openApiDocument };