-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] [doc] fix multiple apis in the automatically generated documentation use the same anchor point #19193
[fix] [doc] fix multiple apis in the automatically generated documentation use the same anchor point #19193
Conversation
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.
These look like actual API changes. Please explain.
1a991e1
to
baf7e79
Compare
Hi @dave2wave
Already changed the plain to only modify Swagger annotations. please take a look again |
@tisonkun What do you think about this PR? I am unfamiliar with swagger, but I know you have recently worked on this part. please help to review it, thanks! |
I agree that it's not a breaking change for end-users but only affects the doc experience. Some related works previous:
And I agree that a nickname alias can be a better solution. I can approve this move but I appreciate seeing the discussion on the mailing list continue for a while (days or after the lunar new year holiday). |
Now we aggregate rest api into a single file. I think it might be better to split them. This is also good for us to generate other language admin clients. I am trying to work on it. |
The pr had no activity for 30 days, mark with Stale label. |
413fb63
to
e414067
Compare
Please take a look, thanks |
/pulsarbot rerun-failure-checks |
/pulsarbot rerun-failure-checks |
/pulsarbot rerun-failure-checks |
Codecov Report
@@ Coverage Diff @@
## master #19193 +/- ##
=============================================
+ Coverage 26.40% 62.31% +35.91%
+ Complexity 6427 3503 -2924
=============================================
Files 1597 1848 +251
Lines 123682 135866 +12184
Branches 13511 14952 +1441
=============================================
+ Hits 32658 84665 +52007
+ Misses 86336 43466 -42870
- Partials 4688 7735 +3047
Flags with carried forward coverage won't be shown. Click here to find out more.
|
<configuration> | ||
<apiSources> | ||
<apiSource> | ||
<springmvc>false</springmvc> | ||
<operationIdFormat>{{className}}_{{methodName}}</operationIdFormat> | ||
<outputFormats>json</outputFormats> |
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.
nit: Is this json outputFormats necessary?
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.
nit: Is this json outputFormats necessary?
It should be optional, but maven or swagger had issues, and I had null Pointers when testing locally. I tried troubleshooting the issue yesterday but couldn't get the root cause quickly, so I thought adding this configuration would avoid unnecessary trouble.
<configuration> | ||
<apiSources> | ||
<apiSource> | ||
<springmvc>false</springmvc> | ||
<operationIdFormat>{{className}}_{{methodName}}</operationIdFormat> |
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.
nit: I think {className}_{methodName}
is reasonable as the unique operationIdFormat.
LGTM if we don't have duplicated apiSources from the same class and methodName.
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 keeping only the latest version of admin API(such as v2
, v3
), {className}_{methodName}
will not conflict. If we open multiple versions of API in the future, we need to change the rule to {package_name}_{className}_{methodName}
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.
Please take a look at the OWASP failure. Although it seems unrelated to this patch, we should fix it later.
Motivation
Now that site admin-rest-api is automatically generated through swagger, each API in the site has its own link that we can walk through, the generated rule of API-link is
https://pulsar.apache.org/admin-rest-api/#operation/{operationId}
, we call the suffix#operation/{operationId}
of link anchor.Since the {operationId}'s default value is the method name of the endpoint class, and there has the same method name in the multi endpoint-classes, such as
Namespaces.setDispatchRate
andPersistentTopics.setDispatchRate
, so these both APIs will generate the same link:https://pulsar.apache.org/admin-rest-api/#operation/setDispatchRate
.Modifications
In the update to version
3.1.8
ofswagger-maven-plugin,
there are another ways to setoperationId
: The Operation Id Format. see https://github.com/kongchen/swagger-maven-plugin/blob/e4cf3af6ed4a4987b2269a05b7037549bc4a5511/src/main/java/com/github/kongchen/swagger/docgen/reader/AbstractReader.java#L535-L540. So we can generateoperationId
using the specified rule{className}_{methodName}.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: