OpenAPITools/openapi-generator · error · MojoExecutionException

inputSpec, inputSpecRootDirectory, or inputSpecFiles must be

Error message

inputSpec, inputSpecRootDirectory, or inputSpecFiles must be specified

What it means

Thrown by ValidateMojo.validateInputSpecInput when none of the spec inputs is configured: the inputSpec array is null/empty/blank-first-element, inputSpecRootDirectory is blank, and inputSpecFiles is null or empty. It is the validate goal's equivalent of the generate goal's first guard and fails before any reading or merging of specs.

Source

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

      }

      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.");
      return true;
    }
    return false;
  }

  private Optional<String> mergeInDirectory() throws MojoExecutionException {
    // Explicit file list takes precedence
    if (inputSpecFiles != null && !inputSpecFiles.isEmpty()) {
      if (mergedFileOutputDir == null) {
        throw new MojoExecutionException("mergedFileOutputDir must be set when inputSpecFiles is used");
      }
      MergedSpecBuilder.MergeMode resolvedMergeMode;

View on GitHub (pinned to fcec517be3)

Solutions

  1. Add <inputSpec>${project.basedir}/src/main/resources/openapi.yaml</inputSpec> to the validate execution's configuration.
  2. For directory merges use <inputSpecRootDirectory>; for explicit lists use <inputSpecFiles> plus <mergedFileOutputDir>.
  3. If both goals exist in the POM, put shared settings in one <configuration> at plugin level so validate inherits inputSpec from generate.

Example fix

<!-- before -->
<execution>
  <id>validate-spec</id>
  <goals><goal>validate</goal></goals>
</execution>

<!-- after -->
<execution>
  <id>validate-spec</id>
  <goals><goal>validate</goal></goals>
  <configuration>
    <inputSpec>${project.basedir}/src/main/resources/openapi.yaml</inputSpec>
  </configuration>
</execution>
Defensive patterns

Strategy: validation

Validate before calling

# CI: every validate execution must reference a spec input
grep -q 'openapi-generator' pom.xml && \
  ! grep -Eq '<inputSpec>|<inputSpecRootDirectory>|<inputSpecFiles>' pom.xml && \
  { echo 'validate goal has no spec input configured'; exit 1; }

Prevention

When it happens

Trigger: Running mvn openapi-generator:validate without <inputSpec> (or -DinputSpec), no inputSpecRootDirectory, and no inputSpecFiles. Note inputSpec is an array here — a single blank first element (empty tag or whitespace property) also counts as missing.

Common situations: Adding a validation execution to the POM but forgetting to mirror the spec path from the generate execution; property typo like <input-spec>; CI jobs invoking the validate goal directly with the -D flag dropped.

Related errors


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