fix(backend): better nullable ref schema representation (#16088)

* fix(backend): better nullable ref schema representation

* refactor
This commit is contained in:
zyoshoka 2025-05-23 20:27:16 +09:00 committed by GitHub
parent bbbc68a772
commit 9c98c13743
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 5 deletions

View File

@ -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') {