Skip to content

[fix] [doc] fix multiple apis in the automatically generated documentation use the same anchor point - #19193

Merged
poorbarcode merged 1 commit into
apache:masterfrom
poorbarcode:doc/fix_admin_api_for_swagger
Mar 9, 2023
Merged

[fix] [doc] fix multiple apis in the automatically generated documentation use the same anchor point#19193
poorbarcode merged 1 commit into
apache:masterfrom
poorbarcode:doc/fix_admin_api_for_swagger

Conversation

@poorbarcode

@poorbarcode poorbarcode commented Jan 11, 2023

Copy link
Copy Markdown
Contributor

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 and PersistentTopics.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 of swagger-maven-plugin, there are another ways to set operationId: 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 generate operationId using the specified rule {className}_{methodName}.

截屏2023-03-08 16 04 47

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions Bot added the doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. label Jan 11, 2023

@dave2wave dave2wave left a comment

Copy link
Copy Markdown
Member

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.

@poorbarcode poorbarcode changed the title [fix] [doc] [fix] [doc] fix multiple apis in the automatically generated documentation use the same anchor point [fix] [doc] fix multiple apis in the automatically generated documentation use the same anchor point Jan 11, 2023
@poorbarcode
poorbarcode force-pushed the doc/fix_admin_api_for_swagger branch from 1a991e1 to baf7e79 Compare January 11, 2023 18:02
@poorbarcode

Copy link
Copy Markdown
Contributor Author

Hi @dave2wave

These look like actual API changes. Please explain.

Already changed the plain to only modify Swagger annotations. please take a look again

@poorbarcode
poorbarcode requested a review from dave2wave January 12, 2023 02:00
@mattisonchao

mattisonchao commented Jan 12, 2023

Copy link
Copy Markdown
Member

@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!

@tisonkun

tisonkun commented Jan 12, 2023

Copy link
Copy Markdown
Member

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).

cc @tuteng @shoothzj

@hezhangjian

Copy link
Copy Markdown
Member

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.

@github-actions

Copy link
Copy Markdown

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions Bot added the Stale label Feb 12, 2023
@poorbarcode
poorbarcode force-pushed the doc/fix_admin_api_for_swagger branch from 413fb63 to e414067 Compare March 8, 2023 07:56
@poorbarcode

Copy link
Copy Markdown
Contributor Author

@tisonkun @tuteng @heesung-sn

Please take a look, thanks

@poorbarcode poorbarcode added type/bug The PR fixed a bug or issue reported a bug ready-to-test and removed Stale labels Mar 8, 2023
@poorbarcode poorbarcode self-assigned this Mar 8, 2023
@poorbarcode

Copy link
Copy Markdown
Contributor Author

/pulsarbot rerun-failure-checks

@poorbarcode poorbarcode added this to the 3.0.0 milestone Mar 8, 2023
@poorbarcode

Copy link
Copy Markdown
Contributor Author

/pulsarbot rerun-failure-checks

@tisonkun
tisonkun self-requested a review March 8, 2023 11:04
@poorbarcode

Copy link
Copy Markdown
Contributor Author

/pulsarbot rerun-failure-checks

@codecov-commenter

codecov-commenter commented Mar 8, 2023

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.31%. Comparing base (af1360f) to head (e414067).
⚠️ Report is 2761 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@              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     
Flag Coverage Δ
inttests 24.53% <ø> (-0.05%) ⬇️
systests 25.28% <ø> (?)
unittests 59.54% <ø> (+42.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1364 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread pulsar-broker/pom.xml
<apiSource>
<springmvc>false</springmvc>
<operationIdFormat>{{className}}_{{methodName}}</operationIdFormat>
<outputFormats>json</outputFormats>

@heesung-sohn heesung-sohn Mar 8, 2023

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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.

Comment thread pulsar-broker/pom.xml
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<operationIdFormat>{{className}}_{{methodName}}</operationIdFormat>

@heesung-sohn heesung-sohn Mar 8, 2023

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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}

@tisonkun tisonkun added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages and removed type/bug The PR fixed a bug or issue reported a bug labels Mar 9, 2023

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

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.

@tisonkun
tisonkun requested review from hezhangjian and tuteng March 9, 2023 02:46
@poorbarcode

Copy link
Copy Markdown
Contributor Author

Hi @tisonkun

Please take a look at the OWASP failure. Although it seems unrelated to this patch, we should fix it later.

I have pushed a #19764 to fix it, so I am merging the current PR now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. ready-to-test type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants