♻️ Remove modify id script in favor of openapi-ts config (#1434)
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
import * as fs from "node:fs"
|
||||
|
||||
async function modifyOpenAPIFile(filePath) {
|
||||
try {
|
||||
const data = await fs.promises.readFile(filePath)
|
||||
const openapiContent = JSON.parse(data)
|
||||
|
||||
const paths = openapiContent.paths
|
||||
for (const pathKey of Object.keys(paths)) {
|
||||
const pathData = paths[pathKey]
|
||||
for (const method of Object.keys(pathData)) {
|
||||
const operation = pathData[method]
|
||||
if (operation.tags && operation.tags.length > 0) {
|
||||
const tag = operation.tags[0]
|
||||
const operationId = operation.operationId
|
||||
const toRemove = `${tag}-`
|
||||
if (operationId.startsWith(toRemove)) {
|
||||
const newOperationId = operationId.substring(toRemove.length)
|
||||
operation.operationId = newOperationId
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await fs.promises.writeFile(
|
||||
filePath,
|
||||
JSON.stringify(openapiContent, null, 2),
|
||||
)
|
||||
console.log("File successfully modified")
|
||||
} catch (err) {
|
||||
console.error("Error:", err)
|
||||
}
|
||||
}
|
||||
|
||||
const filePath = "./openapi.json"
|
||||
modifyOpenAPIFile(filePath)
|
@@ -10,6 +10,19 @@ export default defineConfig({
|
||||
name: "@hey-api/sdk",
|
||||
// NOTE: this doesn't allow tree-shaking
|
||||
asClass: true,
|
||||
operationId: true,
|
||||
methodNameBuilder: (operation) => {
|
||||
// @ts-ignore
|
||||
let name: string = operation.name
|
||||
// @ts-ignore
|
||||
let service: string = operation.service
|
||||
|
||||
if (service && name.toLowerCase().startsWith(service.toLowerCase())) {
|
||||
name = name.slice(service.length)
|
||||
}
|
||||
|
||||
return name.charAt(0).toLowerCase() + name.slice(1)
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
|
@@ -4,46 +4,46 @@ import type { CancelablePromise } from "./core/CancelablePromise"
|
||||
import { OpenAPI } from "./core/OpenAPI"
|
||||
import { request as __request } from "./core/request"
|
||||
import type {
|
||||
ReadItemsData,
|
||||
ReadItemsResponse,
|
||||
CreateItemData,
|
||||
CreateItemResponse,
|
||||
ReadItemData,
|
||||
ReadItemResponse,
|
||||
UpdateItemData,
|
||||
UpdateItemResponse,
|
||||
DeleteItemData,
|
||||
DeleteItemResponse,
|
||||
LoginAccessTokenData,
|
||||
LoginAccessTokenResponse,
|
||||
TestTokenResponse,
|
||||
RecoverPasswordData,
|
||||
RecoverPasswordResponse,
|
||||
ResetPasswordData,
|
||||
ResetPasswordResponse,
|
||||
RecoverPasswordHtmlContentData,
|
||||
RecoverPasswordHtmlContentResponse,
|
||||
ReadUsersData,
|
||||
ReadUsersResponse,
|
||||
CreateUserData,
|
||||
CreateUserResponse,
|
||||
ReadUserMeResponse,
|
||||
DeleteUserMeResponse,
|
||||
UpdateUserMeData,
|
||||
UpdateUserMeResponse,
|
||||
UpdatePasswordMeData,
|
||||
UpdatePasswordMeResponse,
|
||||
RegisterUserData,
|
||||
RegisterUserResponse,
|
||||
ReadUserByIdData,
|
||||
ReadUserByIdResponse,
|
||||
UpdateUserData,
|
||||
UpdateUserResponse,
|
||||
DeleteUserData,
|
||||
DeleteUserResponse,
|
||||
TestEmailData,
|
||||
TestEmailResponse,
|
||||
HealthCheckResponse,
|
||||
ItemsReadItemsData,
|
||||
ItemsReadItemsResponse,
|
||||
ItemsCreateItemData,
|
||||
ItemsCreateItemResponse,
|
||||
ItemsReadItemData,
|
||||
ItemsReadItemResponse,
|
||||
ItemsUpdateItemData,
|
||||
ItemsUpdateItemResponse,
|
||||
ItemsDeleteItemData,
|
||||
ItemsDeleteItemResponse,
|
||||
LoginLoginAccessTokenData,
|
||||
LoginLoginAccessTokenResponse,
|
||||
LoginTestTokenResponse,
|
||||
LoginRecoverPasswordData,
|
||||
LoginRecoverPasswordResponse,
|
||||
LoginResetPasswordData,
|
||||
LoginResetPasswordResponse,
|
||||
LoginRecoverPasswordHtmlContentData,
|
||||
LoginRecoverPasswordHtmlContentResponse,
|
||||
UsersReadUsersData,
|
||||
UsersReadUsersResponse,
|
||||
UsersCreateUserData,
|
||||
UsersCreateUserResponse,
|
||||
UsersReadUserMeResponse,
|
||||
UsersDeleteUserMeResponse,
|
||||
UsersUpdateUserMeData,
|
||||
UsersUpdateUserMeResponse,
|
||||
UsersUpdatePasswordMeData,
|
||||
UsersUpdatePasswordMeResponse,
|
||||
UsersRegisterUserData,
|
||||
UsersRegisterUserResponse,
|
||||
UsersReadUserByIdData,
|
||||
UsersReadUserByIdResponse,
|
||||
UsersUpdateUserData,
|
||||
UsersUpdateUserResponse,
|
||||
UsersDeleteUserData,
|
||||
UsersDeleteUserResponse,
|
||||
UtilsTestEmailData,
|
||||
UtilsTestEmailResponse,
|
||||
UtilsHealthCheckResponse,
|
||||
} from "./types.gen"
|
||||
|
||||
export class ItemsService {
|
||||
@@ -57,8 +57,8 @@ export class ItemsService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static readItems(
|
||||
data: ReadItemsData = {},
|
||||
): CancelablePromise<ReadItemsResponse> {
|
||||
data: ItemsReadItemsData = {},
|
||||
): CancelablePromise<ItemsReadItemsResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "GET",
|
||||
url: "/api/v1/items/",
|
||||
@@ -81,8 +81,8 @@ export class ItemsService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static createItem(
|
||||
data: CreateItemData,
|
||||
): CancelablePromise<CreateItemResponse> {
|
||||
data: ItemsCreateItemData,
|
||||
): CancelablePromise<ItemsCreateItemResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "POST",
|
||||
url: "/api/v1/items/",
|
||||
@@ -103,8 +103,8 @@ export class ItemsService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static readItem(
|
||||
data: ReadItemData,
|
||||
): CancelablePromise<ReadItemResponse> {
|
||||
data: ItemsReadItemData,
|
||||
): CancelablePromise<ItemsReadItemResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "GET",
|
||||
url: "/api/v1/items/{id}",
|
||||
@@ -127,8 +127,8 @@ export class ItemsService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static updateItem(
|
||||
data: UpdateItemData,
|
||||
): CancelablePromise<UpdateItemResponse> {
|
||||
data: ItemsUpdateItemData,
|
||||
): CancelablePromise<ItemsUpdateItemResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "PUT",
|
||||
url: "/api/v1/items/{id}",
|
||||
@@ -152,8 +152,8 @@ export class ItemsService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static deleteItem(
|
||||
data: DeleteItemData,
|
||||
): CancelablePromise<DeleteItemResponse> {
|
||||
data: ItemsDeleteItemData,
|
||||
): CancelablePromise<ItemsDeleteItemResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "DELETE",
|
||||
url: "/api/v1/items/{id}",
|
||||
@@ -177,8 +177,8 @@ export class LoginService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static loginAccessToken(
|
||||
data: LoginAccessTokenData,
|
||||
): CancelablePromise<LoginAccessTokenResponse> {
|
||||
data: LoginLoginAccessTokenData,
|
||||
): CancelablePromise<LoginLoginAccessTokenResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "POST",
|
||||
url: "/api/v1/login/access-token",
|
||||
@@ -196,7 +196,7 @@ export class LoginService {
|
||||
* @returns UserPublic Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static testToken(): CancelablePromise<TestTokenResponse> {
|
||||
public static testToken(): CancelablePromise<LoginTestTokenResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "POST",
|
||||
url: "/api/v1/login/test-token",
|
||||
@@ -212,8 +212,8 @@ export class LoginService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static recoverPassword(
|
||||
data: RecoverPasswordData,
|
||||
): CancelablePromise<RecoverPasswordResponse> {
|
||||
data: LoginRecoverPasswordData,
|
||||
): CancelablePromise<LoginRecoverPasswordResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "POST",
|
||||
url: "/api/v1/password-recovery/{email}",
|
||||
@@ -235,8 +235,8 @@ export class LoginService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static resetPassword(
|
||||
data: ResetPasswordData,
|
||||
): CancelablePromise<ResetPasswordResponse> {
|
||||
data: LoginResetPasswordData,
|
||||
): CancelablePromise<LoginResetPasswordResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "POST",
|
||||
url: "/api/v1/reset-password/",
|
||||
@@ -257,8 +257,8 @@ export class LoginService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static recoverPasswordHtmlContent(
|
||||
data: RecoverPasswordHtmlContentData,
|
||||
): CancelablePromise<RecoverPasswordHtmlContentResponse> {
|
||||
data: LoginRecoverPasswordHtmlContentData,
|
||||
): CancelablePromise<LoginRecoverPasswordHtmlContentResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "POST",
|
||||
url: "/api/v1/password-recovery-html-content/{email}",
|
||||
@@ -283,8 +283,8 @@ export class UsersService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static readUsers(
|
||||
data: ReadUsersData = {},
|
||||
): CancelablePromise<ReadUsersResponse> {
|
||||
data: UsersReadUsersData = {},
|
||||
): CancelablePromise<UsersReadUsersResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "GET",
|
||||
url: "/api/v1/users/",
|
||||
@@ -307,8 +307,8 @@ export class UsersService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static createUser(
|
||||
data: CreateUserData,
|
||||
): CancelablePromise<CreateUserResponse> {
|
||||
data: UsersCreateUserData,
|
||||
): CancelablePromise<UsersCreateUserResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "POST",
|
||||
url: "/api/v1/users/",
|
||||
@@ -326,7 +326,7 @@ export class UsersService {
|
||||
* @returns UserPublic Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static readUserMe(): CancelablePromise<ReadUserMeResponse> {
|
||||
public static readUserMe(): CancelablePromise<UsersReadUserMeResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "GET",
|
||||
url: "/api/v1/users/me",
|
||||
@@ -339,7 +339,7 @@ export class UsersService {
|
||||
* @returns Message Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static deleteUserMe(): CancelablePromise<DeleteUserMeResponse> {
|
||||
public static deleteUserMe(): CancelablePromise<UsersDeleteUserMeResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "DELETE",
|
||||
url: "/api/v1/users/me",
|
||||
@@ -355,8 +355,8 @@ export class UsersService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static updateUserMe(
|
||||
data: UpdateUserMeData,
|
||||
): CancelablePromise<UpdateUserMeResponse> {
|
||||
data: UsersUpdateUserMeData,
|
||||
): CancelablePromise<UsersUpdateUserMeResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "PATCH",
|
||||
url: "/api/v1/users/me",
|
||||
@@ -377,8 +377,8 @@ export class UsersService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static updatePasswordMe(
|
||||
data: UpdatePasswordMeData,
|
||||
): CancelablePromise<UpdatePasswordMeResponse> {
|
||||
data: UsersUpdatePasswordMeData,
|
||||
): CancelablePromise<UsersUpdatePasswordMeResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "PATCH",
|
||||
url: "/api/v1/users/me/password",
|
||||
@@ -399,8 +399,8 @@ export class UsersService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static registerUser(
|
||||
data: RegisterUserData,
|
||||
): CancelablePromise<RegisterUserResponse> {
|
||||
data: UsersRegisterUserData,
|
||||
): CancelablePromise<UsersRegisterUserResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "POST",
|
||||
url: "/api/v1/users/signup",
|
||||
@@ -421,8 +421,8 @@ export class UsersService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static readUserById(
|
||||
data: ReadUserByIdData,
|
||||
): CancelablePromise<ReadUserByIdResponse> {
|
||||
data: UsersReadUserByIdData,
|
||||
): CancelablePromise<UsersReadUserByIdResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "GET",
|
||||
url: "/api/v1/users/{user_id}",
|
||||
@@ -445,8 +445,8 @@ export class UsersService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static updateUser(
|
||||
data: UpdateUserData,
|
||||
): CancelablePromise<UpdateUserResponse> {
|
||||
data: UsersUpdateUserData,
|
||||
): CancelablePromise<UsersUpdateUserResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "PATCH",
|
||||
url: "/api/v1/users/{user_id}",
|
||||
@@ -470,8 +470,8 @@ export class UsersService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static deleteUser(
|
||||
data: DeleteUserData,
|
||||
): CancelablePromise<DeleteUserResponse> {
|
||||
data: UsersDeleteUserData,
|
||||
): CancelablePromise<UsersDeleteUserResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "DELETE",
|
||||
url: "/api/v1/users/{user_id}",
|
||||
@@ -495,8 +495,8 @@ export class UtilsService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static testEmail(
|
||||
data: TestEmailData,
|
||||
): CancelablePromise<TestEmailResponse> {
|
||||
data: UtilsTestEmailData,
|
||||
): CancelablePromise<UtilsTestEmailResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "POST",
|
||||
url: "/api/v1/utils/test-email/",
|
||||
@@ -514,7 +514,7 @@ export class UtilsService {
|
||||
* @returns boolean Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static healthCheck(): CancelablePromise<HealthCheckResponse> {
|
||||
public static healthCheck(): CancelablePromise<UtilsHealthCheckResponse> {
|
||||
return __request(OpenAPI, {
|
||||
method: "GET",
|
||||
url: "/api/v1/utils/health-check/",
|
||||
|
@@ -100,122 +100,122 @@ export type ValidationError = {
|
||||
type: string
|
||||
}
|
||||
|
||||
export type ReadItemsData = {
|
||||
export type ItemsReadItemsData = {
|
||||
limit?: number
|
||||
skip?: number
|
||||
}
|
||||
|
||||
export type ReadItemsResponse = ItemsPublic
|
||||
export type ItemsReadItemsResponse = ItemsPublic
|
||||
|
||||
export type CreateItemData = {
|
||||
export type ItemsCreateItemData = {
|
||||
requestBody: ItemCreate
|
||||
}
|
||||
|
||||
export type CreateItemResponse = ItemPublic
|
||||
export type ItemsCreateItemResponse = ItemPublic
|
||||
|
||||
export type ReadItemData = {
|
||||
export type ItemsReadItemData = {
|
||||
id: string
|
||||
}
|
||||
|
||||
export type ReadItemResponse = ItemPublic
|
||||
export type ItemsReadItemResponse = ItemPublic
|
||||
|
||||
export type UpdateItemData = {
|
||||
export type ItemsUpdateItemData = {
|
||||
id: string
|
||||
requestBody: ItemUpdate
|
||||
}
|
||||
|
||||
export type UpdateItemResponse = ItemPublic
|
||||
export type ItemsUpdateItemResponse = ItemPublic
|
||||
|
||||
export type DeleteItemData = {
|
||||
export type ItemsDeleteItemData = {
|
||||
id: string
|
||||
}
|
||||
|
||||
export type DeleteItemResponse = Message
|
||||
export type ItemsDeleteItemResponse = Message
|
||||
|
||||
export type LoginAccessTokenData = {
|
||||
export type LoginLoginAccessTokenData = {
|
||||
formData: Body_login_login_access_token
|
||||
}
|
||||
|
||||
export type LoginAccessTokenResponse = Token
|
||||
export type LoginLoginAccessTokenResponse = Token
|
||||
|
||||
export type TestTokenResponse = UserPublic
|
||||
export type LoginTestTokenResponse = UserPublic
|
||||
|
||||
export type RecoverPasswordData = {
|
||||
export type LoginRecoverPasswordData = {
|
||||
email: string
|
||||
}
|
||||
|
||||
export type RecoverPasswordResponse = Message
|
||||
export type LoginRecoverPasswordResponse = Message
|
||||
|
||||
export type ResetPasswordData = {
|
||||
export type LoginResetPasswordData = {
|
||||
requestBody: NewPassword
|
||||
}
|
||||
|
||||
export type ResetPasswordResponse = Message
|
||||
export type LoginResetPasswordResponse = Message
|
||||
|
||||
export type RecoverPasswordHtmlContentData = {
|
||||
export type LoginRecoverPasswordHtmlContentData = {
|
||||
email: string
|
||||
}
|
||||
|
||||
export type RecoverPasswordHtmlContentResponse = string
|
||||
export type LoginRecoverPasswordHtmlContentResponse = string
|
||||
|
||||
export type ReadUsersData = {
|
||||
export type UsersReadUsersData = {
|
||||
limit?: number
|
||||
skip?: number
|
||||
}
|
||||
|
||||
export type ReadUsersResponse = UsersPublic
|
||||
export type UsersReadUsersResponse = UsersPublic
|
||||
|
||||
export type CreateUserData = {
|
||||
export type UsersCreateUserData = {
|
||||
requestBody: UserCreate
|
||||
}
|
||||
|
||||
export type CreateUserResponse = UserPublic
|
||||
export type UsersCreateUserResponse = UserPublic
|
||||
|
||||
export type ReadUserMeResponse = UserPublic
|
||||
export type UsersReadUserMeResponse = UserPublic
|
||||
|
||||
export type DeleteUserMeResponse = Message
|
||||
export type UsersDeleteUserMeResponse = Message
|
||||
|
||||
export type UpdateUserMeData = {
|
||||
export type UsersUpdateUserMeData = {
|
||||
requestBody: UserUpdateMe
|
||||
}
|
||||
|
||||
export type UpdateUserMeResponse = UserPublic
|
||||
export type UsersUpdateUserMeResponse = UserPublic
|
||||
|
||||
export type UpdatePasswordMeData = {
|
||||
export type UsersUpdatePasswordMeData = {
|
||||
requestBody: UpdatePassword
|
||||
}
|
||||
|
||||
export type UpdatePasswordMeResponse = Message
|
||||
export type UsersUpdatePasswordMeResponse = Message
|
||||
|
||||
export type RegisterUserData = {
|
||||
export type UsersRegisterUserData = {
|
||||
requestBody: UserRegister
|
||||
}
|
||||
|
||||
export type RegisterUserResponse = UserPublic
|
||||
export type UsersRegisterUserResponse = UserPublic
|
||||
|
||||
export type ReadUserByIdData = {
|
||||
export type UsersReadUserByIdData = {
|
||||
userId: string
|
||||
}
|
||||
|
||||
export type ReadUserByIdResponse = UserPublic
|
||||
export type UsersReadUserByIdResponse = UserPublic
|
||||
|
||||
export type UpdateUserData = {
|
||||
export type UsersUpdateUserData = {
|
||||
requestBody: UserUpdate
|
||||
userId: string
|
||||
}
|
||||
|
||||
export type UpdateUserResponse = UserPublic
|
||||
export type UsersUpdateUserResponse = UserPublic
|
||||
|
||||
export type DeleteUserData = {
|
||||
export type UsersDeleteUserData = {
|
||||
userId: string
|
||||
}
|
||||
|
||||
export type DeleteUserResponse = Message
|
||||
export type UsersDeleteUserResponse = Message
|
||||
|
||||
export type TestEmailData = {
|
||||
export type UtilsTestEmailData = {
|
||||
emailTo: string
|
||||
}
|
||||
|
||||
export type TestEmailResponse = Message
|
||||
export type UtilsTestEmailResponse = Message
|
||||
|
||||
export type HealthCheckResponse = boolean
|
||||
export type UtilsHealthCheckResponse = boolean
|
||||
|
@@ -6,7 +6,6 @@ set -x
|
||||
cd backend
|
||||
python -c "import app.main; import json; print(json.dumps(app.main.app.openapi()))" > ../openapi.json
|
||||
cd ..
|
||||
node frontend/modify-openapi-operationids.js
|
||||
mv openapi.json frontend/
|
||||
cd frontend
|
||||
npm run generate-client
|
||||
|
Reference in New Issue
Block a user