Add OpenAPI TypeScript config and update dependencies
Introduced `openapi-ts.config.ts` to generate client code from the OpenAPI spec. Updated several dependencies to enable OpenAPI integration, including `@hey-api` plugins, `axios`, and `@tanstack/react-query`. These changes set up the project for streamlined API access using autogenerated TypeScript clients.
This commit is contained in:
28
frontend/openapi-ts.config.ts
Normal file
28
frontend/openapi-ts.config.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import {defineConfig} from '@hey-api/openapi-ts';
|
||||
import path from "path";
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_BACKEND_API_URL || 'http://localhost:8000';
|
||||
const OPENAPI_URL = `${API_URL}/api/v1/openapi.json`;
|
||||
const OUTPUT_DIR = path.resolve(__dirname, './src/client');
|
||||
// const OPENAPI_FILE = path.resolve(__dirname, './openapi.json');
|
||||
|
||||
|
||||
export default defineConfig({
|
||||
input:
|
||||
OPENAPI_URL,
|
||||
output: {
|
||||
format: 'prettier',
|
||||
lint: 'eslint',
|
||||
path: OUTPUT_DIR,
|
||||
},
|
||||
plugins: [
|
||||
'@hey-api/client-axios',
|
||||
'@hey-api/schemas',
|
||||
'@hey-api/sdk',
|
||||
{
|
||||
enums: 'javascript',
|
||||
name: '@hey-api/typescript',
|
||||
},
|
||||
'@tanstack/react-query',
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user