Skip to content

feat: align boat:lint with RESTful API in Backbase v3 and fix security alerts - #1318

Merged
bartveenstra merged 9 commits into
mainfrom
feat/lint-restful-api-v3-rules
Nov 10, 2026
Merged

bartveenstra merged 9 commits into
mainfrom
feat/lint-restful-api-v3-rules

Conversation

@bartveenstra

@bartveenstra bartveenstra commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Aligns boat:lint with the RESTful API in Backbase v3 guideline. It fixes a crash on OpenAPI 3.1 specs, resolves the rules that contradicted the guideline, and adds rules for its core requirements.

The new checks are SHOULD and start as preview rules. Their violations are reported, marked (preview) in the log and labelled in the HTML report, but never fail the build, even with failOnWarning. A rule is promoted to blocking by removing it from the new previewRules parameter.

Changes

  • Fix B014 on OpenAPI 3.1. The parser can pass example values as plain Java maps, and the rule's cast to JsonNode threw a ClassCastException. The rule also read schema.type, which is null on 3.1 because the type is in types. The new SchemaUtil handles both.

  • previewRules parameter on boat:lint. The default is B004, B016–B024, M010. Supporting changes:

    • BoatLinter(ignoreRules, previewRules).
    • BoatLintReport.hasBlockingViolations(), used by LintMojo to decide whether to fail.
    • The preview marker in BoatViolation.displayString().
    • The label in the HTML report.
  • Rules that contradicted the guideline:

    • B004 checks the optional info.x-api-dashboard-tags instead of the top-level tags, which the guideline uses for grouping operations.

    • M010 casing follows the guideline:

      • camelCase properties (plus _links and _metadata) and path parameters;
      • Hyphenated-Pascal-Case headers, plus the Service SDK X-CXT-RequestUUID and X-B3-* headers;
      • snake_case or SCREAMING_SNAKE_CASE enum values.

      M010 is no longer in the default ignoreRules; it is a preview rule instead.

    • B016 flags 405, 408, 422 and 5xx responses.

  • New rules, all SHOULD:

    Rule Check
    B017 No verbs in paths, except after webhooks
    B018 The path version (/v2/) matches the major version of info.version
    B019 application/json without parameters such as charset
    B020 Response bodies are objects, list responses have an items array, top-level lists do not return 404
    B021 List endpoints declare size (integer, default 20, max 100 for client-api, 1000 otherwise) and page (minimum 0) or cursor
    B022 Date and time properties have format date-time, date or time
    B023 Amounts are strings with format number; currencies are strings with pattern ^[A-Z]{3}$ and no enum
    B024 4xx application/json responses use the Service SDK error body (string message, optional key and errors)
  • Violation pointers for the new rules. Pointers are built from the path, method, status, media type or property. On 3.1 the parser can share one model object between identical parts of a document, so Zally's object lookup would point at the wrong operation.

  • Docs. Added 0.19.2 release notes in README.md and documented previewRules in the boat:lint section of boat-maven-plugin/README.md.

  • Also included: the CloudEvents AsyncAPI test specs in boat-trail-resources are replaced with a generic pet adoption example that covers the same features.

Impact on consumers

  • M010 now runs by default, so casing violations appear. They are preview, so they don't block the build.
  • If a project sets ignoreRules or previewRules, that list replaces the default one.

Testing

  • Each new rule has a test class with a compliant and a violating spec, parameterized over OpenAPI 3.0.3 and 3.1.0.
  • BoatLinterTests lints two guideline fixtures:
    • follows-guideline.yaml has no guideline violations.
    • violates-guideline.yaml triggers every preview rule, with identical violations and pointers on 3.0.3 and 3.1.0.
  • LintMojoTests: preview-only violations don't fail with failOnWarning, and do fail when previewRules is empty.
  • Results locally:
    • boat-quay-rules: 132 passed
    • boat-quay-lint: 15 passed
    • scaffold BoatLintTests: 2 passed
    • LintMojoTests: 11 passed
    • AsyncAPI tests touched by 5ab56e0: 29 passed

Known limitations

  • On 3.0, Zally merges the allOf members of component schemas when it resolves the document. B022/B023 violations on such properties point at the composed schema instead of the allOf member.
  • The existing B014 still finds pointers by object lookup, so on 3.1 some of its violations can point at another operation. This PR does not change that.

Security fixes

This PR also fixes the four open Dependabot alerts on main, and updates the Spring generator templates so generated projects no longer get the vulnerable Spring Framework versions either. These changes were first opened as #1319.

