Skip to content

Commit 20c7932

Browse files
authored
♻️ Regenerate client to use UUID instead of id integers and update frontend (fastapi#1281)
1 parent 92f183e commit 20c7932

File tree

5 files changed

+80
-41
lines changed

5 files changed

+80
-41
lines changed

frontend/src/client/core/request.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import axios from "axios"
22
import type {
33
AxiosError,
4+
AxiosInstance,
45
AxiosRequestConfig,
56
AxiosResponse,
6-
AxiosInstance,
77
} from "axios"
88

99
import { ApiError } from "./ApiError"
@@ -151,12 +151,12 @@ export const getHeaders = async (
151151
)
152152

153153
if (isStringWithValue(token)) {
154-
headers["Authorization"] = `Bearer ${token}`
154+
headers.Authorization = `Bearer ${token}`
155155
}
156156

157157
if (isStringWithValue(username) && isStringWithValue(password)) {
158158
const credentials = base64(`${username}:${password}`)
159-
headers["Authorization"] = `Basic ${credentials}`
159+
headers.Authorization = `Basic ${credentials}`
160160
}
161161

162162
if (options.body !== undefined) {

frontend/src/client/models.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export type ItemCreate = {
1919
export type ItemPublic = {
2020
title: string
2121
description?: string | null
22-
id: number
23-
owner_id: number
22+
id: string
23+
owner_id: string
2424
}
2525

2626
export type ItemUpdate = {
@@ -65,7 +65,7 @@ export type UserPublic = {
6565
is_active?: boolean
6666
is_superuser?: boolean
6767
full_name?: string | null
68-
id: number
68+
id: string
6969
}
7070

7171
export type UserRegister = {

frontend/src/client/schemas.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,15 @@ export const $ItemCreate = {
6565
title: {
6666
type: "string",
6767
isRequired: true,
68+
maxLength: 255,
69+
minLength: 1,
6870
},
6971
description: {
7072
type: "any-of",
7173
contains: [
7274
{
7375
type: "string",
76+
maxLength: 255,
7477
},
7578
{
7679
type: "null",
@@ -85,25 +88,30 @@ export const $ItemPublic = {
8588
title: {
8689
type: "string",
8790
isRequired: true,
91+
maxLength: 255,
92+
minLength: 1,
8893
},
8994
description: {
9095
type: "any-of",
9196
contains: [
9297
{
9398
type: "string",
99+
maxLength: 255,
94100
},
95101
{
96102
type: "null",
97103
},
98104
],
99105
},
100106
id: {
101-
type: "number",
107+
type: "string",
102108
isRequired: true,
109+
format: "uuid",
103110
},
104111
owner_id: {
105-
type: "number",
112+
type: "string",
106113
isRequired: true,
114+
format: "uuid",
107115
},
108116
},
109117
} as const
@@ -115,6 +123,8 @@ export const $ItemUpdate = {
115123
contains: [
116124
{
117125
type: "string",
126+
maxLength: 255,
127+
minLength: 1,
118128
},
119129
{
120130
type: "null",
@@ -126,6 +136,7 @@ export const $ItemUpdate = {
126136
contains: [
127137
{
128138
type: "string",
139+
maxLength: 255,
129140
},
130141
{
131142
type: "null",
@@ -169,6 +180,8 @@ export const $NewPassword = {
169180
new_password: {
170181
type: "string",
171182
isRequired: true,
183+
maxLength: 40,
184+
minLength: 8,
172185
},
173186
},
174187
} as const
@@ -191,10 +204,14 @@ export const $UpdatePassword = {
191204
current_password: {
192205
type: "string",
193206
isRequired: true,
207+
maxLength: 40,
208+
minLength: 8,
194209
},
195210
new_password: {
196211
type: "string",
197212
isRequired: true,
213+
maxLength: 40,
214+
minLength: 8,
198215
},
199216
},
200217
} as const
@@ -204,6 +221,8 @@ export const $UserCreate = {
204221
email: {
205222
type: "string",
206223
isRequired: true,
224+
format: "email",
225+
maxLength: 255,
207226
},
208227
is_active: {
209228
type: "boolean",
@@ -218,6 +237,7 @@ export const $UserCreate = {
218237
contains: [
219238
{
220239
type: "string",
240+
maxLength: 255,
221241
},
222242
{
223243
type: "null",
@@ -227,6 +247,8 @@ export const $UserCreate = {
227247
password: {
228248
type: "string",
229249
isRequired: true,
250+
maxLength: 40,
251+
minLength: 8,
230252
},
231253
},
232254
} as const
@@ -236,6 +258,8 @@ export const $UserPublic = {
236258
email: {
237259
type: "string",
238260
isRequired: true,
261+
format: "email",
262+
maxLength: 255,
239263
},
240264
is_active: {
241265
type: "boolean",
@@ -250,15 +274,17 @@ export const $UserPublic = {
250274
contains: [
251275
{
252276
type: "string",
277+
maxLength: 255,
253278
},
254279
{
255280
type: "null",
256281
},
257282
],
258283
},
259284
id: {
260-
type: "number",
285+
type: "string",
261286
isRequired: true,
287+
format: "uuid",
262288
},
263289
},
264290
} as const
@@ -268,16 +294,21 @@ export const $UserRegister = {
268294
email: {
269295
type: "string",
270296
isRequired: true,
297+
format: "email",
298+
maxLength: 255,
271299
},
272300
password: {
273301
type: "string",
274302
isRequired: true,
303+
maxLength: 40,
304+
minLength: 8,
275305
},
276306
full_name: {
277307
type: "any-of",
278308
contains: [
279309
{
280310
type: "string",
311+
maxLength: 255,
281312
},
282313
{
283314
type: "null",
@@ -294,6 +325,8 @@ export const $UserUpdate = {
294325
contains: [
295326
{
296327
type: "string",
328+
format: "email",
329+
maxLength: 255,
297330
},
298331
{
299332
type: "null",
@@ -313,6 +346,7 @@ export const $UserUpdate = {
313346
contains: [
314347
{
315348
type: "string",
349+
maxLength: 255,
316350
},
317351
{
318352
type: "null",
@@ -324,6 +358,8 @@ export const $UserUpdate = {
324358
contains: [
325359
{
326360
type: "string",
361+
maxLength: 40,
362+
minLength: 8,
327363
},
328364
{
329365
type: "null",
@@ -340,6 +376,7 @@ export const $UserUpdateMe = {
340376
contains: [
341377
{
342378
type: "string",
379+
maxLength: 255,
343380
},
344381
{
345382
type: "null",
@@ -351,6 +388,8 @@ export const $UserUpdateMe = {
351388
contains: [
352389
{
353390
type: "string",
391+
format: "email",
392+
maxLength: 255,
354393
},
355394
{
356395
type: "null",

0 commit comments

Comments
 (0)