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,18 +103,15 @@ 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
}, },
anyOf: [
{
// (re)note with text, files and poll are optional
properties: {
text: { type: 'string', minLength: 1, maxLength: MAX_NOTE_TEXT_LENGTH, nullable: false },
},
required: ['text'],
},
{
// (re)note with files, text and poll are optional
properties: {
fileIds: { fileIds: {
type: 'array', type: 'array',
uniqueItems: true, uniqueItems: true,
@ -122,27 +119,13 @@ export const paramDef = {
maxItems: 16, maxItems: 16,
items: { type: 'string', format: 'misskey:id' }, items: { type: 'string', format: 'misskey:id' },
}, },
},
required: ['fileIds'],
},
{
// (re)note with files, text and poll are optional
properties: {
mediaIds: { mediaIds: {
deprecated: true,
description: 'Use `fileIds` instead. If both are specified, this property is discarded.',
type: 'array', type: 'array',
uniqueItems: true, uniqueItems: true,
minItems: 1, minItems: 1,
maxItems: 16, maxItems: 16,
items: { type: 'string', format: 'misskey:id' }, items: { type: 'string', format: 'misskey:id' },
}, },
},
required: ['mediaIds'],
},
{
// (re)note with poll, text and files are optional
properties: {
poll: { poll: {
type: 'object', type: 'object',
nullable: true, nullable: true,
@ -161,6 +144,30 @@ export const paramDef = {
required: ['choices'], required: ['choices'],
}, },
}, },
// (re)note with text, files and poll are optional
anyOf: [
{
properties: {
text: { type: 'string' },
},
required: ['text'],
},
{
properties: {
fileIds: { type: 'array' },
},
required: ['fileIds'],
},
{
properties: {
mediaIds: { type: 'array' },
},
required: ['mediaIds'],
},
{
properties: {
poll: { type: 'object' },
},
required: ['poll'], required: ['poll'],
}, },
], ],