swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.48k stars 8.96k forks source link

Enhancement Request: Consistent URI Generation for Swagger API Documentation #9126

Open canflypeople opened 1 year ago

canflypeople commented 1 year ago

Enhancement Request: Consistent URI Generation for Swagger API Documentation

Current Behavior:

Currently, Swagger generates API documentation endpoint paths based on the combination of method names and the "Using" keyword followed by the HTTP method type used in the code. This results in any alteration to method names directly affecting the API documentation URLs.

Desired Enhancement:

I propose an enhancement to the Swagger API documentation generation process. Instead of relying solely on method names, I suggest adopting a more adaptable approach that incorporates both the existing endpoint URI and the HTTP method type associated with each API endpoint.

Example:

For instance, consider the following endpoint definition:

If the method name is modified to fetchUserData, the current behavior would lead to a change in the documentation URI:

However, with the proposed enhancement, the documentation URI would remain consistent by considering the HTTP method type along with the endpoint URI:

Advantages:

  1. Improved Stability: Method name changes won't impact documentation URIs.
  2. Endpoint Consistency: Documentation URIs will consistently match the actual API endpoint URI.
  3. Enhanced Readability: Documentation URLs will be more intuitive and easier to manage.

Implementation:

To implement this enhancement, the Swagger generation process could be updated to utilize the existing endpoint URI and the HTTP method type combined to form the documentation URIs.

I believe this enhancement would significantly enhance the usability and maintainability of Swagger-generated API documentation.

Thank you for considering this proposal. Please feel free to request further details or share your thoughts on this approach.

satokenta940 commented 7 months ago

The document generation is currently using Apidog, which can solve your problem. I think its UI looks better, and of course, Swagger is also very good.