Skip to content

Fix schema conversion on swagger-core 3 - #23

Merged
ruibaby merged 1 commit into
mainfrom
fix/swagger-core-3-compatibility
Nov 23, 2026
Merged

ruibaby merged 1 commit into
mainfrom
fix/swagger-core-3-compatibility

Conversation

@ruibaby

@ruibaby ruibaby commented Nov 23, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace the swagger Json.mapper() call in tool schema generation with Json31.jsonSchemaAsMap(Schema), whose JVM signature is identical in swagger-core 2.x and 3.x.
  • Update the schema test to assert the JSON numeric minimum as an Integer, matching the new conversion path.
  • Keep the plugin working on both Halo 2.26/2.27 (swagger-core 2.2.x, Jackson 2) and Halo 2.28/main (swagger-core 3.0.0, Jackson 3).

Root cause

Halo main (2.28.0-SNAPSHOT) upgrades springdoc-openapi from 3.1.0 to 3.2.1, which switches swagger-core from io.swagger.core.v3:swagger-core-jakarta:2.2.52 (Jackson 2) to io.swagger.core.v3:swagger-core:3.0.0 (Jackson 3). The return type of io.swagger.v3.core.util.Json.mapper() changes from com.fasterxml.jackson.databind.ObjectMapper to tools.jackson.databind.ObjectMapper, so the compiled call in HaloSchemaProperties no longer links and the plugin fails to start with:

java.lang.NoSuchMethodError: 'com.fasterxml.jackson.databind.ObjectMapper io.swagger.v3.core.util.Json.mapper()'

Reproduction

  1. Build Halo main (2.28.0-SNAPSHOT) and start it with an isolated work directory.
  2. Install and enable plugin-mcp-server 1.3.x.
  3. Before this change, plugin startup fails while constructing HaloMcpServer with the NoSuchMethodError above.

Verification

  • ./gradlew test spotlessCheck: 173 tests pass.
  • With a classpath switched to swagger-core 3.0.0 + Jackson 3, the old code reproduces the NoSuchMethodError; after the change, all 39 built-in tool input/output schemas are identical to those produced with swagger-core 2.2.52.
  • End-to-end on a locally built Halo 2.28.0-SNAPSHOT: the plugin reaches STARTED, logs Halo MCP server started, and POST /mcp tools/list returns HTTP 200 with 39 tools.

Notes

Released Halo 2.27.x still uses springdoc 3.1.0 and is unaffected; the change is backward compatible with it.

Json.mapper() changed its return type from Jackson 2 to Jackson 3 in
swagger-core 3.0.0, which breaks plugin startup on Halo 2.28 with
NoSuchMethodError. Use Json31.jsonSchemaAsMap() instead, which keeps the
same signature in swagger-core 2.x and 3.x.
@ruibaby
ruibaby merged commit 833a36d into main Nov 23, 2026
1 check passed
@ruibaby
ruibaby deleted the fix/swagger-core-3-compatibility branch November 23, 2026 07:28
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.

1 participant