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

build: Auto-generate frontend API client #1547

Merged
merged 1 commit into from
May 14, 2024
Merged

Conversation

MoritzWeber0
Copy link
Member

@MoritzWeber0 MoritzWeber0 commented May 2, 2024

Instead of maintaining our own frontend library, auto-generate a client with the OpenAPI Generator.

A new target make openapi was added. It can be used to auto-generate the new client according to the generated backend OpenAPI specification. To simplify the function names, the operation IDs are derived from the backend function names.

There are some issues with the generated code, e.g., anyOf relationships are not supported. However, we don't use them in many places and they can still be updated manually.

The main.js size has increased from 3.9MB to 4MB. This can be considered as irrelevant.

The /api/v1/projects/{project_slug}/models/{model_slug}/modelsources/git/validate/path route had to be moved to /api/v1/settings/modelsources/git/validate/path. Due to API generation issues, it accepts a JSON dictionary instead of a string. It didn't use the project_slug and model_slug and better fits to the general Git instances.

In addition, tests for the Git instance routes were added.

Copy link

github-actions bot commented May 2, 2024

A Storybook preview is available for commit 94b93a3.
View Storybook
View Chromatic build

Copy link

codecov bot commented May 2, 2024

Codecov Report

Attention: Patch coverage is 96.44970% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 79.07%. Comparing base (0665eb5) to head (49b2db2).

Files Patch % Lines
backend/capellacollab/cli/__main__.py 0.00% 3 Missing ⚠️
...lab/projects/toolmodels/modelsources/git/routes.py 33.33% 2 Missing ⚠️
...nd/capellacollab/settings/modelsources/git/util.py 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1547      +/-   ##
==========================================
+ Coverage   78.36%   79.07%   +0.71%     
==========================================
  Files         171      172       +1     
  Lines        5778     5764      -14     
  Branches      663      665       +2     
==========================================
+ Hits         4528     4558      +30     
+ Misses       1098     1052      -46     
- Partials      152      154       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MoritzWeber0 MoritzWeber0 force-pushed the openapi-generator branch 12 times, most recently from 0ebef9d to d1fc1f2 Compare May 6, 2024 16:04
Copy link

github-actions bot commented May 6, 2024

The pull request does not conform to the conventional commit specification. Please ensure that your commit messages follow the spec: https://www.conventionalcommits.org/.
We also strongly recommend that you set up your development environment with pre-commit, as described in our Developer documentation. This will run all the important checks right before you commit your changes, and avoids lengthy CI wait time and round trips.

This is the commit validation log:

⧗   input: test if pipeline works
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

Here are some examples of valid commit messages:

build: Bump frontend versions
docs(user): Add model creation workflow
feat: Add a monitoring dashboard

Copy link

github-actions bot commented May 6, 2024

The generated OpenAPI client is not up to date with the latest changes in the OpenAPI specification.
Please run make openapi locally and commit the changes.

@MoritzWeber0 MoritzWeber0 force-pushed the openapi-generator branch 6 times, most recently from 06b3a25 to 7942474 Compare May 10, 2024 11:42
@MoritzWeber0 MoritzWeber0 marked this pull request as ready for review May 10, 2024 11:42
Copy link
Contributor

@dominik003 dominik003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this and applying the initial changes. There are still a few services that make http calls that we should iteratively migrate to the generated ones so that we have no http calls left in our own services. I have ignored all the template and generated stuff in this PR due to the huge amount of changes and because I assume the generation works as expected.
There are only a few comments, mostly about some minor improvements that would be great to apply before we merge this PR.

backend/capellacollab/projects/routes.py Outdated Show resolved Hide resolved
backend/capellacollab/tools/models.py Show resolved Hide resolved
backend/capellacollab/tools/routes.py Show resolved Hide resolved
backend/capellacollab/tools/routes.py Show resolved Hide resolved
backend/tests/settings/test_git_instances.py Show resolved Hide resolved
frontend/src/app/sessions/service/session.service.ts Outdated Show resolved Hide resolved
frontend/src/app/sessions/service/user-session.service.ts Outdated Show resolved Hide resolved
frontend/src/main.ts Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented May 14, 2024

Quality Gate Passed Quality Gate passed

Issues
5 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@MoritzWeber0 MoritzWeber0 merged commit f1bf7a6 into main May 14, 2024
30 checks passed
@MoritzWeber0 MoritzWeber0 deleted the openapi-generator branch May 14, 2024 10:38
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

Successfully merging this pull request may close these issues.

2 participants