Changes

  • commons-lang 2.6 (GHSA-j288-q9x7-2f5v, alerts Release 0.2.1 #31 and Feature/return of the diff #30). commons-lang 2.x is end of life and has no fixed version.

    • boat-scaffold used it for one call: the escapeJavascript Mustache lambda in BoatExample, which the boat-angular mocks template uses. It now uses StringEscapeUtils.ESCAPE_ECMASCRIPT from commons-text 1.14.0, the version the plugin already resolves. The commons-lang3 equivalent is deprecated in favour of commons-text. The escaped output is the same as commons-lang 2.6 for quotes, backslashes, /, control characters and non-ASCII characters.
    • Two scaffold tests used org.apache.commons.lang.UnhandledException; they now use lang3's UncheckedException.
    • boat-maven-plugin declared commons-lang without using it, so the dependency is removed.
  • spring-core 6.1.21 (GHSA-jmp9-x22r-554x, GHSA-659m-px2c-25wj, alerts Master #33 and Release 0.2.4 #38). In the plugin integration-test example (boat-maven-plugin/src/it/example/pom.xml), Spring Boot goes from 3.3.13 to 3.5.16 and spring-core from 6.1.21 to 6.2.19.

  • Generator templates. The templates were unchanged copies of upstream openapi-generator 7.20 and generated projects on vulnerable versions: Spring Boot 3.3.13 brings spring-core 6.1.21, and Spring Boot 4.0.1 brings spring-core 7.0.2, which is affected by GHSA-659m-px2c-25wj (fixed in 7.0.8).

    Template Change
    boat-spring spring-boot/pom-sb3.mustache Spring Boot 3.3.13 → 3.5.16, springdoc 2.6.0 → 2.8.17
    boat-spring spring-cloud/pom-sb3.mustache Spring Boot 3.3.13 → 3.5.16, Spring Cloud 2023.0.0 → 2025.0.3, springdoc 2.2.0 → 2.8.17
    boat-spring spring-http-interface/pom.mustache Spring Boot 3.3.13 → 3.5.16
    boat-spring spring-boot/pom-sb4.mustache Spring Boot 4.0.1 → 4.0.9, springdoc 2.6.0 → 3.0.3
    boat-spring spring-cloud/pom-sb4.mustache Spring Boot 4.0.1 → 4.0.9, Spring Cloud 2025.1.0 → 2025.1.4, springdoc 2.2.0 → 3.0.3, no longer pins spring-security-oauth2-client 6.1.1
    boat-spring spring-http-interface/pom-sb4.mustache Spring Boot 4.0.1 → 4.0.9
    boat-java restclient pom.mustache and build.gradle.mustache spring-web 6.1.21 → 6.2.19

    The companion versions follow each Boot line:

    • Spring Cloud 2025.0 is the release train for Boot 3.5 and 2025.1 for Boot 4.0; older trains fail Spring Cloud's compatibility check.
    • springdoc 2.8 is the line for Boot 3.5 (releases before 2.7 break on Spring Framework 6.2), and springdoc 3.0 for Boot 4.0.
    • The Boot 4 spring-cloud template pinned the Spring Security 6.1 oauth2 client next to Boot 4's Spring Security 7. It now leaves the version to Spring Boot, as the Boot 3 template already did.

Testing

  • mvn dependency:tree shows no commons-lang:commons-lang in any module.
  • Unit tests pass, including BoatAngularTemplatesTests, which generates mocks.
  • mvn -pl boat-maven-plugin -am verify -Dgpg.skip passes. That covers all plugin invoker integration tests, including the example project, which compiles and tests generated Spring code against Boot 3.5.16.
  • The boat-scaffold invoker tests pass. They build the 8 generated Boot 3 spring-boot projects against Boot 3.5.16 and springdoc 2.8.17.
  • Manual check of the other templates. I generated a project from each and built it with mvn package:
    • Boot 3 spring-cloud, Boot 3 spring-http-interface, Boot 4 spring-cloud and Boot 4 spring-http-interface build. The Boot 4 spring-cloud project resolves spring-core 7.0.10 and Spring Security 7.0.8 throughout.
    • restclient and Boot 4 spring-boot needed workarounds for the existing bugs below, and then build.
    • A generated Boot 3 spring-boot app starts on Boot 3.5.16 and serves /v3/api-docs.
    • A generated Boot 4 spring-boot app starts on Boot 4.0.9 and serves /v3/api-docs and Swagger UI through springdoc 3.0.3.

Existing bugs found, not fixed here

All of these happen with the old versions too.

  • boat-java restclient doesn't generate ServerConfiguration and ServerVariable, so the generated ApiClient doesn't compile. For the manual build, I copied the two classes from the upstream java generator.
  • Boot 4 spring-boot (pom-sb4.mustache) declares spring-boot-starter-restclient twice, at compile and test scope. Maven 3.10 rejects the generated pom; older Maven only warns. The generator also doesn't write ApiUtil, which the generated API interfaces use. For the manual build, I removed the duplicate and copied ApiUtil from the upstream spring generator.
  • boat-spring spring-http-interface with useSpringBoot3=true fails because the library has no pom-sb3.mustache.

Not changed

  • The Spring Boot 2 templates (pom.mustache in spring-boot and spring-cloud) stay on Boot 2.7.15 and Spring Framework 5.3. Spring Framework 5.3 has no open-source fix for these advisories.
  • The asyncapi integration-test module (boat-maven-plugin/src/it/example/boat-generate/asyncapi/pom.xml) still imports the Boot 3.3.13 and Spring Cloud 2023.0.5 BOMs. It resolves spring-core 6.2.19 through the parent pin.

bartveenstra and others added 7 commits November 5, 2026 11:50
On OpenAPI 3.1 the parser can return example values as plain Java maps
instead of JsonNode, so checkResponseExampleFulfill crashed the whole lint
with a ClassCastException. Example values are now converted with
ObjectMapper.valueToTree.

Schema types are read through the new SchemaUtil.typeNames, which looks at
both type (3.0) and types (3.1), so nested objects and arrays are checked
on 3.1 documents instead of being reported as missing.

Co-authored-by: Cursor <[email protected]>
boat:lint gets a previewRules parameter. Violations of preview rules are
logged with a "(preview)" marker and labelled in the HTML report, but never
fail the build, even with failOnWarning. A rule is promoted by removing it
from the list.

The default previewRules are B004 and M010:
- B004 now validates info.x-api-dashboard-tags, when present, against the
  product and informative tags. Top-level tags are no longer required or
  restricted.
- M010 is no longer ignored by default. Its CaseChecker config follows the
  RESTful API v3 guideline: camelCase path parameters, _metadata,
  SCREAMING_SNAKE_CASE enum values and the Service SDK headers.

Co-authored-by: Cursor <[email protected]>
Add the rules B016 to B024 for the "RESTful API in Backbase v3" guideline: no 405, 408, 422 or 5xx responses, no verbs in paths, path version matching info.version, plain application/json, list response shape, pagination parameters, date and time formats, money and currency, and the Service SDK error body. All are SHOULD and in the default previewRules, so they are reported but do not fail the build. Violations point at the path, operation, response or property they come from, so OpenAPI 3.0 and 3.1 documents report the same locations.

Co-authored-by: Cursor <[email protected]>
Replace commons-lang 2.6 (GHSA-j288-q9x7-2f5v) with commons-text in
boat-scaffold and drop the unused dependency from boat-maven-plugin.
Bump Spring Boot to 3.5.16 and spring-core to 6.2.19 in the plugin IT
example (GHSA-jmp9-x22r-554x, GHSA-659m-px2c-25wj).

Co-authored-by: Cursor <[email protected]>
The boat-spring templates generated projects on Spring Boot 3.3.13,
which brings the vulnerable spring-core 6.1. They now use Spring Boot
3.5.16 with the matching Spring Cloud 2025.0.3 train and springdoc
2.8.17, since older springdoc releases fail on Spring Framework 6.2.
The boat-java restclient templates use spring-web 6.2.19.

Co-authored-by: Cursor <[email protected]>
Spring Boot 4.0.1 brings spring-core 7.0.2, which is affected by
GHSA-659m-px2c-25wj. The Spring Boot 4 templates now use Spring Boot
4.0.9 with Spring Cloud 2025.1.4 and springdoc 3.0.3, the springdoc line
for Spring Boot 4. The spring-cloud template no longer pins
spring-security-oauth2-client 6.1.1, so Spring Boot manages it with the
rest of Spring Security 7.

Co-authored-by: Cursor <[email protected]>
@bartveenstra bartveenstra changed the title feat: align boat:lint with RESTful API in Backbase v3 feat: align boat:lint with RESTful API in Backbase v3 and fix security alerts Nov 9, 2026
… specs

Replace the CloudEvents AsyncAPI test specs with a pet adoption example
that covers the same features: JSON Schema 2020-12 Multi Format Schema
Objects, const, if/then, shared schemas in a sibling directory, untagged
receive and send operations, and channel x-producers/x-consumers.

Co-authored-by: Cursor <[email protected]>
return Schema<Any>().apply {
properties = members.mapNotNull { it.properties }.fold(LinkedHashMap()) { merged, properties ->
merged.apply { putAll(properties) }
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolve() merges allOf members into a new Schema but copies only properties, required, types and items. format, pattern, enum, minimum, maximum and default are dropped. A property like allOf: [{$ref: DateTime}] (the usual 3.0 way to add a description to a $ref) then loses its format, so B022 reports a false "should have format date-time". B023 (pattern/enum) and B021 (maximum/default) have the same problem.


fun visit(schema: Schema<*>?, pointer: JsonPointer) {
if (schema == null || !visited.add(schema)) {
return

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perf nit: namedProperties() walks the whole document and is recomputed independently by B022 and B023. Caching it in the Context (or sharing it between rules) avoids two full traversals plus allOf merging per lint on large specs.

Resolve README 0.19.2 release notes conflict by keeping the bundle/null-default
fixes from main and the RESTful API v3 lint rules from this branch.

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

Copy link
Copy Markdown

@bartveenstra
bartveenstra merged commit c5e16d6 into main Nov 10, 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