[fix] [doc] fix multiple apis in the automatically generated documentation use the same anchor point - #19193
Conversation
dave2wave
left a comment
There was a problem hiding this comment.
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
|
/pulsarbot rerun-failure-checks |
|
/pulsarbot rerun-failure-checks |
|
/pulsarbot rerun-failure-checks |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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. 🚀 New features to boost your workflow:
|
| <apiSource> | ||
| <springmvc>false</springmvc> | ||
| <operationIdFormat>{{className}}_{{methodName}}</operationIdFormat> | ||
| <outputFormats>json</outputFormats> |
There was a problem hiding this comment.
nit: Is this json outputFormats necessary?
There was a problem hiding this comment.
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.
| <apiSources> | ||
| <apiSource> | ||
| <springmvc>false</springmvc> | ||
| <operationIdFormat>{{className}}_{{methodName}}</operationIdFormat> |
There was a problem hiding this comment.
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.
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}
tisonkun
left a comment
There was a problem hiding this comment.
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.setDispatchRateandPersistentTopics.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.8ofswagger-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 generateoperationIdusing 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
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: