{"record":{"id":"d0b6b497ca335ed6","repo":"OpenAPITools/openapi-generator","slug":"mergedfileoutputdir-must-be-set-when-inputspecfile-d0b6b4","errorCode":null,"errorMessage":"mergedFileOutputDir must be set when inputSpecFiles is used","messagePattern":"mergedFileOutputDir must be set when inputSpecFiles is used","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/ValidateMojo.java","lineNumber":284,"sourceCode":"    if (isInputSpecEmpty && isBlank(inputSpecRootDirectory) && (inputSpecFiles == null || inputSpecFiles.isEmpty())) {\n      LOGGER.error(\"inputSpec, inputSpecRootDirectory, or inputSpecFiles must be specified\");\n      throw new MojoExecutionException(\"inputSpec, inputSpecRootDirectory, or inputSpecFiles must be specified\");\n    }\n  }\n\n  private boolean shouldWeSkip() {\n    if (Boolean.TRUE.equals(skip) || Boolean.TRUE.equals(skipValidateSpec)) {\n      getLog().info(\"Validation is skipped.\");\n      return true;\n    }\n    return false;\n  }\n\n  private Optional<String> mergeInDirectory() throws MojoExecutionException {\n    // Explicit file list takes precedence\n    if (inputSpecFiles != null && !inputSpecFiles.isEmpty()) {\n      if (mergedFileOutputDir == null) {\n        throw new MojoExecutionException(\"mergedFileOutputDir must be set when inputSpecFiles is used\");\n      }\n      MergedSpecBuilder.MergeMode resolvedMergeMode;\n      try {\n        resolvedMergeMode = MergedSpecBuilder.MergeMode.valueOf(mergeMode.toUpperCase(Locale.ROOT));\n      } catch (IllegalArgumentException e) {\n        throw new MojoExecutionException(\"Invalid mergeMode value '\" + mergeMode\n            + \"'. Valid values are: REF, DEEP\");\n      }\n\n      MergedSpecBuilder builder = new MergedSpecBuilder(inputSpecFiles, mergedFileOutputDir.getAbsolutePath(),\n          mergedFileName, mergedFileInfoName, mergedFileInfoDescription, mergedFileInfoVersion, auth)\n          .withMergeMode(resolvedMergeMode);\n\n      if (resolvedMergeMode == MergedSpecBuilder.MergeMode.DEEP) {\n        try {\n          builder.withConflictStrategy(\n              MergedSpecBuilder.MergeConflictStrategy.valueOf(mergeConflictStrategy.toUpperCase(Locale.ROOT)));\n        } catch (IllegalArgumentException e) {","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/ValidateMojo.java#L266-L302","documentation":"ValidateMojo.mergeInDirectory throws this when the explicit-file-list mode is chosen (inputSpecFiles non-empty) but mergedFileOutputDir is null. The merged spec must be written somewhere before it can be validated, so the plugin requires the directory and fails with a MojoExecutionException before attempting any merge.","triggerScenarios":"Configuring <inputSpecFiles> for the validate goal without a sibling <mergedFileOutputDir>; or configuring the directory only on the generate execution and expecting the validate execution to inherit it (per-execution configuration does not merge that way).","commonSituations":"Splitting specs into per-domain files and wiring validation for the merged result; POM refactors that moved merge settings into a profile not active during validation.","solutions":["Add <mergedFileOutputDir>${project.build.directory}/merged-spec</mergedFileOutputDir> alongside <inputSpecFiles> in the validate execution.","Keep generate and validate merge settings in sync by placing them in the plugin-level <configuration> so both executions inherit them.","If file-list merging is not wanted for validation, point <inputSpec> at the already-merged file instead."],"exampleFix":"<!-- before -->\n<configuration>\n  <inputSpecFiles>\n    <inputSpecFile>specs/core.yaml</inputSpecFile>\n  </inputSpecFiles>\n</configuration>\n\n<!-- after -->\n<configuration>\n  <inputSpecFiles>\n    <inputSpecFile>specs/core.yaml</inputSpecFile>\n  </inputSpecFiles>\n  <mergedFileOutputDir>${project.build.directory}/merged-spec</mergedFileOutputDir>\n</configuration>","handlingStrategy":"validation","validationCode":"# inputSpecFiles without mergedFileOutputDir -> fail before Maven does\nxmllint --xpath \"//*[local-name()='inputSpecFiles']\" pom.xml >/dev/null 2>&1 && \\\n  ! xmllint --xpath \"//*[local-name()='mergedFileOutputDir']\" pom.xml >/dev/null 2>&1 && \\\n  { echo 'mergedFileOutputDir required when inputSpecFiles is used'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Place merge-related settings (inputSpecFiles, mergedFileOutputDir, mergedFileName, mergeMode) in one shared configuration block.","Check both generate and validate executions after moving merge config into a profile.","Use ${project.build.directory} for the merged output so clean removes it."],"tags":["openapi-generator","maven","plugin-config","spec-merging","missing-parameter"],"backgroundTag":"missing-required-config","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}