Skip to content

[BUG] skipIfSpecIsUnchanged fails with binary example #24644

Description

@manuelbl

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

If the input specification contains a property for binary data (type: string, format: byte) and also an example for the property, the option skipIfSpecIsUnchanged of the Maven plugin no longer works. The plugin generates the output even if the specification has not changed.

Expected behavior:

The first maven run generates the output files. Subsequent maven runs only display [INFO] Code generation is skipped because input was unchanged and skip the generation (unless the specification changes).

Current behavior:

All maven runs generate the output files.

openapi-generator version

Version 7.24.0

OpenAPI declaration file content or url

OpenAPI specification:

openapi: 3.0.3
info:
  title: My Image
  description: JSON with image data.
  version: 1.0.0
servers:
  - url: https://api.example.com/v1
paths:
  /my-image:
    get:
      summary: Get the image
      operationId: getImage
      responses:
        '200':
          description: The requested image
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Image'
components:
  schemas:
    Image:
      type: object
      properties:
        imageData:
          type: string
          format: byte
          example: bm8gcmVhbCBpbWFnZQo=

Maven pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>repro</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <build>
    <plugins>
      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>7.25.0-SNAPSHOT</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.basedir}/example.yaml</inputSpec>
              <generatorName>java</generatorName>
              <skipIfSpecIsUnchanged>true</skipIfSpecIsUnchanged>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
Generation Details

The above two files are all that's needed for reproduction.

I've used Java 25 and Maven 3.9.14. But it's likely independent of these version.

Steps to reproduce
  1. Run mvn generate-sources – the output files are generated
  2. Run mvn generate-sources again – the output files are generated again even though the input specification has not changed

Actual output:

[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------< com.example:repro >--------------------------
[INFO] Building repro 1.0.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- openapi-generator:7.24.0:generate (default) @ repro ---
[INFO] Generating with dryRun=false
[INFO] Output directory (/home/repro/target/generated-sources/openapi) does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.
[INFO] OpenAPI Generator: java (client)
[INFO] Generator 'java' is considered stable.
[INFO] Environment variable JAVA_POST_PROCESS_FILE not defined so the Java code may not be properly formatted. To define it, try 'export JAVA_POST_PROCESS_FILE="/usr/local/bin/clang-format -i"' (Linux/Mac)
[INFO] NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[INFO] Processing operation getImage
[INFO] writing file /home/repro/target/generated-sources/openapi/src/test/java/org/openapitools/client/model/ImageTest.java
[INFO] writing file /home/repro/target/generated-sources/openapi/docs/Image.md
...
[INFO] writing file /home/repro/target/generated-sources/openapi/.openapi-generator/FILES
############################################################################################
# Thanks for using OpenAPI Generator.                                                      #
# We appreciate your support! Please consider donating to help us maintain this project.   #
# https://opencollective.com/openapi_generator/donate                                      #
############################################################################################
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.589 s
[INFO] Finished at: 2026-08-07T19:36:23+02:00
[INFO] ------------------------------------------------------------------------

Expected output:

[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------< com.example:repro >--------------------------
[INFO] Building repro 1.0.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- openapi-generator:7.24.0:generate (default) @ repro ---
[INFO] Code generation is skipped because input was unchanged
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.410 s
[INFO] Finished at: 2026-08-07T19:40:26+02:00
[INFO] ------------------------------------------------------------------------
Related issues/PRs

None

Suggest a fix

The Maven plugin parses and the input specification, creates an SHA256 hash and compares the hash against the hash from a previous run. However, the input for the hash is not stable. The binary example for example is contained with a string of the form example: [B@81d9a72. That's the result of Java toString() for a byte array. It is a transient value, changing from run to run.

I will provide a PR to make the hash stable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions