Skip to content

Commit 18748e8

Browse files
ci: update api (#8)
Co-authored-by: CI <ci@rman.dev>
1 parent ba51125 commit 18748e8

6 files changed

Lines changed: 25 additions & 9 deletions

File tree

specs/lichess-api.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
openapi: "3.1.0"
22
info:
3-
version: 2.0.113
3+
version: 2.0.114
44
title: Lichess.org API reference
55
contact:
66
name: "Lichess.org API"

specs/schemas/UserExtended.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ allOf:
2424
blocking:
2525
type: boolean
2626
description: only appears if the request is [authenticated with OAuth2](#description/authentication)
27+
fideId:
28+
type: number
2729
required:
2830
- url

specs/tags/games/api-user-username-current-game.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,22 @@ get:
8484
default: false
8585
responses:
8686
"200":
87-
description: The ongoing (or last) game of a user.
87+
description: |
88+
The ongoing (or last) game of a user.
89+
This may be in either PGN or JSON format, depending on the `Accept` header of your request.
8890
headers:
8991
Access-Control-Allow-Origin:
9092
schema:
9193
type: string
9294
default: "'*'"
9395
content:
94-
application/x-chess-pgn:
95-
schema:
96-
$ref: "../../schemas/GamePgn.yaml"
9796
application/json:
9897
schema:
99-
$ref: "../../schemas/GameJson.yaml"
98+
oneOf:
99+
- $ref: "../../schemas/GamePgn.yaml"
100+
- $ref: "../../schemas/GameJson.yaml"
100101
examples:
101-
default:
102+
application/x-chess-pgn:
103+
$ref: "../../examples/games-apiUserCurrentGamePgn.pgn.yaml"
104+
application/json:
102105
$ref: "../../examples/games-apiUserCurrentGameJson.json.yaml"

specs/tags/users/api-user-username.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ get:
3232
schema:
3333
type: boolean
3434
default: false
35+
- in: query
36+
name: fideId
37+
description: Include public FIDE ID if any
38+
schema:
39+
type: boolean
40+
default: false
3541

3642
responses:
3743
"200":

src/client/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,15 @@ export class Lichess {
9999
trophies?: boolean;
100100
profile?: boolean;
101101
rank?: boolean;
102+
fideId?: boolean;
102103
},
103104
) {
104105
const path = `/api/user/${params.username}` as const;
105106
const query = {
106107
trophies: params.trophies,
107108
profile: params.profile,
108109
rank: params.rank,
110+
fideId: params.fideId,
109111
} as const;
110112
const { response, status } = await this.requestor.get({ path, query });
111113
switch (status) {
@@ -648,8 +650,10 @@ export class Lichess {
648650
const { response, status } = await this.requestor.get({ path, query });
649651
switch (status) {
650652
case 200: {
651-
/* mixed */
652-
return { status, response } as const;
653+
const schema = z.union([schemas.GamePgn, schemas.GameJson]);
654+
const json: unknown = await response.clone().json();
655+
const data = schema.parse(json);
656+
return { status, response, data } as const;
653657
}
654658
default: {
655659
throw new Error("Unexpected status code");

src/schemas/UserExtended.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const UserExtended = z.intersection(
1515
followable: z.boolean().optional(),
1616
following: z.boolean().optional(),
1717
blocking: z.boolean().optional(),
18+
fideId: z.number().optional(),
1819
}),
1920
);
2021

0 commit comments

Comments
 (0)