1
0
forked from mirror/misskey

anyOf内にバリデーションを書いても最初の一つしかチェックされない

This commit is contained in:
tamaina 2023-02-25 09:33:19 +00:00
parent 43cfb5092a
commit c8111659e1

View File

@ -103,63 +103,70 @@ export const paramDef = {
replyId: { type: 'string', format: 'misskey:id', nullable: true }, replyId: { type: 'string', format: 'misskey:id', nullable: true },
renoteId: { type: 'string', format: 'misskey:id', nullable: true }, renoteId: { type: 'string', format: 'misskey:id', nullable: true },
channelId: { type: 'string', format: 'misskey:id', nullable: true }, channelId: { type: 'string', format: 'misskey:id', nullable: true },
// anyOf内にバリデーションを書いても最初の一つしかチェックされない
// See https://github.com/misskey-dev/misskey/pull/10082
text: {
type: 'string',
minLength: 1,
maxLength: MAX_NOTE_TEXT_LENGTH,
nullable: false
},
fileIds: {
type: 'array',
uniqueItems: true,
minItems: 1,
maxItems: 16,
items: { type: 'string', format: 'misskey:id' },
},
mediaIds: {
type: 'array',
uniqueItems: true,
minItems: 1,
maxItems: 16,
items: { type: 'string', format: 'misskey:id' },
},
poll: {
type: 'object',
nullable: true,
properties: {
choices: {
type: 'array',
uniqueItems: true,
minItems: 2,
maxItems: 10,
items: { type: 'string', minLength: 1, maxLength: 50 },
},
multiple: { type: 'boolean' },
expiresAt: { type: 'integer', nullable: true },
expiredAfter: { type: 'integer', nullable: true, minimum: 1 },
},
required: ['choices'],
},
}, },
// (re)note with text, files and poll are optional
anyOf: [ anyOf: [
{ {
// (re)note with text, files and poll are optional
properties: { properties: {
text: { type: 'string', minLength: 1, maxLength: MAX_NOTE_TEXT_LENGTH, nullable: false }, text: { type: 'string' },
}, },
required: ['text'], required: ['text'],
}, },
{ {
// (re)note with files, text and poll are optional
properties: { properties: {
fileIds: { fileIds: { type: 'array' },
type: 'array',
uniqueItems: true,
minItems: 1,
maxItems: 16,
items: { type: 'string', format: 'misskey:id' },
},
}, },
required: ['fileIds'], required: ['fileIds'],
}, },
{ {
// (re)note with files, text and poll are optional
properties: { properties: {
mediaIds: { mediaIds: { type: 'array' },
deprecated: true,
description: 'Use `fileIds` instead. If both are specified, this property is discarded.',
type: 'array',
uniqueItems: true,
minItems: 1,
maxItems: 16,
items: { type: 'string', format: 'misskey:id' },
},
}, },
required: ['mediaIds'], required: ['mediaIds'],
}, },
{ {
// (re)note with poll, text and files are optional
properties: { properties: {
poll: { poll: { type: 'object' },
type: 'object',
nullable: true,
properties: {
choices: {
type: 'array',
uniqueItems: true,
minItems: 2,
maxItems: 10,
items: { type: 'string', minLength: 1, maxLength: 50 },
},
multiple: { type: 'boolean' },
expiresAt: { type: 'integer', nullable: true },
expiredAfter: { type: 'integer', nullable: true, minimum: 1 },
},
required: ['choices'],
},
}, },
required: ['poll'], required: ['poll'],
}, },