Skip to content

fix: stop boat:bundle writing default: null and value: null - #1321

Merged
jjjasper merged 4 commits into
mainfrom
fix/bundle-null-defaults
Nov 9, 2026
Merged

jjjasper merged 4 commits into
mainfrom
fix/bundle-null-defaults

Conversation

@bartveenstra

Copy link
Copy Markdown
Contributor

Summary

From 0.18.4 to 0.19.1, boat:bundle (and boat:generate with bundleSpecs) writes default: null on every schema. Generators then reject the spec on non-nullable schemas. For example, iam-auth-server fails generating from the published consent-service-api 1.4.0, which has 158 of them. Bundling also writes value: null next to every example $ref.

This PR fixes both, guards the build against the cause coming back, and adds lint rule B025 so specs that were already published with the problem get flagged.

Root cause

The plugin realm runs two swagger-parser versions side by side:

boat-maven-plugin
├── org.openapitools.openapidiff:openapi-diff-core:2.1.7
│   └── io.swagger.parser.v3:swagger-parser-v3:2.1.31   <- nearest, so Maven picks this one
└── com.backbase.oss:boat-engine
    └── io.swagger.parser.v3:swagger-parser:2.1.48
        └── io.swagger.parser.v3:swagger-parser-v3:2.1.48  (loses)

The root POM only managed the swagger-parser aggregator, not the modules under it.

  • swagger-parser-v3 2.1.31 calls setDefault(null) on schemas that have no default.
  • swagger-models 2.2.54+ tracks that call in defaultSetFlag and serializes it as default: null.
  • boat 0.18.4 bumped swagger-core from 2.2.43 to 2.2.54, which is when the output started changing.

value: null is the same flag mechanism: Example.setValue(null) marks the value as set.

Bundling the consent service sources with each boat version:

boat version default: null value: null
0.17.39, 0.18.0, 0.18.3 0 11
0.18.4 – 0.19.1 116 11
0.19.1 with parser-v3 pinned to 2.1.48 0 11
this branch 0 0

Apart from those removed lines, the output on this branch is identical to 0.19.1.

Changes

  • Dependency alignment (root pom.xml): manage swagger-parser-v3, swagger-parser-core, swagger-parser-v2-converter and swagger-parser-safe-url-resolver at ${swagger-parser.version}. They keep the same exclusions as the aggregator.
  • Guard (boat-maven-plugin/pom.xml): a maven-enforcer dependencyConvergence rule limited to io.swagger.parser.v3:* and io.swagger.core.v3:*. Without the alignment above it fails and points at the openapi-diff-core path.
  • value: null: call setValueSetFlag(false) after setValue(null) in ExamplesProcessor, ExampleHolder and DirectoryExploder.
  • Lint rule B025 (MUST): reports default: null on a schema that does not allow null. In OpenAPI 3.0 that means no nullable: true; in 3.1, no null in type.
    • The rule reads the document as written. Zally's model merges allOf schemas, which drops their default, and reports shared schemas at the wrong location. Zally's document tree drops null values altogether.
    • On the published consent 1.4.0 spec it reports all 158 occurrences. On that spec re-bundled with this branch it reports none.
  • README: 0.19.2 release notes. They ask publishers who bundled with 0.18.4–0.19.1 to re-bundle and republish.

Consumer impact

  • Specs bundled with 0.18.4–0.19.1 keep their default: null until they are re-bundled with this version and republished.
  • Older swagger-parser versions (2.1.22, used by boat 0.17.x) report these as errors such as "default is not of type object".
  • B025 only fails a build when failOnWarning is enabled. Add B025 to ignoreRules to opt out.

Test plan

  • BundleMojoTest.testBundleDoesNotAddNullDefaultsOrValues: a new spec with path and query parameters, an object schema with several property types, and an external example $ref. Without the fixes the bundle has 10 default: null and 1 value: null and the test fails. With them it passes.
  • BundlerTests.testBundleApi: asserts getValueSetFlag() is false on the cleaned-up example and that the serialized spec has no value: null. It fails without the engine change.
  • NoNullDefaultRuleTest has 8 cases:
    • object, property, parameter and response schemas
    • allOf, reported where the schema is declared
    • nullable schemas and non-null defaults, which pass
    • OpenAPI 3.1 with and without null in type
  • mvn verify -pl boat-engine,boat-quay/boat-quay-rules,boat-maven-plugin -am passes, including the invoker ITs. The enforcer rule passes.
  • With 0.19.2-SNAPSHOT installed, bundling the consent service sources writes no default: null or value: null, and its 11 example $refs are kept.

bartveenstra and others added 4 commits November 9, 2026 17:04
Example.setValue(null) marks the value as set in swagger-models 2.2.x, so bundled and exploded specs carried a value: null next to every example $ref. Clear the flag wherever the value is replaced by a $ref.

Co-authored-by: Cursor <[email protected]>
openapi-diff-core brings swagger-parser-v3 2.1.31 closer to the plugin than boat-engine's 2.1.48, so Maven picked the older parser. That parser calls setDefault(null) on every schema, and swagger-models 2.2.54+ (boat 0.18.4 and later) then serializes default: null. Manage all swagger-parser modules at one version and fail the plugin build when the swagger-parser or swagger-core modules diverge again.

Co-authored-by: Cursor <[email protected]>
Generators reject a default: null on a schema that does not allow null. The rule reads the document as written, because Zally's model merges allOf schemas and its document tree drops null values.

Co-authored-by: Cursor <[email protected]>
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@jjjasper
jjjasper merged commit b23c99a into main Nov 9, 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