Skip to content
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

Autogen. file with syntax error on header field #59

Closed
JonJohann opened this issue Jun 18, 2021 · 2 comments
Closed

Autogen. file with syntax error on header field #59

JonJohann opened this issue Jun 18, 2021 · 2 comments

Comments

@JonJohann
Copy link

When I try the following command:

npx @rtk-incubator/rtk-query-codegen-openapi --hooks openapi.json > test.ts

I get the following syntax error, it expects a comma on line 8 around "X-Client-Product-Version":

SyntaxError: ',' expected. (8:65)
6 | endpoints: build => ({
7 | getDatasets: build.query<GetDatasetsApiResponse, GetDatasetsApiArg>({
>8 | query: queryArg => ({ url: /datasets, headers: { X-Client-Product-Version: queryArg.xClientProductVersion } })
9 | }),
10 | getDatasetMetadata: build.query<GetDatasetMetadataApiResponse, GetDatasetMetadataApiArg>({
11 | query: queryArg => ({ url: /datasets/${queryArg.datasetId}, headers: { X-Client-Product-Version: queryArg.xClientProductVersion }, params: { crs_EPSG: queryArg.crsEpsg, normalized_for_visualization: queryArg.normalizedForVisualization } })

at e (C:\Users\jonjoh\AppData\Roaming\npm-cache_npx\3844\node_modules@rtk-incubator\rtk-query-codegen-openapi\node_modules\prettier\parser-typescript.js:1:322)
at C:\Users\jonjoh\AppData\Roaming\npm-cache_npx\3844\node_modules@rtk-incubator\rtk-query-codegen-openapi\node_modules\prettier\parser-typescript.js:22:3244464
at Object.parse (C:\Users\jonjoh\AppData\Roaming\npm-cache_npx\3844\node_modules@rtk-incubator\rtk-query-codegen-openapi\node_modules\prettier\parser-typescript.js:22:3244497)
at Object.parse$a [as parse] (C:\Users\jonjoh\AppData\Roaming\npm-cache_npx\3844\node_modules@rtk-incubator\rtk-query-codegen-openapi\node_modules\prettier\index.js:13652:19)
at coreFormat (C:\Users\jonjoh\AppData\Roaming\npm-cache_npx\3844\node_modules@rtk-incubator\rtk-query-codegen-openapi\node_modules\prettier\index.js:15183:16)
at formatWithCursor$1 (C:\Users\jonjoh\AppData\Roaming\npm-cache_npx\3844\node_modules@rtk-incubator\rtk-query-codegen-openapi\node_modules\prettier\index.js:15423:14)
at C:\Users\jonjoh\AppData\Roaming\npm-cache_npx\3844\node_modules@rtk-incubator\rtk-query-codegen-openapi\node_modules\prettier\index.js:60171:12
at Object.format (C:\Users\jonjoh\AppData\Roaming\npm-cache_npx\3844\node_modules@rtk-incubator\rtk-query-codegen-openapi\node_modules\prettier\index.js:60191:12)
at Object.prettify (C:\Users\jonjoh\AppData\Roaming\npm-cache_npx\3844\node_modules@rtk-incubator\rtk-query-codegen-openapi\lib\utils\prettier.js:53:21)
at C:\Users\jonjoh\AppData\Roaming\npm-cache_npx\3844\node_modules@rtk-incubator\rtk-query-codegen-openapi\lib\bin\cli.js:90:39 {

I downloaded the file from https://raw.githubusercontent.com/kartverket/SFKB-API/master/spec/openapi.yaml as both a .yaml file and a converted json file. They both gave the same error. When comparing with the pet API used in the docs, it lacks header fields, so I suspect the problem lies with either the generation of the header fields inside the endpoints or in the openAPI spec? The spec works perfectly fine in e.g Postman.

@tevariou
Copy link
Contributor

tevariou commented Jun 25, 2021

The issue lies with the - characters in X-Client-Product-Version and it should be fixed by #52. Maybe you can try this one out?

@phryneas
Copy link
Collaborator

This should be resolved with 0.4.0

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

No branches or pull requests

3 participants