-
Notifications
You must be signed in to change notification settings - Fork 177
Description
Description
The --markdown output option fails with a NullPointerException when generating markdown reports, while the console output and --json output work correctly.
Steps to Reproduce
- Run openapi-diff with markdown output:
docker run --rm -v $(pwd):/specs openapitools/openapi-diff:latest \
/specs/swagger.json /specs/main.json --markdown /specs/report.md- The command fails with the error below, despite the console output showing the comparison completed successfully.
Expected Behavior
The markdown file should be generated successfully, similar to how the console output and JSON output work.
Actual Behavior
The command throws a NullPointerException:
java.lang.NullPointerException: Cannot invoke "org.openapitools.openapidiff.core.model.ChangedSchema.isDiscriminatorPropertyChanged()" because "schema" is null
at org.openapitools.openapidiff.core.output.MarkdownRender.schema(MarkdownRender.java:289)
at org.openapitools.openapidiff.core.output.MarkdownRender.itemContent(MarkdownRender.java:248)
at org.openapitools.openapidiff.core.output.MarkdownRender.lambda$bodyContent$7(MarkdownRender.java:222)
Environment
- Docker Image:
openapitools/openapi-diff:latest - OpenAPI Version: 3.0.1
- Date Tested: November 27, 2025
Console Output (Successful)
When running without --markdown, the tool works correctly:
==========================================================================
== API CHANGE LOG ==
==========================================================================
Targeting.DayPartingApi
--------------------------------------------------------------------------
-- What's Changed --
--------------------------------------------------------------------------
- PUT /targeting
Request:
- Changed application/json
Schema: Backward compatible
- Changed text/json
Schema: Backward compatible
- Changed application/*+json
Schema: Backward compatible
--------------------------------------------------------------------------
-- Result --
--------------------------------------------------------------------------
API changes are backward compatible
--------------------------------------------------------------------------
Root Cause Analysis
The error occurs in MarkdownRender.java at line 289, where it attempts to call isDiscriminatorPropertyChanged() on a null ChangedSchema object. The markdown renderer appears to be less tolerant of null schemas compared to the console renderer.
The issue specifically arises when:
- The API has schema changes in request/response bodies
- The
ChangedSchemaobject is null for certain content types - The markdown renderer tries to check all schema properties without null-checking
Workarounds
- Use JSON output instead:
docker run --rm -v $(pwd):/specs openapitools/openapi-diff:latest \
/specs/swagger.json /specs/main.json --json /specs/report.json- Use console output and parse manually:
docker run --rm -v $(pwd):/specs openapitools/openapi-diff:latest \
/specs/swagger.json /specs/main.json --info > output.txtImpact
- Severity: Medium
- Affected Feature: Markdown output generation (
--markdownflag) - Impact: Users cannot generate markdown reports but can use JSON or console output as alternatives
Additional Context
This issue was discovered when comparing two OpenAPI 3.0.1 specifications where the request body examples changed but the schemas remained the same. The tool correctly identifies the changes as backward compatible but fails during markdown generation.