Skip to content

rewrite to work with config file instead of command line args #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from

Conversation

phryneas
Copy link
Collaborator

@phryneas phryneas commented Oct 29, 2021

This has moved to reduxjs/redux-toolkit#1680

@grumpyTofu
Copy link

grumpyTofu commented Nov 4, 2021

@phryneas I was able to try this one out. However, I have been running into some issues:

My config:

import { ConfigFile } from "@rtk-incubator/rtk-query-codegen-openapi/lib";

const {
  parsed: { OPENAPI_DOCS },
} = require("dotenv").config({ path: "./.env.local" });

const config: ConfigFile = {
  schemaFile: OPENAPI_DOCS,
  apiFile: "./src/app/emptyApi.ts",
  //apiImport: "emptyApi",
  outputFile: "./src/app/rtk-api.ts",
  //exportName: "emptyApi",
  hooks: true,
};

export default config;

Is it intentional that we have to import from the lib folder?


Here is the start of my generated file

import { api } from "emptyApi";
const injectedRtkApi = api.injectEndpoints({
  endpoints: (build) => ({
    // endpoints
  })
})

what I notice is that the import is not resolving correctly. It should be a relative import. If I change it manually it works.

import { api } from "./emptyApi";

I have also noticed that when I use the apiImport option in the config, it changes the import to:

import { api as emptyApi } from "emptyApi";
const injectedRtkApi = api.injectEndpoints({
  endpoints: (build) => ({
    // endpoints
  })
})

but the use of "api" for the injectEnpoints function stays the same, so the whole thing is not working unless you change it to match.

@phryneas
Copy link
Collaborator Author

phryneas commented Nov 4, 2021

@grumpyTofu good catches! I'll look into those today evening or tomorrow.

@phryneas
Copy link
Collaborator Author

phryneas commented Nov 4, 2021

@grumpyTofu I have fixed the bugs you found. But not in this branch, but over in the RTK monorepo: reduxjs/redux-toolkit#1680

Could you give it another try?

@phryneas
Copy link
Collaborator Author

This is now published as @rtk-query/codegen-openapi.

@phryneas phryneas closed this Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants