-
> frontend@0.1.0 apigen
> npx @rtk-query/codegen-openapi openapi-config.ts
{
stack: 'SyntaxError: "/Users/user/Projects/frontend/openapi-config.ts" is not a valid JSON Schema\n' +
' at SwaggerParser.parse (/Users/user/Projects/frontend/node_modules/@apidevtools/json-schema-ref-parser/lib/index.js:131:17)\n' +
' at async SwaggerParser.parse (/Users/user/Projects/frontend/node_modules/@apidevtools/swagger-parser/lib/index.js:60:18)\n' +
' at async SwaggerParser.resolve (/Users/user/Projects/frontend/node_modules/@apidevtools/json-schema-ref-parser/lib/index.js:184:5)\n' +
' at async SwaggerParser.bundle (/Users/user/Projects/frontend/node_modules/@apidevtools/json-schema-ref-parser/lib/index.js:227:5)\n' +
' at async Object.getV3Doc (/Users/user/Projects/frontend/node_modules/@rtk-incubator/rtk-query-codegen-openapi/lib/utils/getV3Doc.js:11:17)\n' +
' at async Object.generateApi (/Users/user/Projects/frontend/node_modules/@rtk-incubator/rtk-query-codegen-openapi/lib/generate.js:41:19)',
message: '"/Users/user/Projects/frontend/openapi-config.ts" is not a valid JSON Schema',
toJSON: [Function: toJSON],
name: 'SyntaxError',
toString: [Function: toString]
} The import { ConfigFile } from '@rtk-query/codegen-openapi'
const config: ConfigFile = {
schemaFile: 'http://127.0.0.1:8000/openapi.json',
apiFile: './src/fixtures/emptyApi.ts',
apiImport: 'emptySplitApi',
outputFile: './src/service/scannerApi.ts',
exportName: 'scannerApi',
hooks: true,
}
export default config And here's the import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
const API_URL = (
process.env.REACT_APP_API_URL ?
process.env.REACT_APP_API_URL : "http://127.0.0.1:8000")
const emptySplitApi = createApi({
baseQuery: fetchBaseQuery({
baseUrl: API_URL
}),
endpoints: () => ({}),
})
export {
API_URL,
emptySplitApi
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
From the stack trace, you are invoking |
Beta Was this translation helpful? Give feedback.
-
since the library |
Beta Was this translation helpful? Give feedback.
From the stack trace, you are invoking
@rtk-incubator/rtk-query-codegen-openapi
here, not@rtk-query/codegen-openapi
- and that takes a schema as command line argument, not the config file. Do you have the package names mapped weirldy somehow?