OpenAPITools/openapi-generator · error · IllegalArgumentException

The [%s] Documentation Provider is not supported by this gen

Error message

The [%s] Documentation Provider is not supported by this generator

What it means

AbstractJavaCodegen.processOpts resolves the documentationProvider option and throws IllegalArgumentException when the value — although a valid provider (none, source, swagger1, swagger2, springdoc) — is not in the concrete generator's supportedDocumentationProvider() set. Different Java generators support different provider subsets.

Source

Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java:424

        cliOptions.add(CliOption.newString(CodegenConstants.DEFAULT_TO_EMPTY_CONTAINER, CodegenConstants.DEFAULT_TO_EMPTY_CONTAINER_DESC));
    }

    @Override
    public void processOpts() {
        useCodegenAsMustacheParentContext();
        super.processOpts();

        if (null != defaultDocumentationProvider()) {
            documentationProvider = DocumentationProvider.ofCliOption(
                    (String) additionalProperties.getOrDefault(DOCUMENTATION_PROVIDER,
                            defaultDocumentationProvider().toCliOptValue())
            );

            if (!supportedDocumentationProvider().contains(documentationProvider)) {
                String msg = String.format(Locale.ROOT,
                        "The [%s] Documentation Provider is not supported by this generator",
                        documentationProvider.toCliOptValue());
                throw new IllegalArgumentException(msg);
            }

            annotationLibrary = AnnotationLibrary.ofCliOption(
                    (String) additionalProperties.getOrDefault(ANNOTATION_LIBRARY,
                            documentationProvider.getPreferredAnnotationLibrary().toCliOptValue())
            );

            if (!supportedAnnotationLibraries().contains(annotationLibrary)) {
                String msg = String.format(Locale.ROOT, "The Annotation Library [%s] is not supported by this generator",
                        annotationLibrary.toCliOptValue());
                throw new IllegalArgumentException(msg);
            }

            if (!documentationProvider.supportedAnnotationLibraries().contains(annotationLibrary)) {
                String msg = String.format(Locale.ROOT,
                        "The [%s] documentation provider does not support [%s] as complementary annotation library",
                        documentationProvider.toCliOptValue(), annotationLibrary.toCliOptValue());
                throw new IllegalArgumentException(msg);

View on GitHub (pinned to fcec517be3)

Solutions

  1. Pick a documentation provider the specific generator supports — check the generator's README/help output for documentationProvider values.
  2. Omit the documentationProvider option to fall back to the generator's defaultDocumentationProvider().
  3. Switch to a generator that supports the provider you need if the documentation output is a hard requirement.

Example fix

# before (generator only supports springdoc):
openapi-generator-cli generate -g java -i api.yaml -p documentationProvider=source
# after:
openapi-generator-cli generate -g java -i api.yaml -p documentationProvider=springdoc
# or simply omit the option to use the default
Defensive patterns

Strategy: validation

Validate before calling

// Programmatic use: verify against the generator instance before setting options
JavaGenerator gen = ...; // concrete generator
String provider = (String) additionalProperties.getOrDefault("documentationProvider",
        gen.defaultDocumentationProvider().toCliOptValue());
DocumentationProvider parsed = DocumentationProvider.ofCliOption(provider.toUpperCase(Locale.ROOT));
if (!gen.supportedDocumentationProvider().contains(parsed))
    throw new IllegalArgumentException("Pick from: " + gen.supportedDocumentationProvider());

Type guard

const DOC_PROVIDERS = ['none', 'source', 'swagger1', 'swagger2', 'springdoc'] as const;
export type DocProvider = typeof DOC_PROVIDERS[number];
export function isDocProvider(v: string): v is DocProvider {
    return (DOC_PROVIDERS as readonly string[]).includes(v);
}
// NOTE: passing the guard is necessary but not sufficient — the concrete generator's supported set decides.

Prevention

When it happens

Trigger: Passing -p documentationProvider=source (or springdoc, etc.) to a Java generator whose supportedDocumentationProvider() excludes it. The value is resolved via DocumentationProvider.ofCliOption, then the membership check fails and option processing aborts.

Common situations: Copying a working option set from one Java generator (spring, jaxrsjersey) to another that supports only swagger2 or springdoc; upgrading generator versions where the supported set changed; typos usually produce a different 'No enum constant' error, so this one means a valid-but-unsupported combination.

Related errors


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