redux-toolkit
redux-toolkit copied to clipboard
2XX status code is always ignored
Current Behavior
'2XX' status is always ignored
Expected Behavior
in absence of a more specific 200 range status code, the 2XX code should be used to type the response (see https://swagger.io/specification/v3/#responses-object)
Example
this leads to generated ApiResponse type to be typed to any
"responses": {
"2XX": {
"description": "…",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MyComponent"
}
}
}
}
}
closing because unclear whether that was solved with 2.0.0 (which I cannot run because cli is not exported as export in package.json)
@maddrag0n can you clarify the packaging comment?
@markerikson we are calling the cli programmatically like this
const cliPath = require.resolve('@rtk-query/codegen-openapi/lib/bin/cli');
const runReduxCodegen = async (specUrl: string | undefined, configPath: string, outputPath: string): Promise<void> => (
new Promise((resolve, reject) => {
exec(
`tsx ${cliPath} ${configPath}`,
{
env: {
...process.env,
SPEC_URL: specUrl,
STORE_ROOT_PATH: outputPath,
},
},
(error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
reject(new Error(`Execution failed with error: ${stderr || 'Unknown error'}`));
} else {
console.log(stdout);
if (stderr) {
reject(new Error(`Execution produced errors: ${stderr}`));
} else {
resolve();
}
}
},
);
})
);
when upgrading from 1.2.0 to 2.0.0, the error message is that /lib/bin/cli is not in exports of the package
nodeLinker is pnp
Yeah, we don't have that exposed here:
https://github.com/reduxjs/redux-toolkit/blob/cb089e6c834ff72a5457875e0f5be10a742ee239/packages/rtk-query-codegen-openapi/package.json#L10-L22
We didn't anticipate anyone trying to do what you're doing :)
Ought to be doable, though - just need to add it as an entry point in the exports section (ie "./cli").
Opened https://github.com/reduxjs/redux-toolkit/issues/4976 to track that, and I'll keep this issue open as well.
Not immediately sure when we'll have time to work on the codegen specifically, but it ought to be a fairly simple change if you'd like to file a PR!
I was able to confirm 2.0.0 does not solve the 2XX incompatibility
Now that we've shipped an updated Codegen CLI version with the CLI package exposed, are there next steps we need to do here?