-
Notifications
You must be signed in to change notification settings - Fork 11
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
fix(ui): Adapt the UI to the latest API changes #224
fix(ui): Adapt the UI to the latest API changes #224
Conversation
Note that IMO #223 should be merged first, and then the API code in here be regenerated afterwards, to reflect the new |
The "Build and test" check failing is because of a bug in A temporary fix would be adding
to the two files causing the error, but I'm a bit reluctant to do it, as changing manually a part of software which is auto-generated isn't really wise I think. The failing test doesn't appear to affect the query client's functionality in any way. If the team verdict is I should do the manual additions to auto-generated files to get "build and test" passing, I will do so. |
A few options:
I'd say 1 is probably the best in short-term. If the manual addition of the headers is cumbersome, we could write a small bash script that is executed with the generator script. |
Well it depends on how often the OpenAPI spec will change (I would guess it is still volatile), and how long does the bug fixing in upstream take. I can surely add those lines manually for some time. |
280b323
to
5e4c191
Compare
I know we had talked about this, but now that I see the diff of this PR I yet wonder whether it would be feasible to separate purely auto-generated code from the manual changes required. While that would break with the every-commit-must-pass-all-checks-convention, it would more clearly show what manual changes were needed, which helps if anything similar needs to be done in the future again. So I'd expected three commits currently:
|
OpenAPI query client library update to v1 (PR eclipse-apoapsis#157) introduced major changes to the structure and functionality of the query client. Moreover, PR eclipse-apoapsis#181 introduced a fix to OpenAPI generation of nullable values, which brought major changes to the Swagger JSON. This commit regenerates the query client from scratch to adapt to these changes. The command used for regenerating is: pnpm codegen Signed-off-by: Jyrki Keisala <[email protected]>
There is a bug [1] in the codegen tool that causes it to generate unused query keys for requests with no parameters. This commit renames the unused query keys to start with an underscore '_' to pass the lint checks for unused variables. NOTE: This is not a lasting solution, as every regeneration of the query client will revert these changes. [1]: 7nohe/openapi-react-query-codegen#112 Signed-off-by: Jyrki Keisala <[email protected]>
The changed query client lead to some fixes needed in the UI code to adapt to changes, which are listed here for further reference: - to access the "message" and "cause" fields of the ApiError body in the error toast component, intermediate type casting of error.body to "any" was needed. NOTE: it should be investigated, why this has changed, as before we had direct access to error.body.message and error.body.cause in the UI - earlier on, the service functions like ProductsService.getProductById() were called with passing parameters directly, but now the parameters need to be passed as objects - The openapi-react-query-codegen uses openapi-ts as an underlying engine for code generation, and inline enums were broken in the latter [2]. While this has already been fixed in openapi-ts, the fix has not yet been taken into use in openapi-react-query-codegen [1]. Until the openapi-react-query-codegen is updated, the inline enums need to be accessed differently, as in z.nativeEnum(CreateRepository.type) needs to be changed into z.enum($CreateRepository.properties.type.enum) Note that when the library is updated, this change probably needs to be reverted back to its original form. [1]: 7nohe/openapi-react-query-codegen#110 [2]: hey-api/openapi-ts#547 Signed-off-by: Jyrki Keisala <[email protected]>
The PRs #157, #181 and #223 introduced some major changes to the generated UI API which all need to be adapted in the UI codebase.
To assist with further similar PRs and clearly separate manual changes from auto-generated ones, we do not use the "every commit must pass all checks" convention in this PR.
Please see the individual commits for details.