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

[AMORO-3256] Amoro Open Api with Swagger in Ams #3296

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

mansonliwh
Copy link
Contributor

@mansonliwh mansonliwh commented Oct 23, 2024

Why are the changes needed?

Close #3256.

Brief change log

This PR introduces Swagger and OpenAPI Generator. To avoid intrusive development, this design does not use a large number of annotations on the controller. Instead, it predefines the openapi.yaml. The interface specifications defined in openapi.yaml are used to generate the Swagger page, API docs, and an SDK using the Apache HttpClient framework.

In the Maven build, you can use the generate-sdk profile to specify whether to generate the SDK.

How was this patch tested?

  • [ ☑️ ] Add screenshots for manual tests if appropriate

Swagger Page:
image

Auth Setting:
image

Generated API docs & SDK demo:
image

  • [ ☑️ ] Run test locally before making a pull request

@github-actions github-actions bot added module:ams-server Ams server module type:build module:ams-dashboard Ams dashboard module labels Oct 23, 2024
@@ -408,6 +409,66 @@
<scope>test</scope>
</dependency>

<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

we can use ${swagger.version} replace 2.2.10

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we may define the versions in properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your suggestion. I have removed that part of the dependency.


<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

the latest version is 7.9.0 why we don't use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the latest version is 7.9.0 why we don't use it?

Thank you for your suggestion. The latest version has dependency conflicts, and I believe the current version should be stable enough to meet the requirements.

@codecov-commenter
Copy link

codecov-commenter commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 21.60%. Comparing base (f13f3f3) to head (0c7516a).
Report is 16 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (f13f3f3) and HEAD (0c7516a). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (f13f3f3) HEAD (0c7516a)
core 1 0
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3296      +/-   ##
============================================
- Coverage     30.17%   21.60%   -8.57%     
+ Complexity     3840     2311    -1529     
============================================
  Files           580      426     -154     
  Lines         48020    39719    -8301     
  Branches       6207     5623     -584     
============================================
- Hits          14488     8582    -5906     
+ Misses        32542    30409    -2133     
+ Partials        990      728     -262     
Flag Coverage Δ
core ?
trino 21.60% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

@mansonliwh Thanks for the contribution! I left some comments.

@@ -35,6 +35,7 @@
<url>https://amoro.apache.org</url>

<properties>
<skip-generate-sdk>false</skip-generate-sdk>
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, we should not generate the SDK by default as it is not required for everyone.
But the doc is necessary for the dashboard.

So we may need to separate the properties for SDK and DOC.

@@ -408,6 +409,66 @@
<scope>test</scope>
</dependency>

<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we may define the versions in properties.

<version>2.2.10</version>
</dependency>

<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the dependency by default?
Or should we separate them for the doc and the SDK?

Copy link
Contributor Author

@mansonliwh mansonliwh Nov 8, 2024

Choose a reason for hiding this comment

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

Do we need the dependency by default? Or should we separate them for the doc and the SDK?

Thank you for your suggestion. I have already enabled the default 'skip' option while separated the 'doc' and the 'sdk'.

<version>4.1.1</version>
</dependency>

<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

We already had httpclient:5.2 and httpcore:5.2 dependencies in runtime scope, do we still need this?

@github-actions github-actions bot added type:docs Improvements or additions to documentation module:common labels Nov 8, 2024
@github-actions github-actions bot removed type:docs Improvements or additions to documentation module:common labels Nov 8, 2024
@mansonliwh mansonliwh force-pushed the feature-swagger branch 2 times, most recently from ae5b21e to b136b28 Compare November 8, 2024 02:34
mounted() {
SwaggerUI({
dom_id: '#swagger-ui',
url: '/swagger-docs', // 这里是你的 OpenAPI 规范文件的路径
Copy link
Contributor

Choose a reason for hiding this comment

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

Comments should be English.

amoro-web/src/router/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@czy006 czy006 left a comment

Choose a reason for hiding this comment

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

At present, we have no relevant descriptive documents for this section. Maybe we need to supplement them.

@mansonliwh mansonliwh force-pushed the feature-swagger branch 2 times, most recently from cbd34de to 49a35cf Compare November 22, 2024 07:46
Copy link
Contributor

@czy006 czy006 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

@mansonliwh I left some comments, PTAL.

amoro-ams/pom.xml Outdated Show resolved Hide resolved
amoro-ams/pom.xml Outdated Show resolved Hide resolved
amoro-ams/pom.xml Outdated Show resolved Hide resolved
@mansonliwh mansonliwh force-pushed the feature-swagger branch 2 times, most recently from fd62196 to 0c7516a Compare November 26, 2024 02:24
amoro-ams/pom.xml Outdated Show resolved Hide resolved
amoro-ams/pom.xml Outdated Show resolved Hide resolved
Copy link
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

LGTM.

Thanks for the contribution!

@czy006 czy006 merged commit 9e0f057 into apache:master Nov 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:ams-dashboard Ams dashboard module module:ams-server Ams server module type:build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: Amoro Open Api with Swagger in Ams
5 participants