Skip to content

Commit 800eb74

Browse files
authored
fix: Swagger validation errors (#677)
* fix: Swagger validation errors * undo package changes
1 parent c9a0e5e commit 800eb74

File tree

151 files changed

+466
-482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+466
-482
lines changed

src/server/middleware/error.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ export const createCustomError = (
2222
code,
2323
});
2424

25-
export const customDateTimestampError = (date: string): CustomError => {
26-
return createCustomError(
25+
export const customDateTimestampError = (date: string): CustomError =>
26+
createCustomError(
2727
`Invalid date: ${date}. Needs to new Date() / new Date().toISOstring() / new Date().getTime() / Unix Epoch`,
2828
StatusCodes.BAD_REQUEST,
2929
"INVALID_DATE_TIME",
3030
);
31-
};
3231

3332
export const badAddressError = (address: string): CustomError =>
3433
createCustomError(

src/server/middleware/open-api.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ export const withOpenApi = async (server: FastifyInstance) => {
2929
},
3030
],
3131
},
32-
refResolver: {
33-
buildLocalReference(json, baseUri, fragment, i) {
34-
return json.$id || `def-${i}`;
35-
},
36-
},
3732
});
3833

3934
// Exports the /json endpoint without the Swagger UI.

src/server/routes/auth/access-tokens/create.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Static, Type } from "@sinclair/typebox";
1+
import { Type, type Static } from "@sinclair/typebox";
22
import { buildJWT } from "@thirdweb-dev/auth";
33
import { LocalWallet } from "@thirdweb-dev/wallets";
4-
import { FastifyInstance } from "fastify";
4+
import type { FastifyInstance } from "fastify";
55
import { StatusCodes } from "http-status-codes";
66
import { updateConfiguration } from "../../../../db/configuration/updateConfiguration";
77
import { createToken } from "../../../../db/tokens/createToken";
@@ -16,12 +16,10 @@ const requestBodySchema = Type.Object({
1616
});
1717

1818
const responseBodySchema = Type.Object({
19-
result: Type.Composite([
20-
AccessTokenSchema,
21-
Type.Object({
22-
accessToken: Type.String(),
23-
}),
24-
]),
19+
result: Type.Object({
20+
...AccessTokenSchema.properties,
21+
accessToken: Type.String(),
22+
}),
2523
});
2624

