diff --git a/openapi-config.ts b/openapi-config.ts new file mode 100644 index 0000000000000000000000000000000000000000..2d13d1b07cf01e81458b14f596263e9a711cf78e --- /dev/null +++ b/openapi-config.ts @@ -0,0 +1,12 @@ +import type { ConfigFile } from "@rtk-query/codegen-openapi"; + +const config: ConfigFile = { + schemaFile: "http://localhost:8080/api/spec", + apiFile: "./src/store/emptyApi.ts", + apiImport: "emptySplitApi", + outputFile: "./src/store/deployApi.ts", + exportName: "deployApi", + hooks: { queries: true, lazyQueries: true, mutations: true } +}; + +export default config; diff --git a/package.json b/package.json index 514445bb25795de73b62f60e99ef03fde9659ab7..9674925d1bdb0d6c245f4079fc5f17420513b3b3 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,8 @@ "lint:fix": "npm run lint -- --fix", "prettier": "npx prettier src --check", "prettier:fix": "npm run prettier -- --write", - "format": "npm run prettier:fix && npm run lint:fix" + "format": "npm run prettier:fix && npm run lint:fix", + "generate-api": "npx @rtk-query/codegen-openapi openapi-config.ts" }, "browserslist": { "production": [ diff --git a/src/store/emptyApi.ts b/src/store/emptyApi.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3b426cf9671205ad47bc65a9824b957d898d136 --- /dev/null +++ b/src/store/emptyApi.ts @@ -0,0 +1,7 @@ +import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; + +// initialize an empty api service that we'll inject endpoints into later as needed +export const emptySplitApi = createApi({ + baseQuery: fetchBaseQuery({ baseUrl: "/" }), + endpoints: () => ({}) +});