OpenAPITools/openapi-generator · error · MojoExecutionException

Validation has error(s). See above for the details.

Error message

Validation has error(s). See above for the details.

What it means

End-of-goal wrapper in ValidateMojo: when validation reports errors (or warnings while <strictSpec>true</strictSpec>), the mojo throws a bare Exception inside its try block, which the catch converts to MojoExecutionException('Validation has error(s). See above for the details.'). The per-rule findings were already logged above by logInvalid, so the details live in the preceding log output, not in the exception.

Source

Thrown at modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/ValidateMojo.java:256

            if (buildContext != null) {
              buildContext.addMessage(inputSpecFile, 0, 0, e.getMessage(), BuildContext.SEVERITY_WARNING, null);
            }
          }
        }
      }
      if (dryRun) {
        if (hasError || (strictSpec && hasWarning)) {
          getLog().warn("Validation issues detected in dry-run mode. Please review the results.");
          getLog().info("The build will not fail because dryRun is active.");
        }
        return;
      }

      if (hasError || (strictSpec && hasWarning)) {
        throw new Exception();
      }
    } catch (Exception e) {
      throw new MojoExecutionException(
          "Validation has error(s). See above for the details.");
    } finally {
      GlobalSettings.log();
    }
  }

  private void validateInputSpecInput() throws MojoExecutionException {
    boolean isInputSpecEmpty = (inputSpec == null || inputSpec.length == 0 || isBlank(inputSpec[0]));

    if (isInputSpecEmpty && isBlank(inputSpecRootDirectory) && (inputSpecFiles == null || inputSpecFiles.isEmpty())) {
      LOGGER.error("inputSpec, inputSpecRootDirectory, or inputSpecFiles must be specified");
      throw new MojoExecutionException("inputSpec, inputSpecRootDirectory, or inputSpecFiles must be specified");
    }
  }

  private boolean shouldWeSkip() {
    if (Boolean.TRUE.equals(skip) || Boolean.TRUE.equals(skipValidateSpec)) {
      getLog().info("Validation is skipped.");

View on GitHub (pinned to fcec517be3)

Solutions

  1. Scroll up in the log: each 'invalid' line names the rule and location — fix those spec issues and rerun.
  2. For warning-only failures under strict mode, either fix the warnings or set <strictSpec>false</strictSpec> if warnings are acceptable.
  3. Use <dryRun>true</dryRun> while triaging to see all issues without failing the build.
  4. Run openapi-generator-cli validate on the same file locally for faster iteration than a full mvn cycle.

Example fix

<!-- before -->
<configuration>
  <inputSpec>${project.basedir}/api.yaml</inputSpec>
  <strictSpec>true</strictSpec>
</configuration>

<!-- after -->
<configuration>
  <inputSpec>${project.basedir}/api.yaml</inputSpec>
  <strictSpec>false</strictSpec>
</configuration>
Defensive patterns

Strategy: validation

Validate before calling

<!-- triage without breaking the build -->
<configuration>
  <inputSpec>${project.basedir}/api.yaml</inputSpec>
  <dryRun>true</dryRun>
</configuration>

Try / catch

# CI: validate locally first, print rule details, then decide
openapi-generator-cli validate -i api.yaml || {
  echo 'spec validation failed; fix the rules listed above before pushing'; exit 1;
}

Prevention

When it happens

Trigger: Running openapi-generator:validate on a spec that violates rules (invalid $ref, wrong type shapes, missing required fields) with dryRun=false; or a spec with only warnings while strictSpec is true. With <dryRun>true</dryRun> or skip/skipValidateSpec the goal returns without failing.

Common situations: Adding spec validation to a CI gate and legacy specs failing on pre-existing issues; strictSpec=true tightening warning handling; upgrading openapi-generator to a version with new/stricter validation rules that now flag previously passing specs.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22). Data as JSON: /api/errors/86e5d3e7076fa823. Report an issue: GitHub.