Skip to content

Commit e82b1c1

Browse files
committed
fmt
1 parent 65d7830 commit e82b1c1

2 files changed

Lines changed: 30 additions & 32 deletions

File tree

src/shikimori/mod.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141

4242
export {doc} from './openapi.ts'
4343

44+
// --- Global schemas ---
4445
doc.addSchemas({
4546
achievements,
4647
anime,
@@ -80,7 +81,7 @@ doc.addSchemas({
8081
videos,
8182
})
8283

83-
//////////////////////////////// Responses
84+
// --- Global responses ---
8485
// const BadRequestResponse = doc.addResponse('BadRequest', (t) => {
8586
// t.describe('The given parameters could not be parsed')
8687
// t.content('application/json', z.any())
@@ -108,8 +109,7 @@ const NotFoundResponse = doc.addResponse('NotFound', (t) => {
108109
t.content('application/json', z.object())
109110
})
110111

111-
//////////////////////////////// Paths
112-
//////////////// Achievements
112+
// --- Achievements ---
113113
doc.addPath('/api/achievements').get((t) => {
114114
t.tag('achievements')
115115
t.describe('List user achievements')
@@ -124,7 +124,7 @@ doc.addPath('/api/achievements').get((t) => {
124124
})
125125
})
126126

127-
//////////////// Animes
127+
// --- Animes ---
128128
doc.addPath('/api/animes').get((t) => {
129129
t.tag('anime')
130130
t.describe('List animes')
@@ -235,7 +235,7 @@ doc.addPath('/api/animes/{id}/topics', {id: (t) => t.schema(animeID)}).get((t) =
235235
t.response(401, UnauthorizedResponse)
236236
})
237237

238-
//////////////// Manga
238+
// --- Manga ---
239239
doc.addPath('/api/mangas').get((t) => {
240240
t.tag('manga')
241241
t.describe('list manga')
@@ -319,7 +319,7 @@ doc.addPath('/api/mangas/{id}/topics', {id: (t) => t.schema(ID)}).get((t) => {
319319
t.response(401, UnauthorizedResponse)
320320
})
321321

322-
//////////////// Ranobe
322+
// --- Ranobe ---
323323
doc.addPath('/api/ranobe').get((t) => {
324324
t.tag('ranobe')
325325
t.describe('List ranobe')
@@ -401,7 +401,7 @@ doc.addPath('/api/ranobe/{id}/topics', {id: (t) => t.schema(ID)}).get((t) => {
401401
t.response(401, UnauthorizedResponse)
402402
})
403403

404-
//////////////// Characters
404+
// --- Characters ---
405405
doc.addPath('/api/characters/{id}', {id: (t) => t.schema(ID)}).get((t) => {
406406
t.tag('characters')
407407
t.describe('Show a character')
@@ -422,7 +422,7 @@ doc.addPath('/api/characters/search').get((t) => {
422422
})
423423
})
424424

425-
//////////////// Peoples / Persons
425+
// --- Peoples / Persons ---
426426
doc.addPath('/api/people/{id}', {id: (t) => t.schema(ID)}).get((t) => {
427427
t.tag('people')
428428
t.describe('Show a person')
@@ -434,7 +434,7 @@ doc.addPath('/api/people/search').get((t) => {
434434
t.operationId('find_person')
435435
})
436436

437-
//////////////// Constants
437+
// --- Constants ---
438438
doc.addPath('/api/constants/anime').get((t) => {
439439
t.tag('constants')
440440
t.operationId('get_constants_anime')
@@ -508,7 +508,6 @@ doc.addPath('/api/constants/smileys').get((t) => {
508508
})
509509
})
510510

511-
////////////////
512511
doc.addPath('/api/genres').get((t) => {
513512
t.tag('genres')
514513
t.operationId('list_genres')
@@ -528,9 +527,9 @@ doc.addPath('/api/studios').get((t) => {
528527
})
529528
})
530529

531-
//////////////// Users
530+
// --- Users ---
532531
doc
533-
.addPath('/api/users') //
532+
.addPath('/api/users')
534533
.parameter('query', 'page', (t) => {
535534
t.schema(usersSearchQuery.shape.page)
536535
})
@@ -553,7 +552,7 @@ doc
553552
doc
554553
.addPath('/api/users/{id}', {
555554
id: (t) => t.schema(userID),
556-
}) //
555+
})
557556
.get((t) => {
558557
t.tag('v1_user')
559558
t.operationId('get_user')
@@ -565,7 +564,7 @@ doc
565564
})
566565

567566
doc
568-
.addPath('/api/users/whoami') //
567+
.addPath('/api/users/whoami')
569568
.get((t) => {
570569
t.tag('v1_user')
571570
t.security(oauth2)
@@ -578,7 +577,7 @@ doc
578577
t.response(401, UnauthorizedResponse)
579578
})
580579

581-
//////////////// User Rates
580+
// --- User Rates ---
582581
doc
583582
.addPath('/api/user_rates/{type}/cleanup', {
584583
type: (t) => t.schema(z.enum(['anime', 'manga'])),
@@ -607,9 +606,8 @@ doc
607606
})
608607
})
609608

610-
//////////////// User Rates 2
611-
doc
612-
.addPath('/api/v2/user_rates') //
609+
// --- User Rates 2 ---
610+
doc.addPath('/api/v2/user_rates')
613611
.parameter('query', 'user_id', (t) => t.schema(userRatesQuery.shape.user_id))
614612
.parameter('query', 'target_id', (t) => t.schema(userRatesQuery.shape.target_id))
615613
.parameter('query', 'target_type', (t) => t.schema(userRatesQuery.shape.target_type))
@@ -724,7 +722,7 @@ doc
724722
t.response(401, UnauthorizedResponse)
725723
})
726724

727-
//////////////// Videos
725+
// --- Videos ---
728726
doc
729727
.addPath('/api/animes/{anime_id}/videos', {
730728
anime_id: (t) => t.schema(animeID),

src/shikimori/schema.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {z} from 'zod'
22

3-
//////////////////////////////// Error
3+
// --- Error ---
44
export const UnauthorizedSchema = z.object({
55
error: z.string(),
66
error_description: z.string(),
@@ -13,10 +13,10 @@ export const NotFoundSchema = z
1313
})
1414
.describe('Page Not Found')
1515

16-
////////////////////////////////
16+
// --- shared ---
1717
export const ID = z.int().positive().describe('The ID')
1818

19-
//////////////////////////////// User
19+
// --- User ---
2020
export const userAnimeStatus = z.enum(['planned', 'watching', 'rewatching', 'completed', 'on_hold', 'dropped'])
2121

2222
export const userID = ID.describe('The user ID').meta({example: 406192})
@@ -43,7 +43,7 @@ export const userInfo = z.object({
4343
...userInfoAdditional.shape,
4444
})
4545

46-
//////////////////////////////// Users
46+
// --- Users ---
4747
export const users = z.array(user)
4848

4949
export const usersSearchQuery = z.object({
@@ -52,7 +52,7 @@ export const usersSearchQuery = z.object({
5252
search: z.string().optional(),
5353
})
5454

55-
//////////////////////////////// UserRates
55+
// --- UserRates ---
5656
export const userAnimeTarget = z.enum(['Anime', 'Mange'])
5757
export const userRates = z.object({
5858
id: z.number().positive().describe('The user rate ID'),
@@ -101,11 +101,11 @@ export const userRatesCreateParams = z.object({
101101
...userRatesUpdateParams.shape,
102102
})
103103

104-
//////////////////////////////// Anime
104+
// --- Anime ---
105105
export const animeKind = z.enum(['tv', 'movie', 'ova', 'ona', 'special', 'tv_special', 'music', 'pv', 'cm'])
106106
export const animeRating = z.enum(['none', 'g', 'pg', 'pg_13', 'r', 'r_plus', 'rx'])
107107
export const animeStatus = z.enum(['anons', 'ongoing', 'released'])
108-
export const animeID = z //
108+
export const animeID = z
109109
.number()
110110
.int()
111111
.positive()
@@ -213,7 +213,7 @@ export const studio = z
213213

214214
export const studios = z.array(studio)
215215

216-
//////////////////////////////// Anime Search
216+
// --- Anime Search ---
217217
export const animeSearchQuery_order = z.enum([
218218
'id',
219219
'id_desc',
@@ -341,7 +341,7 @@ export const animeShort = anime.pick({
341341
})
342342
export const animeList = z.array(animeShort)
343343

344-
//////////////////////////////// Manga Search
344+
// --- Manga Search ---
345345
export const mangeSearchQuery_order = z.enum([
346346
'id',
347347
'id_desc',
@@ -390,7 +390,7 @@ export const mangaSearchQuery = z
390390
})
391391
.partial()
392392

393-
//////////////////////////////// Manga
393+
// --- Manga ---
394394
export const manga = z.object({
395395
id: ID,
396396
name: z.string().describe('The name of the manga'),
@@ -460,7 +460,7 @@ export const mangaShort = manga.pick({
460460
})
461461
export const mangaList = z.array(mangaShort)
462462

463-
////////
463+
// ---
464464
export const characterFull = z.object({
465465
id: ID,
466466
name: z.string(),
@@ -603,7 +603,7 @@ export const topicsQuery = z
603603
})
604604
.partial()
605605

606-
////////////////
606+
// ---
607607
export const genre = z.object({
608608
id: z.number().positive(),
609609
name: z.string(),
@@ -612,7 +612,6 @@ export const genre = z.object({
612612
})
613613
export const genres = z.array(genre)
614614

615-
//
616615
export const achievement = z.object({
617616
user_id: userID,
618617
id: ID,
@@ -622,4 +621,5 @@ export const achievement = z.object({
622621
created_at: z.iso.datetime(),
623622
updated_at: z.iso.datetime(),
624623
})
624+
625625
export const achievements = z.array(achievement)

0 commit comments

Comments
 (0)