2725
export async function createAccessToken(fastify: FastifyInstance) {
@@ -35,7 +33,7 @@ export async function createAccessToken(fastify: FastifyInstance) {
3533
summary: "Create a new access token",
3634
description: "Create a new access token",
3735
tags: ["Access Tokens"],
38-
operationId: "create",
36+
operationId: "createAccessToken",
3937
body: requestBodySchema,
4038
response: {
4139
...standardResponseSchema,

src/server/routes/auth/access-tokens/getAll.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { getAccessTokens } from "../../../../db/tokens/getAccessTokens";
55
import { AddressSchema } from "../../../schemas/address";
@@ -28,7 +28,7 @@ export async function getAllAccessTokens(fastify: FastifyInstance) {
2828
summary: "Get all access tokens",
2929
description: "Get all access tokens",
3030
tags: ["Access Tokens"],
31-
operationId: "getAll",
31+
operationId: "listAccessTokens",
3232
response: {
3333
...standardResponseSchema,
3434
[StatusCodes.OK]: responseBodySchema,

src/server/routes/auth/access-tokens/revoke.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { revokeToken } from "../../../../db/tokens/revokeToken";
55
import { accessTokenCache } from "../../../../utils/cache/accessToken";
@@ -26,7 +26,7 @@ export async function revokeAccessToken(fastify: FastifyInstance) {
2626
summary: "Revoke an access token",
2727
description: "Revoke an access token",
2828
tags: ["Access Tokens"],
29-
operationId: "revoke",
29+
operationId: "revokeAccessTokens",
3030
body: requestBodySchema,
3131
response: {
3232
...standardResponseSchema,

src/server/routes/auth/access-tokens/update.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { updateToken } from "../../../../db/tokens/updateToken";
55
import { accessTokenCache } from "../../../../utils/cache/accessToken";
@@ -27,7 +27,7 @@ export async function updateAccessToken(fastify: FastifyInstance) {
2727
summary: "Update an access token",
2828
description: "Update an access token",
2929
tags: ["Access Tokens"],
30-
operationId: "update",
30+
operationId: "updateAccessTokens",
3131
body: requestBodySchema,
3232
response: {
3333
...standardResponseSchema,

src/server/routes/auth/permissions/getAll.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { prisma } from "../../../../db/client";
55
import { AddressSchema } from "../../../schemas/address";
@@ -25,7 +25,7 @@ export async function getAllPermissions(fastify: FastifyInstance) {
2525
summary: "Get all permissions",
2626
description: "Get all users with their corresponding permissions",
2727
tags: ["Permissions"],
28-
operationId: "getAll",
28+
operationId: "listAdmins",
2929
response: {
3030
...standardResponseSchema,
3131
[StatusCodes.OK]: responseBodySchema,

src/server/routes/auth/permissions/grant.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { updatePermissions } from "../../../../db/permissions/updatePermissions";
55
import { AddressSchema } from "../../../schemas/address";
@@ -29,7 +29,7 @@ export async function grantPermissions(fastify: FastifyInstance) {
2929
summary: "Grant permissions to user",
3030
description: "Grant permissions to a user",
3131
tags: ["Permissions"],
32-
operationId: "grant",
32+
operationId: "grantAdmin",
3333
body: requestBodySchema,
3434
response: {
3535
...standardResponseSchema,

src/server/routes/auth/permissions/revoke.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { deletePermissions } from "../../../../db/permissions/deletePermissions";
55
import { AddressSchema } from "../../../schemas/address";
@@ -26,7 +26,7 @@ export async function revokePermissions(fastify: FastifyInstance) {
2626
summary: "Revoke permissions from user",
2727
description: "Revoke a user's permissions",
2828
tags: ["Permissions"],
29-
operationId: "revoke",
29+
operationId: "revokeAdmin",
3030
body: requestBodySchema,
3131
response: {
3232
...standardResponseSchema,

src/server/routes/backend-wallet/create.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { WalletType } from "../../../schema/wallet";
55
import { getConfig } from "../../../utils/cache/getConfig";

src/server/routes/chain/get.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Type, type Static } from "@sinclair/typebox";
1+
import { Type } from "@sinclair/typebox";
22
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { getChainMetadata } from "thirdweb/chains";
@@ -46,7 +46,7 @@ export async function getChainData(fastify: FastifyInstance) {
4646
summary: "Get chain details",
4747
description: "Get details about a chain.",
4848
tags: ["Chain"],
49-
operationId: "get",
49+
operationId: "getChain",
5050
querystring: chainRequestQuerystringSchema,
5151
response: {
5252
...standardResponseSchema,

src/server/routes/chain/getAll.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Type, type Static } from "@sinclair/typebox";
1+
import { Type } from "@sinclair/typebox";
22
import { fetchChains } from "@thirdweb-dev/chains";
33
import type { FastifyInstance } from "fastify";
44
import { StatusCodes } from "http-status-codes";
@@ -57,7 +57,7 @@ export async function getAllChainData(fastify: FastifyInstance) {
5757
summary: "Get all chain details",
5858
description: "Get details about all supported chains.",
5959
tags: ["Chain"],
60-
operationId: "getAll",
60+
operationId: "listChains",
6161
response: {
6262
...standardResponseSchema,
6363
[StatusCodes.OK]: responseSchema,

src/server/routes/contract/extensions/account/write/grantAdmin.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { queueTx } from "../../../../../../db/transactions/queueTx";
55
import { getContract } from "../../../../../../utils/cache/getContract";
@@ -41,7 +41,7 @@ export const grantAdmin = async (fastify: FastifyInstance) => {
4141
summary: "Grant admin",
4242
description: "Grant a smart account's admin permission.",
4343
tags: ["Account"],
44-
operationId: "grantAdmin",
44+
operationId: "grantAccountAdmin",
4545
headers: walletWithAAHeaderSchema,
4646
params: contractParamSchema,
4747
body: requestBodySchema,
@@ -69,9 +69,8 @@ export const grantAdmin = async (fastify: FastifyInstance) => {
6969
accountAddress,
7070
});
7171

72-
const tx = await contract.account.grantAdminPermissions.prepare(
73-
signerAddress,
74-
);
72+
const tx =
73+
await contract.account.grantAdminPermissions.prepare(signerAddress);
7574
const queueId = await queueTx({
7675
tx,
7776
chainId,

src/server/routes/contract/extensions/account/write/grantSession.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { queueTx } from "../../../../../../db/transactions/queueTx";
55
import { getContract } from "../../../../../../utils/cache/getContract";
@@ -42,7 +42,7 @@ export const grantSession = async (fastify: FastifyInstance) => {
4242
summary: "Create session key",
4343
description: "Create a session key for a smart account.",
4444
tags: ["Account"],
45-
operationId: "grantSession",
45+
operationId: "grantAccountSession",
4646
params: contractParamSchema,
4747
headers: walletWithAAHeaderSchema,
4848
body: requestBodySchema,

src/server/routes/contract/extensions/account/write/revokeAdmin.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { queueTx } from "../../../../../../db/transactions/queueTx";
55
import { getContract } from "../../../../../../utils/cache/getContract";
@@ -41,7 +41,7 @@ export const revokeAdmin = async (fastify: FastifyInstance) => {
4141
summary: "Revoke admin",
4242
description: "Revoke a smart account's admin permission.",
4343
tags: ["Account"],
44-
operationId: "revokeAdmin",
44+
operationId: "revokeAccountAdmin",
4545
headers: walletWithAAHeaderSchema,
4646
params: contractParamSchema,
4747
body: requestBodySchema,
@@ -69,9 +69,8 @@ export const revokeAdmin = async (fastify: FastifyInstance) => {
6969
accountAddress,
7070
});
7171

72-
const tx = await contract.account.revokeAdminPermissions.prepare(
73-
walletAddress,
74-
);
72+
const tx =
73+
await contract.account.revokeAdminPermissions.prepare(walletAddress);
7574
const queueId = await queueTx({
7675
tx,
7776
chainId,

src/server/routes/contract/extensions/account/write/revokeSession.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { queueTx } from "../../../../../../db/transactions/queueTx";
55
import { getContract } from "../../../../../../utils/cache/getContract";
@@ -41,7 +41,7 @@ export const revokeSession = async (fastify: FastifyInstance) => {
4141
summary: "Revoke session key",
4242
description: "Revoke a session key for a smart account.",
4343
tags: ["Account"],
44-
operationId: "revokeSession",
44+
operationId: "revokeAccountSession",
4545
params: contractParamSchema,
4646
headers: walletWithAAHeaderSchema,
4747
body: requestBodySchema,

src/server/routes/contract/extensions/account/write/updateSession.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { queueTx } from "../../../../../../db/transactions/queueTx";
55
import { getContract } from "../../../../../../utils/cache/getContract";
@@ -43,7 +43,7 @@ export const updateSession = async (fastify: FastifyInstance) => {
4343
summary: "Update session key",
4444
description: "Update a session key for a smart account.",
4545
tags: ["Account"],
46-
operationId: "updateSession",
46+
operationId: "updateAccountSession",
4747
params: contractParamSchema,
4848
headers: walletWithAAHeaderSchema,
4949
body: requestBodySchema,

src/server/routes/contract/extensions/erc1155/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FastifyInstance } from "fastify";
1+
import type { FastifyInstance } from "fastify";
22
import { erc1155BalanceOf } from "./read/balanceOf";
33
import { erc1155CanClaim } from "./read/canClaim";
44
import { erc1155Get } from "./read/get";

src/server/routes/contract/extensions/erc1155/read/balanceOf.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
23
import { StatusCodes } from "http-status-codes";
3-
4-
import { Static, Type } from "@sinclair/typebox";
54
import { getContract } from "../../../../../../utils/cache/getContract";
65
import { AddressSchema } from "../../../../../schemas/address";
76
import {
@@ -48,7 +47,7 @@ export async function erc1155BalanceOf(fastify: FastifyInstance) {
4847
description:
4948
"Get the balance of a specific wallet address for this ERC-1155 contract.",
5049
tags: ["ERC1155"],
51-
operationId: "balanceOf",
50+
operationId: "erc1155-balanceOf",
5251
params: requestSchema,
5352
querystring: querystringSchema,
5453
response: {

src/server/routes/contract/extensions/erc1155/read/canClaim.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { getContract } from "../../../../../../utils/cache/getContract";
55
import {
@@ -45,7 +45,7 @@ export async function erc1155CanClaim(fastify: FastifyInstance) {
4545
description:
4646
"Check if tokens are currently available for claiming, optionally specifying if a specific wallet address can claim.",
4747
tags: ["ERC1155"],
48-
operationId: "canClaim",
48+
operationId: "erc1155-canClaim",
4949
params: requestSchema,
5050
querystring: requestQueryString,
5151
response: {

src/server/routes/contract/extensions/erc1155/read/get.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { getContract } from "../../../../../../utils/cache/getContract";
55
import { nftSchema } from "../../../../../schemas/nft";
@@ -56,7 +56,7 @@ export async function erc1155Get(fastify: FastifyInstance) {
5656
summary: "Get details",
5757
description: "Get the details for a token in an ERC-1155 contract.",
5858
tags: ["ERC1155"],
59-
operationId: "get",
59+
operationId: "erc1155-get",
6060
params: requestSchema,
6161
querystring: querystringSchema,
6262
response: {

src/server/routes/contract/extensions/erc1155/read/getActiveClaimConditions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { getContract } from "../../../../../../utils/cache/getContract";
55
import { claimConditionOutputSchema } from "../../../../../schemas/claimConditions";
@@ -44,7 +44,7 @@ export async function erc1155GetActiveClaimConditions(
4444
description:
4545
"Retrieve the currently active claim phase for a specific token ID, if any.",
4646
tags: ["ERC1155"],
47-
operationId: "getActiveClaimConditions",
47+
operationId: "erc1155-getActiveClaimConditions",
4848
params: requestSchema,
4949
querystring: requestQueryString,
5050
response: {

0 commit comments

Comments
 (0)