Skip to content

Commit 1be9fa9

Browse files
committed
run generate-client.sh
1 parent efb06ff commit 1be9fa9

File tree

6 files changed

+62
-76
lines changed

6 files changed

+62
-76
lines changed

backend/app/api/routes/users.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def create_user(*, session: SessionDep, user_in: UserCreate) -> Any:
5656
"""
5757
Create new user.
5858
"""
59+
print(f"CREATING new user: {user_in}")
5960
user = crud.get_user_by_email(session=session, email=user_in.email)
6061
if user:
6162
raise HTTPException(

frontend/src/client/core/ApiRequestOptions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ export type ApiRequestOptions<T = unknown> = {
1818
readonly responseHeader?: string
1919
readonly responseTransformer?: (data: unknown) => Promise<T>
2020
readonly url: string
21-
readonly withCredentials?: boolean
2221
}

frontend/src/client/core/request.ts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ export const getHeaders = async <T>(
178178
} else if (options.formData !== undefined) {
179179
if (options.mediaType) {
180180
headers["Content-Type"] = options.mediaType
181-
} else {
182-
headers["Content-Type"] = "application/x-www-form-urlencoded"
183181
}
184182
}
185183

@@ -205,31 +203,15 @@ export const sendRequest = async <T>(
205203
): Promise<AxiosResponse<T>> => {
206204
const controller = new AbortController()
207205

208-
let data = body;
209-
210-
// If we have formData but it's not a FormData instance,
211-
// and Content-Type is application/x-www-form-urlencoded
212-
if (options.formData && !isFormData(options.formData) &&
213-
headers["Content-Type"] === "application/x-www-form-urlencoded") {
214-
const params = new URLSearchParams();
215-
Object.entries(options.formData).forEach(([key, value]) => {
216-
if (value !== undefined && value !== null) {
217-
params.append(key, String(value));
218-
}
219-
});
220-
data = params;
221-
} else {
222-
data = body ?? formData;
223-
}
224-
225206
let requestConfig: AxiosRequestConfig = {
226-
data: data,
207+
data: body ?? formData,
227208
headers,
228209
method: options.method,
229210
signal: controller.signal,
230211
url,
231-
withCredentials: options.withCredentials ?? config.WITH_CREDENTIALS,
212+
withCredentials: config.WITH_CREDENTIALS,
232213
}
214+
233215
onCancel(() => controller.abort())
234216

235217
for (const fn of config.interceptors.request._fns) {
@@ -385,13 +367,15 @@ export const request = <T>(
385367
if (options.responseTransformer && isSuccess(response.status)) {
386368
transformedBody = await options.responseTransformer(responseBody)
387369
}
370+
388371
const result: ApiResult = {
389372
url,
390373
ok: isSuccess(response.status),
391374
status: response.status,
392375
statusText: response.statusText,
393376
body: responseHeader ?? transformedBody,
394377
}
378+
395379
catchErrorCodes(options, result)
396380

397381
resolve(result.body)

frontend/src/client/sdk.gen.ts

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import type {
1515
ItemsDeleteItemData,
1616
ItemsDeleteItemResponse,
1717
LoginLoginAccessTokenData,
18-
LogoutResponse,
1918
LoginLoginAccessTokenResponse,
2019
LoginTestTokenResponse,
2120
LoginRecoverPasswordData,
@@ -24,6 +23,9 @@ import type {
2423
LoginResetPasswordResponse,
2524
LoginRecoverPasswordHtmlContentData,
2625
LoginRecoverPasswordHtmlContentResponse,
26+
LoginLogoutResponse,
27+
PrivateCreateUserData,
28+
PrivateCreateUserResponse,
2729
UsersReadUsersData,
2830
UsersReadUsersResponse,
2931
UsersCreateUserData,
@@ -67,7 +69,6 @@ export class ItemsService {
6769
skip: data.skip,
6870
limit: data.limit,
6971
},
70-
withCredentials: true,
7172
errors: {
7273
422: "Validation Error",
7374
},
@@ -90,7 +91,6 @@ export class ItemsService {
9091
url: "/api/v1/items/",
9192
body: data.requestBody,
9293
mediaType: "application/json",
93-
withCredentials: true,
9494
errors: {
9595
422: "Validation Error",
9696
},
@@ -114,7 +114,6 @@ export class ItemsService {
114114
path: {
115115
id: data.id,
116116
},
117-
withCredentials: true,
118117
errors: {
119118
422: "Validation Error",
120119
},
@@ -139,7 +138,6 @@ export class ItemsService {
139138
path: {
140139
id: data.id,
141140
},
142-
withCredentials: true,
143141
body: data.requestBody,
144142
mediaType: "application/json",
145143
errors: {
@@ -165,7 +163,6 @@ export class ItemsService {
165163
path: {
166164
id: data.id,
167165
},
168-
withCredentials: true,
169166
errors: {
170167
422: "Validation Error",
171168
},
@@ -176,10 +173,10 @@ export class ItemsService {
176173
export class LoginService {
177174
/**
178175
* Login Access Token
179-
* OAuth2 compatible token login, get an access token for future requests
176+
* OAuth2-compatible token login: get an access token for future requests (sent in an HTTP-only cookie)
180177
* @param data The data for the request.
181178
* @param data.formData
182-
* @returns Token Successful Response
179+
* @returns unknown Successful Response
183180
* @throws ApiError
184181
*/
185182
public static loginAccessToken(
@@ -189,42 +186,13 @@ export class LoginService {
189186
method: "POST",
190187
url: "/api/v1/login/access-token",
191188
formData: data.formData,
192-
headers: {
193-
"Content-Type": "application/x-www-form-urlencoded",
194-
},
195189
mediaType: "application/x-www-form-urlencoded",
196-
withCredentials: true,
197190
errors: {
198191
422: "Validation Error",
199192
},
200193
})
201194
}
202195

203-
204-
/**
205-
* Login Access Token
206-
* OAuth2 compatible token login, get an access token for future requests
207-
* @param data The data for the request.
208-
* @param data.formData
209-
* @returns Token Successful Response
210-
* @throws ApiError
211-
*/
212-
public static logout(): CancelablePromise<LogoutResponse> {
213-
return __request(OpenAPI, {
214-
method: "POST",
215-
url: "/api/v1/logout",
216-
headers: {
217-
"Content-Type": "application/x-www-form-urlencoded",
218-
},
219-
mediaType: "application/x-www-form-urlencoded",
220-
withCredentials: true,
221-
errors: {
222-
422: "Validation Error",
223-
},
224-
})
225-
}
226-
227-
228196
/**
229197
* Test Token
230198
* Test access token
@@ -235,7 +203,6 @@ export class LoginService {
235203
return __request(OpenAPI, {
236204
method: "POST",
237205
url: "/api/v1/login/test-token",
238-
withCredentials: true,
239206
})
240207
}
241208

@@ -306,6 +273,43 @@ export class LoginService {
306273
},
307274
})
308275
}
276+
277+
/**
278+
* Logout
279+
* Delete the HTTP-only cookie during logout
280+
* @returns unknown Successful Response
281+
* @throws ApiError
282+
*/
283+
public static logout(): CancelablePromise<LoginLogoutResponse> {
284+
return __request(OpenAPI, {
285+
method: "POST",
286+
url: "/api/v1/logout",
287+
})
288+
}
289+
}
290+
291+
export class PrivateService {
292+
/**
293+
* Create User
294+
* Create a new user.
295+
* @param data The data for the request.
296+
* @param data.requestBody
297+
* @returns UserPublic Successful Response
298+
* @throws ApiError
299+
*/
300+
public static createUser(
301+
data: PrivateCreateUserData,
302+
): CancelablePromise<PrivateCreateUserResponse> {
303+
return __request(OpenAPI, {
304+
method: "POST",
305+
url: "/api/v1/private/users/",
306+
body: data.requestBody,
307+
mediaType: "application/json",
308+
errors: {
309+
422: "Validation Error",
310+
},
311+
})
312+
}
309313
}
310314

311315
export class UsersService {
@@ -366,7 +370,6 @@ export class UsersService {
366370
return __request(OpenAPI, {
367371
method: "GET",
368372
url: "/api/v1/users/me",
369-
withCredentials: true,
370373
})
371374
}
372375

@@ -380,7 +383,6 @@ export class UsersService {
380383
return __request(OpenAPI, {
381384
method: "DELETE",
382385
url: "/api/v1/users/me",
383-
withCredentials: true,
384386
})
385387
}
386388

@@ -400,7 +402,6 @@ export class UsersService {
400402
url: "/api/v1/users/me",
401403
body: data.requestBody,
402404
mediaType: "application/json",
403-
withCredentials: true,
404405
errors: {
405406
422: "Validation Error",
406407
},
@@ -423,7 +424,6 @@ export class UsersService {
423424
url: "/api/v1/users/me/password",
424425
body: data.requestBody,
425426
mediaType: "application/json",
426-
withCredentials: true,
427427
errors: {
428428
422: "Validation Error",
429429
},
@@ -495,7 +495,6 @@ export class UsersService {
495495
},
496496
body: data.requestBody,
497497
mediaType: "application/json",
498-
withCredentials: true,
499498
errors: {
500499
422: "Validation Error",
501500
},
@@ -516,7 +515,6 @@ export class UsersService {
516515
return __request(OpenAPI, {
517516
method: "DELETE",
518517
url: "/api/v1/users/{user_id}",
519-
withCredentials: true,
520518
path: {
521519
user_id: data.userId,
522520
},

frontend/src/client/types.gen.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,13 @@ export type NewPassword = {
4444
new_password: string
4545
}
4646

47-
export type Token = {
48-
access_token: string
49-
token_type?: string
47+
export type PrivateUserCreate = {
48+
email: string
49+
password: string
50+
full_name: string
51+
is_verified?: boolean
5052
}
5153

52-
export type HTTPOnlyCookie = {
53-
message: string
54-
}
5554
export type UpdatePassword = {
5655
current_password: string
5756
new_password: string
@@ -139,9 +138,7 @@ export type LoginLoginAccessTokenData = {
139138
formData: Body_login_login_access_token
140139
}
141140

142-
export type LoginLoginAccessTokenResponse = HTTPOnlyCookie
143-
144-
export type LogoutResponse = HTTPOnlyCookie
141+
export type LoginLoginAccessTokenResponse = unknown
145142

146143
export type LoginTestTokenResponse = UserPublic
147144

@@ -163,6 +160,14 @@ export type LoginRecoverPasswordHtmlContentData = {
163160

164161
export type LoginRecoverPasswordHtmlContentResponse = string
165162

163+
export type LoginLogoutResponse = unknown
164+
165+
export type PrivateCreateUserData = {
166+
requestBody: PrivateUserCreate
167+
}
168+
169+
export type PrivateCreateUserResponse = UserPublic
170+
166171
export type UsersReadUsersData = {
167172
limit?: number
168173
skip?: number

frontend/tests/utils/privateApi.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ export const createUser = async ({
1818
is_verified: true,
1919
full_name: "Test User",
2020
},
21-
credentials: 'include'
2221
})
2322
}

0 commit comments

Comments
 (0)