Skip to content

fix: keep strings that look like numbers quoted in AsyncAPI bundles - #1328

Merged
jjjasper merged 2 commits into
mainfrom
fix/asyncapi-bundle-numeric-strings
Nov 11, 2026
Merged

jjjasper merged 2 commits into
mainfrom
fix/asyncapi-bundle-numeric-strings

Conversation

@bartveenstra

Copy link
Copy Markdown
Contributor

Summary

boat:bundle for AsyncAPI writes strings that look like numbers without quotes. A CloudEvents envelope with

specversion:
  type: string
  const: "1.0"

is bundled as const: 1.0, which YAML reads as the number 1.0. No message then validates against the published bundle (/specversion: must be the constant value '1.0'), and consumers have to patch the spec before they can use it. The same happens to enum: ["1", "2"], examples: ["123"] and any other string that looks like a number.

Root cause

AsyncApiBundler has its own YAML writer with MINIMIZE_QUOTES but without ALWAYS_QUOTE_NUMBERS_AS_STRINGS. OpenAPI bundles don't have the problem: they go through swagger-core's ObjectMapperFactory, which enables both. This PR enables the missing feature. Real numbers are written as numbers and stay unquoted.

Verification

  • New AsyncApiBundlerTest.keepsStringsThatLookLikeNumbersQuoted fails on main and passes here.
  • mvn -B test passes for all modules.
  • Bundling the factory approval events spec, which has two CloudEvents envelopes, the only difference between 0.19.3 and this branch is these two lines:
-          const: 1.0
+          const: "1.0"

Not fixed here

While writing the test, maximum: 10 in a draft-2020-12 schema came out of the bundle as maximum: 1E+1. That comes from the schema projection, not the YAML writer, so it is left for a separate fix.

Made with Cursor

AsyncApiBundler wrote YAML with MINIMIZE_QUOTES but without ALWAYS_QUOTE_NUMBERS_AS_STRINGS, so a string such as the CloudEvents specversion const "1.0" came out as the number 1.0. Enable the feature, as swagger-core's YAML writer for OpenAPI bundles already does.
@jjjasper
jjjasper enabled auto-merge (squash) November 11, 2026 15:14
@sonarqubecloud

Copy link
Copy Markdown

@jjjasper
jjjasper merged commit 8b63a10 into main Nov 11, 2026
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.

2 participants