Skip to content

fix: render Console Swagger Request Body schemas - #771

Open
Tfh-Yqf wants to merge 1 commit into
higress-group:mainfrom
Tfh-Yqf:fix/swagger-ui-request-body-schema-3207
Open

fix: render Console Swagger Request Body schemas#771
Tfh-Yqf wants to merge 1 commit into
higress-group:mainfrom
Tfh-Yqf:fix/swagger-ui-request-body-schema-3207

Conversation

@Tfh-Yqf

@Tfh-Yqf Tfh-Yqf commented Aug 25, 2026

Copy link
Copy Markdown

Ⅰ. Describe what this PR did

When Console Swagger UI is enabled (all-in-one / helm swagger.enabled), Request Body panels stayed empty because:

  1. springdoc-openapi-ui 1.8.0 transitively ships swagger-ui 5.10.3, which cannot render requestBody schemas (fixed upstream in swagger-ui 5.11.10).
  2. Controllers often omit consumes, so springdoc emits only a */* media type; Swagger UI then has nothing concrete to paint.

This PR:

  • Excludes the transitive swagger-ui webjar and pins 5.18.2 directly on the console module
  • Sets springdoc.default-consumes/produces-media-type=application/json
  • Adds OpenApiRequestBodyCustomizer to copy wildcard requestBody schemas onto application/json
  • Adds regression tests for the webjar pin, schema generation, and media-type rewrite

Ⅱ. Does this pull request fix one issue?

Fixes higress-group/higress#3207

Ⅲ. Why don't you add test cases (unit test/integration test)?

Added:

  • SwaggerUiWebjarVersionTest — classpath / locator must serve swagger-ui >= 5.11.10
  • OpenApiRequestBodySchemaTest — representative @RequestBody DTOs must resolve to non-empty schemas
  • OpenApiRequestBodyCustomizerTest — wildcard / empty / already-json edge cases

mvn -pl console -am test: 20 tests, 0 failures.

Ⅳ. Describe how to verify it

  1. Build and run Console with Swagger enabled:
    SPRINGDOC_API_DOCS_ENABLED=true SPRINGDOC_SWAGGER_UI_ENABLED=true
  2. Open /swagger-ui/index.html
  3. Expand a POST/PUT such as POST /v1/routes — Request Body should list fields (name, path, services, ...)
  4. Optionally run: mvn -pl console -am test -Dfrontend.skip=true

Ⅴ. Special notes for reviews

Related earlier fix: higress-console#654 (swagger-ui 5.11.10). This PR hardens the override (explicit dependency + exclusion), bumps to 5.18.2, and closes the still-open higress#3207 with schema/media-type coverage.

Pin swagger-ui 5.18.2 (and exclude springdoc's 5.10.3 webjar), normalize
wildcard requestBody media types to application/json, and add regression
tests so all-in-one Swagger UI shows body fields again.

Fixes higress-group/higress#3207

Co-authored-by: Cursor <cursoragent@cursor.com>
@CLAassistant

CLAassistant commented Aug 25, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

使用all in one 的方式部署服务,swagger的request Body不显示参数

2 participants