-
Notifications
You must be signed in to change notification settings - Fork 151
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
Generate OpenAPI spec during compile #1279
base: master
Are you sure you want to change the base?
Conversation
…mpatibility issue with CRA
… UserService.test.ts
@@ -18,11 +18,13 @@ | |||
"@types/react-router-bootstrap": "^0.26.6", | |||
"@types/react-router-dom": "^5.3.3", | |||
"@types/yup": "^0.32.0", | |||
"axios": "^1.6.5", | |||
"axios": "0.27.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting an error like described here: openapistack/openapi-client-axios#172
Turns out, this is an incompatibility issue related to create-react-app.
I had it fixed by downgrading axios' version, as suggested here: facebook/create-react-app#12823 (comment)
In the long run, we might think about migrating this project out of CRA and into Vite-backed codebase, as suggested in the first link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm that's from 2022, shouldn't we be concerned that we're using such an old dependency? CRA maybe needs to be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah you write about that. Probably this vite thing should happen sooner rather than later?
ui/README.md
Outdated
@@ -12,6 +12,12 @@ Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | |||
The page will reload if you make edits.<br /> | |||
You will also see any lint errors in the console. | |||
|
|||
#### API client & associated types | |||
|
|||
Before running `yarn start`, make sure to run `sbt "backend/generateOpenAPISpec"` in the project's root directory. This command will generate the `<project_root>/backend/target/openapi.yaml` file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok so I did yarn start
after pulling these changes, and the terminal hangs on:
[~/projects/bootzooka/ui]% yarn start
yarn run v1.22.19
$ yarn generate:openapi-types && concurrently "react-scripts start" "yarn watch:openapi"
$ npx openapicmd typegen ../backend/target/openapi.yaml > src/api-client/openapi.d.ts
While in src/api-client/openapi.d.ts
I got:
Need to install the following packages:
openapicmd
Ok to proceed? (y)
this probably should go to the terminal? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After answering "y" to the (hidden) question, I got:
/bin/sh: concurrently: command not found
error Command failed with exit code 127.
probably some setup that I'm missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so running ./frontend-start.sh
, which does yarn install
helped ;) Maybe consolidating the READMEs would be a good idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I got:
error @oclif/[email protected]: The engine "node" is incompatible with this module. Expected version ">=18.0.0". Got "16.15.1"
error Found incompatible module.
node 16 is specified as the minimum in package.json
. Maybe this should be updated?
Somewhat unrelated to the core task, but maybe https://softwaremill.github.io/bootzooka/stack.html would be good to extend with the main libraries used on the frontend - there are things like Formik or Yup (and possibly others) which I might guess as to why they are used, but it would be good to describe it too |
After starting I get a warning:
Another thing to update probably? |
More warnings, these seem to be connected to the client generation:
|
But despite the warnings, the UI works :) |
.then((client) => client.postUserLogin(null, { ...params, apiKeyValidHours: 1 })) | ||
.then(({ data }) => apiKeySchema.validate(data)); | ||
|
||
export const register = (payload: RegisterParamsPayload) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we generate these values as well? they seem to follow the same pattern, and that they can be fully computed from the API spec? this applies to the validation as well, doesn't it exactly follow what's in the OpenAPI schema?
No description provided.