Aias00 opened a new issue, #7592:
URL: https://github.com/apache/shenyu/issues/7592

   ## Background
   
   ShenYu admin has a legacy "API document" viewing feature exposed at 
`@RestApi("/apidoc")` (`ApiDocController`). Investigation shows this **viewer 
is completely dead** and is fully decoupled from the actually-used API-doc 
pipeline. This issue proposes removing only the dead viewer while keeping the 
live publish pipeline intact.
   
   ## Evidence
   
   - `ApiDocController` exposes only `GET /apidoc/getDocMenus` 
(`shenyu-admin/.../controller/ApiDocController.java:60`). Its data source is 
`DocManager.listAll()`.
   - `DocManagerImpl.DOC_DEFINITION_MAP` is declared at 
`DocManagerImpl.java:71` and returned by `listAll()` at `:181-182`, but has 
**zero `put` calls anywhere in the codebase** (verified by repo-wide grep). So 
`getDocMenus` always returns an empty list.
   - The writer side `DocManagerImpl.addDocInfo(...)` does **not** write to 
`DOC_DEFINITION_MAP`; it serializes an `ApiDocRegisterDTO` and publishes it to 
the registry center / gateway metadata. The two paths do not share state. This 
regression was introduced when API-doc storage moved from local cache to DB in 
commit `327bf65c` (#4849) — `listAll()` was never updated.
   - The frontend apidoc page additionally calls `GET /apidoc/getDocItem`, but 
**no such endpoint exists** on the backend → 404 (see linked issue).
   
   So the entire API-doc *viewer* is non-functional.
   
   ## What is alive (do NOT touch)
   
   The API-doc *publish* pipeline is healthy and shared by three consumers:
   
   1. Manual swagger import: `SwaggerImportServiceImpl.importSwagger` → 
`DocManager.addDocInfo` → `SwaggerDocParser` → `ApiDocRegisterDTO` → 
registry/gateway metadata.
   2. MCP tool generation: `POST /swagger/import/mcp` → `OpenAPIV3Parser` → 
`ShenyuMcpTool`.
   3. Client annotation registration: `@ShenyuApiDoc` also produces 
`ApiDocRegisterDTO`.
   
   Therefore `DocManager` (interface + `addDocInfo`), `SwaggerDocParser`, 
`ApiDocRegisterDTO`, `registerApiDocService`, `SwaggerImportServiceImpl`, and 
`ApiSourceEnum` must remain.
   
   ## Proposed removal scope (low risk)
   
   Delete only the dead viewer:
   
   - `ApiDocController` (and its test `ApiDocControllerTest`).
   - `DOC_DEFINITION_MAP` field + `listAll()` in `DocManagerImpl` (keep 
`addDocInfo`).
   - Frontend apidoc page + menu entry (the only references are the two broken 
`/apidoc/*` calls).
   
   This removes dead code without affecting swagger import, MCP generation, or 
client annotation registration.
   
   ## Alternative
   
   Instead of deleting, the viewer could be *repaired* by making `listAll()` 
read from the already-published gateway API metadata and adding the missing 
`getDocItem` endpoint (see linked issues). Removal is preferred because the 
feature has been broken since 2023 and the data already lives in the publish 
path.
   
   ## Related
   
   - Linked: API-doc detail endpoint `getDocItem` missing (404) — see the 
linked bug issue.
   - Linked: `ApiSourceEnum.IMPORT_YAPI` has no backend implementation.
   - Linked: SSRF port blacklist blocks common Spring Boot ports, breaking 
swagger import.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to