summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/openapi/schemas.ts
diff options
context:
space:
mode:
authorzyoshoka <107108195+zyoshoka@users.noreply.github.com>2025-05-23 20:27:16 +0900
committerGitHub <noreply@github.com>2025-05-23 20:27:16 +0900
commit9c98c13743d0d5af98128f2caf43fb83f2dcea2f (patch)
tree06a0fbb8e9dcf340b11d16ff25ca3cbd439a298b /packages/backend/src/server/api/openapi/schemas.ts
parentenhance(frontend): tweak default preferences (diff)
downloadmisskey-9c98c13743d0d5af98128f2caf43fb83f2dcea2f.tar.gz
misskey-9c98c13743d0d5af98128f2caf43fb83f2dcea2f.tar.bz2
misskey-9c98c13743d0d5af98128f2caf43fb83f2dcea2f.zip
fix(backend): better nullable ref schema representation (#16088)
* fix(backend): better nullable ref schema representation * refactor
Diffstat (limited to 'packages/backend/src/server/api/openapi/schemas.ts')
-rw-r--r--packages/backend/src/server/api/openapi/schemas.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/packages/backend/src/server/api/openapi/schemas.ts b/packages/backend/src/server/api/openapi/schemas.ts
index c80dda8d96..1cdcbebd1a 100644
--- a/packages/backend/src/server/api/openapi/schemas.ts
+++ b/packages/backend/src/server/api/openapi/schemas.ts
@@ -38,14 +38,13 @@ export function convertSchemaToOpenApiSchema(schema: Schema, type: 'param' | 're
if (type === 'res' && schema.ref && (!schema.selfRef || includeSelfRef)) {
const $ref = `#/components/schemas/${schema.ref}`;
- if (schema.nullable || schema.optional) {
- res.allOf = [{ $ref }];
+ if (schema.nullable) {
+ res.oneOf = [{ $ref }, { type: 'null' }];
} else {
res.$ref = $ref;
}
- }
-
- if (schema.nullable) {
+ delete res.type;
+ } else if (schema.nullable) {
if (Array.isArray(schema.type) && !schema.type.includes('null')) {
res.type.push('null');
} else if (typeof schema.type === 'string') {