Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(api): close the remaining gaps in the auth schema emitter

Andrej Acevski16281884e772
diff --git a/apps/api/src/auth-openapi.ts b/apps/api/src/auth-openapi.ts
index 6769495a0..c696ed045 100644
--- a/apps/api/src/auth-openapi.ts
+++ b/apps/api/src/auth-openapi.ts
@@ -178,6 +178,7 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
}),
logo: z
.string()
+ .nullable()
.optional()
.openapi({ description: "The logo of the organization" }),
metadata: z
@@ -188,7 +189,7 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
description:
"Whether to keep the current active organization active after creating a new one. Eg: true",
}),
- description: z.string().optional(),
+ description: z.string().nullable().optional(),
}),
},
},
@@ -219,7 +220,7 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
role: z
.string()
.openapi({ description: "The name of the role to create" }),
- permission: z.record(z.string(), z.unknown()).openapi({
+ permission: z.record(z.string(), z.array(z.string())).openapi({
description: "The permission to assign to the role",
}),
additionalFields: z.record(z.string(), z.unknown()).optional(),
@@ -323,7 +324,27 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
request: {
body: {
required: true,
- content: { "application/json": { schema: z.unknown() } },
+ content: {
+ "application/json": {
+ schema: z.intersection(
+ z.object({
+ organizationId: z.string().optional(),
+ }),
+ z.union([
+ z.object({
+ roleName: z
+ .string()
+ .openapi({ description: "The name of the role to delete" }),
+ }),
+ z.object({
+ roleId: z
+ .string()
+ .openapi({ description: "The id of the role to delete" }),
+ }),
+ ]),
+ ),
+ },
+ },
},
},
responses: {
@@ -391,7 +412,7 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
description: "Get an invitation by ID",
request: {
query: z.object({
- id: z.string().optional(),
+ id: z.string(),
}),
},
responses: {
@@ -902,7 +923,7 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
content: {
"application/json": {
schema: z.object({
- organizationId: z.string().optional().openapi({
+ organizationId: z.string().nullable().optional().openapi({
description:
'The organization id to set as active. It can be null to unset the active organization. Eg: "org-id"',
}),
@@ -936,7 +957,7 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
content: {
"application/json": {
schema: z.object({
- teamId: z.string().optional().openapi({
+ teamId: z.string().nullable().optional().openapi({
description:
"The team id to set as active. It can be null to unset the active team",
}),
@@ -967,7 +988,7 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
"application/json": {
schema: z.object({
data: z.object({
- description: z.string().optional(),
+ description: z.string().nullable().optional(),
name: z
.string()
.optional()
@@ -978,6 +999,7 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
.openapi({ description: "The slug of the organization" }),
logo: z
.string()
+ .nullable()
.optional()
.openapi({ description: "The logo of the organization" }),
metadata: z
@@ -1061,7 +1083,33 @@ export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {
request: {
body: {
required: true,
- content: { "application/json": { schema: z.unknown() } },
+ content: {
+ "application/json": {
+ schema: z.intersection(
+ z.object({
+ organizationId: z.string().optional(),
+ data: z.object({
+ permission: z
+ .record(z.string(), z.array(z.string()))
+ .optional(),
+ roleName: z.string().optional(),
+ }),
+ }),
+ z.union([
+ z.object({
+ roleName: z
+ .string()
+ .openapi({ description: "The name of the role to update" }),
+ }),
+ z.object({
+ roleId: z
+ .string()
+ .openapi({ description: "The id of the role to update" }),
+ }),
+ ]),
+ ),
+ },
+ },
},
},
responses: {
diff --git a/apps/docs/openapi.json b/apps/docs/openapi.json
index 69ddb7f95..fcdd45591 100644
--- a/apps/docs/openapi.json
+++ b/apps/docs/openapi.json
@@ -3471,7 +3471,10 @@
"description": "The user id of the organization creator. If not provided, the current user will be used. Should only be used by admins or when called by the server. server-only. Eg: \"user-id\""
},
"logo": {
- "type": "string",
+ "type": [
+ "string",
+ "null"
+ ],
"description": "The logo of the organization"
},
"metadata": {
@@ -3484,7 +3487,10 @@
"description": "Whether to keep the current active organization active after creating a new one. Eg: true"
},
"description": {
- "type": "string"
+ "type": [
+ "string",
+ "null"
+ ]
}
},
"required": [
@@ -3534,7 +3540,12 @@
},
"permission": {
"type": "object",
- "additionalProperties": {},
+ "additionalProperties": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
"description": "The permission to assign to the role"
},
"additionalFields": {
@@ -3693,7 +3704,46 @@
"required": true,
"content": {
"application/json": {
- "schema": {}
+ "schema": {
+ "allOf": [
+ {
+ "type": "object",
+ "properties": {
+ "organizationId": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "roleName": {
+ "type": "string",
+ "description": "The name of the role to delete"
+ }
+ },
+ "required": [
+ "roleName"
+ ]
+ },
+ {
+ "type": "object",
+ "properties": {
+ "roleId": {
+ "type": "string",
+ "description": "The id of the role to delete"
+ }
+ },
+ "required": [
+ "roleId"
+ ]
+ }
+ ]
+ }
+ ]
+ }
}
}
},
@@ -3806,7 +3856,7 @@
"schema": {
"type": "string"
},
- "required": false,
+ "required": true,
"name": "id",
"in": "query"
}
@@ -4669,7 +4719,10 @@
"type": "object",
"properties": {
"organizationId": {
- "type": "string",
+ "type": [
+ "string",
+ "null"
+ ],
"description": "The organization id to set as active. It can be null to unset the active organization. Eg: \"org-id\""
},
"organizationSlug": {
@@ -4712,7 +4765,10 @@
"type": "object",
"properties": {
"teamId": {
- "type": "string",
+ "type": [
+ "string",
+ "null"
+ ],
"description": "The team id to set as active. It can be null to unset the active team"
}
}
@@ -4754,7 +4810,10 @@
"type": "object",
"properties": {
"description": {
- "type": "string"
+ "type": [
+ "string",
+ "null"
+ ]
},
"name": {
"type": "string",
@@ -4765,7 +4824,10 @@
"description": "The slug of the organization"
},
"logo": {
- "type": "string",
+ "type": [
+ "string",
+ "null"
+ ],
"description": "The logo of the organization"
},
"metadata": {
@@ -4905,7 +4967,66 @@
"required": true,
"content": {
"application/json": {
- "schema": {}
+ "schema": {
+ "allOf": [
+ {
+ "type": "object",
+ "properties": {
+ "organizationId": {
+ "type": "string"
+ },
+ "data": {
+ "type": "object",
+ "properties": {
+ "permission": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "roleName": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "required": [
+ "data"
+ ]
+ },
+ {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "roleName": {
+ "type": "string",
+ "description": "The name of the role to update"
+ }
+ },
+ "required": [
+ "roleName"
+ ]
+ },
+ {
+ "type": "object",
+ "properties": {
+ "roleId": {
+ "type": "string",
+ "description": "The id of the role to update"
+ }
+ },
+ "required": [
+ "roleId"
+ ]
+ }
+ ]
+ }
+ ]
+ }
}
}
},