-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json-schema配下の最新化 #12312
json-schema配下の最新化 #12312
Changes from 7 commits
e979743
fac1d27
273dbea
0b533c9
700008b
09c564b
ff1676c
1e505a2
219354f
7630cbe
b16fe1e
123f3d7
14a3eba
5f2d680
6b22253
3a50c7f
f1dfd31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ export const packedDriveFileSchema = { | |
}, | ||
url: { | ||
type: 'string', | ||
optional: false, nullable: true, | ||
optional: false, nullable: false, | ||
format: 'url', | ||
}, | ||
thumbnailUrl: { | ||
|
@@ -94,7 +94,7 @@ export const packedDriveFileSchema = { | |
}, | ||
folder: { | ||
type: 'object', | ||
optional: true, nullable: true, | ||
optional: false, nullable: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optionalであることを意図しています There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 直しました:pray: |
||
ref: 'DriveFolder', | ||
}, | ||
userId: { | ||
|
@@ -105,7 +105,7 @@ export const packedDriveFileSchema = { | |
}, | ||
user: { | ||
type: 'object', | ||
optional: true, nullable: true, | ||
optional: false, nullable: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optionalであることを意図しています There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 直しました:pray: |
||
ref: 'UserLite', | ||
}, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,12 @@ export const packedDriveFolderSchema = { | |
type: 'string', | ||
optional: false, nullable: false, | ||
}, | ||
parentId: { | ||
type: 'string', | ||
optional: false, nullable: true, | ||
format: 'id', | ||
example: 'xxxxxxxxxx', | ||
}, | ||
foldersCount: { | ||
type: 'number', | ||
optional: true, nullable: false, | ||
|
@@ -29,15 +35,9 @@ export const packedDriveFolderSchema = { | |
type: 'number', | ||
optional: true, nullable: false, | ||
}, | ||
parentId: { | ||
type: 'string', | ||
optional: false, nullable: true, | ||
format: 'id', | ||
example: 'xxxxxxxxxx', | ||
}, | ||
parent: { | ||
type: 'object', | ||
optional: true, nullable: true, | ||
optional: true, nullable: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nullが入るようになる可能性はある(親フォルダがない場合など) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 直しました:pray: |
||
ref: 'DriveFolder', | ||
}, | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hint.packedUsers.get(userId)
からundefinedを引き剥がすための対応です。!
マークで対応することも可能でしたが、lintの警告が出てしまったためこのような形になりました。不都合あれば戻しますので、お手数ですがその際はご指摘願います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Misskeyのバックエンド見ていただければわかりますが普通に
!
は使われている(lintを無視している)のでどっちでもいい気がいたします)(方針に関してはしゅいろ氏あたりに聞いてみてください)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ifで弾く書き方だと、読み手に「undefinedが入る可能性があるのか」と思わせかねないのでそのような可能性がないことが明らかな場合は
!
で書くようにしてますね(とはいえ気軽には使いたくないのでlintのwarnは出すようにしてます)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここはundefinedになる可能性が十分あるので(packedUsersそのものも、packedUsersのなかにuserIdがない可能性もありえる)、今の実装でも良いのかなと思いつつ…
どうしたら良いのか分からなくなりつつあるので、方針を確認させて下さい:pray:
①このまま
②もとに戻す(ただしjson-schemaの型と合わない)
③もとに戻しつつ、
hint.packedUsers.get(userId)!
として型を合わせる④json-schema側をundefined許容にする
⑤③をより安全にする(
packedUsers
のnullチェックだけじゃなく、hasでuserIdの有無を見る)