fix: oapi shitty generation
This commit is contained in:
parent
cb9fba6fbc
commit
68294dd13c
16 changed files with 302 additions and 288 deletions
|
|
@ -12,6 +12,7 @@ export type { CursorObj } from './models/CursorObj';
|
|||
export type { Image } from './models/Image';
|
||||
export type { ReleaseSeason } from './models/ReleaseSeason';
|
||||
export type { Review } from './models/Review';
|
||||
export type { StorageType } from './models/StorageType';
|
||||
export type { Studio } from './models/Studio';
|
||||
export type { Tag } from './models/Tag';
|
||||
export type { Tags } from './models/Tags';
|
||||
|
|
@ -21,6 +22,7 @@ export type { TitleSort } from './models/TitleSort';
|
|||
export type { TitleStatus } from './models/TitleStatus';
|
||||
export type { User } from './models/User';
|
||||
export type { UserTitle } from './models/UserTitle';
|
||||
export type { UserTitleMini } from './models/UserTitleMini';
|
||||
export type { UserTitleStatus } from './models/UserTitleStatus';
|
||||
|
||||
export { DefaultService } from './services/DefaultService';
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@
|
|||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type { StorageType } from './StorageType';
|
||||
export type Image = {
|
||||
id?: number;
|
||||
/**
|
||||
* Image storage type
|
||||
*/
|
||||
storage_type?: 's3' | 'local';
|
||||
storage_type?: StorageType;
|
||||
image_path?: string;
|
||||
};
|
||||
|
||||
|
|
|
|||
8
modules/frontend/src/api/models/StorageType.ts
Normal file
8
modules/frontend/src/api/models/StorageType.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/* generated using openapi-typescript-codegen -- do not edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Image storage type
|
||||
*/
|
||||
export type StorageType = 's3' | 'local';
|
||||
|
|
@ -2,4 +2,30 @@
|
|||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type Title = Record<string, any>;
|
||||
import type { Image } from './Image';
|
||||
import type { ReleaseSeason } from './ReleaseSeason';
|
||||
import type { Studio } from './Studio';
|
||||
import type { Tags } from './Tags';
|
||||
import type { TitleStatus } from './TitleStatus';
|
||||
export type Title = {
|
||||
/**
|
||||
* Unique title ID (primary key)
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* Localized titles. Key = language (ISO 639-1), value = list of names
|
||||
*/
|
||||
title_names: Record<string, Array<string>>;
|
||||
studio?: Studio;
|
||||
tags: Tags;
|
||||
poster?: Image;
|
||||
title_status?: TitleStatus;
|
||||
rating?: number;
|
||||
rating_count?: number;
|
||||
release_year?: number;
|
||||
release_season?: ReleaseSeason;
|
||||
episodes_aired?: number;
|
||||
episodes_all?: number;
|
||||
episodes_len?: Record<string, number>;
|
||||
};
|
||||
|
||||
|
|
|
|||
14
modules/frontend/src/api/models/UserTitleMini.ts
Normal file
14
modules/frontend/src/api/models/UserTitleMini.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* generated using openapi-typescript-codegen -- do not edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type { UserTitleStatus } from './UserTitleStatus';
|
||||
export type UserTitleMini = {
|
||||
user_id: number;
|
||||
title_id: number;
|
||||
status: UserTitleStatus;
|
||||
rate?: number;
|
||||
review_id?: number;
|
||||
ctime?: string;
|
||||
};
|
||||
|
||||
|
|
@ -9,6 +9,7 @@ import type { TitleSort } from '../models/TitleSort';
|
|||
import type { TitleStatus } from '../models/TitleStatus';
|
||||
import type { User } from '../models/User';
|
||||
import type { UserTitle } from '../models/UserTitle';
|
||||
import type { UserTitleMini } from '../models/UserTitleMini';
|
||||
import type { UserTitleStatus } from '../models/UserTitleStatus';
|
||||
import type { CancelablePromise } from '../core/CancelablePromise';
|
||||
import { OpenAPI } from '../core/OpenAPI';
|
||||
|
|
@ -78,7 +79,7 @@ export class DefaultService {
|
|||
* @returns Title Title description
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static getTitles1(
|
||||
public static getTitle(
|
||||
titleId: number,
|
||||
fields: string = 'all',
|
||||
): CancelablePromise<Title> {
|
||||
|
|
@ -105,7 +106,7 @@ export class DefaultService {
|
|||
* @returns User User info
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static getUsers(
|
||||
public static getUsersId(
|
||||
userId: string,
|
||||
fields: string = 'all',
|
||||
): CancelablePromise<User> {
|
||||
|
|
@ -248,22 +249,17 @@ export class DefaultService {
|
|||
* User adding title to list af watched, status required
|
||||
* @param userId ID of the user to assign the title to
|
||||
* @param requestBody
|
||||
* @returns any Title successfully added to user
|
||||
* @returns UserTitleMini Title successfully added to user
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static addUserTitle(
|
||||
userId: number,
|
||||
requestBody: UserTitle,
|
||||
): CancelablePromise<{
|
||||
data?: {
|
||||
user_id: number;
|
||||
requestBody: {
|
||||
title_id: number;
|
||||
status: UserTitleStatus;
|
||||
rate?: number;
|
||||
review_id?: number;
|
||||
ctime?: string;
|
||||
};
|
||||
}> {
|
||||
},
|
||||
): CancelablePromise<UserTitleMini> {
|
||||
return __request(OpenAPI, {
|
||||
method: 'POST',
|
||||
url: '/users/{user_id}/titles',
|
||||
|
|
@ -282,4 +278,37 @@ export class DefaultService {
|
|||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Update a usertitle
|
||||
* User updating title list of watched
|
||||
* @param userId ID of the user to assign the title to
|
||||
* @param requestBody
|
||||
* @returns UserTitleMini Title successfully updated
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static updateUserTitle(
|
||||
userId: number,
|
||||
requestBody: {
|
||||
title_id: number;
|
||||
status?: UserTitleStatus;
|
||||
rate?: number;
|
||||
},
|
||||
): CancelablePromise<UserTitleMini> {
|
||||
return __request(OpenAPI, {
|
||||
method: 'PATCH',
|
||||
url: '/users/{user_id}/titles',
|
||||
path: {
|
||||
'user_id': userId,
|
||||
},
|
||||
body: requestBody,
|
||||
mediaType: 'application/json',
|
||||
errors: {
|
||||
400: `Invalid request body (missing fields, invalid types, etc.)`,
|
||||
401: `Unauthorized — missing or invalid auth token`,
|
||||
403: `Forbidden — user not allowed to update title`,
|
||||
404: `User or Title not found`,
|
||||
500: `Internal server error`,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
// import React, { useEffect, useState } from "react";
|
||||
// import { useParams } from "react-router-dom";
|
||||
// import { DefaultService } from "../../api/services/DefaultService";
|
||||
// import type { User } from "../../api/models/User";
|
||||
// import styles from "./UserPage.module.css";
|
||||
|
||||
// const UserPage: React.FC = () => {
|
||||
// const { id } = useParams<{ id: string }>();
|
||||
// const [user, setUser] = useState<User | null>(null);
|
||||
// const [loading, setLoading] = useState(true);
|
||||
// const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// useEffect(() => {
|
||||
// if (!id) return;
|
||||
|
||||
// const getTitleInfo = async () => {
|
||||
// try {
|
||||
// const userInfo = await DefaultService.getTitle(id, "all");
|
||||
// setUser(userInfo);
|
||||
// } catch (err) {
|
||||
// console.error(err);
|
||||
// setError("Failed to fetch user info.");
|
||||
// } finally {
|
||||
// setLoading(false);
|
||||
// }
|
||||
// };
|
||||
// getTitleInfo();
|
||||
// }, [id]);
|
||||
|
||||
// if (loading) return <div className={styles.loader}>Loading...</div>;
|
||||
// if (error) return <div className={styles.error}>{error}</div>;
|
||||
// if (!user) return <div className={styles.error}>User not found.</div>;
|
||||
|
||||
// return (
|
||||
// <div className={styles.container}>
|
||||
// <div className={styles.card}>
|
||||
// <div className={styles.avatar}>
|
||||
// {user.avatar_id ? (
|
||||
// <img
|
||||
// src={`/images/${user.avatar_id}.png`}
|
||||
// alt="User Avatar"
|
||||
// className={styles.avatarImg}
|
||||
// />
|
||||
// ) : (
|
||||
// <div className={styles.avatarPlaceholder}>
|
||||
// {user.disp_name?.[0] || "U"}
|
||||
// </div>
|
||||
// )}
|
||||
// </div>
|
||||
|
||||
// <div className={styles.info}>
|
||||
// <h1 className={styles.name}>{user.disp_name || user.nickname}</h1>
|
||||
// <p className={styles.nickname}>@{user.nickname}</p>
|
||||
// {user.user_desc && <p className={styles.desc}>{user.user_desc}</p>}
|
||||
// <p className={styles.created}>
|
||||
// Joined: {new Date(user.creation_date).toLocaleDateString()}
|
||||
// </p>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
// };
|
||||
|
||||
// export default UserPage;
|
||||
|
|
@ -15,7 +15,7 @@ const UserPage: React.FC = () => {
|
|||
|
||||
const getUserInfo = async () => {
|
||||
try {
|
||||
const userInfo = await DefaultService.getUsers(id, "all"); // <-- use dynamic id
|
||||
const userInfo = await DefaultService.getUsersId(id, "all"); // <-- use dynamic id
|
||||
setUser(userInfo);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export default function UsersIdPage({ userId }: UsersIdPageProps) {
|
|||
if (!id) return;
|
||||
setLoadingUser(true);
|
||||
try {
|
||||
const result = await DefaultService.getUsers(id, "all");
|
||||
const result = await DefaultService.getUsersId(id, "all");
|
||||
setUser(result);
|
||||
setErrorUser(null);
|
||||
} catch (err: any) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue