Updating specs to correct some issues with app ID.

This commit is contained in:
mike12345567 2024-10-30 17:12:48 +00:00
parent 38760897bf
commit 037a33dc7d
8 changed files with 26 additions and 17 deletions

View File

@ -56,7 +56,7 @@
"required": true,
"description": "The ID of the app which this request is targeting.",
"schema": {
"default": "{{ appId }}",
"default": "{{appId}}",
"type": "string"
}
},
@ -66,7 +66,7 @@
"required": true,
"description": "The ID of the app which this request is targeting.",
"schema": {
"default": "{{ appId }}",
"default": "{{appId}}",
"type": "string"
}
},
@ -3512,7 +3512,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/viewSearch"
"$ref": "#/components/schemas/nameSearch"
}
}
}

View File

@ -43,7 +43,7 @@ components:
required: true
description: The ID of the app which this request is targeting.
schema:
default: "{{ appId }}"
default: "{{appId}}"
type: string
appIdUrl:
in: path
@ -51,7 +51,7 @@ components:
required: true
description: The ID of the app which this request is targeting.
schema:
default: "{{ appId }}"
default: "{{appId}}"
type: string
queryId:
in: path
@ -2639,7 +2639,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/viewSearch"
$ref: "#/components/schemas/nameSearch"
responses:
"200":
description: Returns the found views, based on the search parameters.

View File

@ -34,7 +34,7 @@ export const appId = {
required: true,
description: "The ID of the app which this request is targeting.",
schema: {
default: "{{ appId }}",
default: "{{appId}}",
type: "string",
},
}
@ -45,7 +45,7 @@ export const appIdUrl = {
required: true,
description: "The ID of the app which this request is targeting.",
schema: {
default: "{{ appId }}",
default: "{{appId}}",
type: "string",
},
}

View File

@ -19,7 +19,7 @@ function fixView(view: ViewV2, params?: { viewId: string }) {
export async function search(ctx: UserCtx, next: Next) {
const { name } = ctx.request.body
await controller.v2.fetch(ctx)
ctx.body = stringSearch(ctx.body, name)
ctx.body = stringSearch(ctx.body.data, name)
await next()
}
@ -30,7 +30,12 @@ export async function create(ctx: UserCtx, next: Next) {
}
export async function read(ctx: UserCtx, next: Next) {
await controller.v2.get(ctx)
await controller.v2.get({
...ctx,
params: {
viewId: ctx.params.viewId,
},
})
await next()
}

View File

@ -4,18 +4,20 @@ import queryEndpoints from "./queries"
import tableEndpoints from "./tables"
import rowEndpoints from "./rows"
import userEndpoints from "./users"
import viewEndpoints from "./views"
import roleEndpoints from "./roles"
import authorized from "../../../middleware/authorized"
import publicApi from "../../../middleware/publicApi"
import { paramResource, paramSubResource } from "../../../middleware/resourceId"
import { PermissionType, PermissionLevel } from "@budibase/types"
import { PermissionLevel, PermissionType } from "@budibase/types"
import { CtxFn } from "./utils/Endpoint"
import mapperMiddleware from "./middleware/mapper"
import env from "../../../environment"
import { middleware, redis } from "@budibase/backend-core"
import { SelectableDatabase } from "@budibase/backend-core/src/redis/utils"
// below imports don't have declaration files
const Router = require("@koa/router")
const { RateLimit, Stores } = require("koa2-ratelimit")
import { middleware, redis } from "@budibase/backend-core"
import { SelectableDatabase } from "@budibase/backend-core/src/redis/utils"
interface KoaRateLimitOptions {
socket: {
@ -145,8 +147,10 @@ function applyRoutes(
}
applyAdminRoutes(metricEndpoints)
applyAdminRoutes(roleEndpoints)
applyRoutes(appEndpoints, PermissionType.APP, "appId")
applyRoutes(tableEndpoints, PermissionType.TABLE, "tableId")
applyRoutes(viewEndpoints, PermissionType.VIEW, "viewId")
applyRoutes(userEndpoints, PermissionType.USER, "userId")
applyRoutes(queryEndpoints, PermissionType.QUERY, "queryId")
// needs to be applied last for routing purposes, don't override other endpoints

View File

@ -144,7 +144,7 @@ read.push(new Endpoint("get", "/views/:viewId", controller.read))
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/viewSearch'
* $ref: '#/components/schemas/nameSearch'
* responses:
* 200:
* description: Returns the found views, based on the search parameters.

View File

@ -1599,7 +1599,7 @@ export interface operations {
};
requestBody: {
content: {
"application/json": components["schemas"]["viewSearch"];
"application/json": components["schemas"]["nameSearch"];
};
};
};

View File

@ -1,8 +1,8 @@
import { constants, utils } from "@budibase/backend-core"
import { BBContext } from "@budibase/types"
import { Ctx } from "@budibase/types"
export default function ({ requiresAppId }: { requiresAppId?: boolean } = {}) {
return async (ctx: BBContext, next: any) => {
return async (ctx: Ctx, next: any) => {
const appId = await utils.getAppIdFromCtx(ctx)
if (requiresAppId && !appId) {
ctx.throw(