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

kotlin-spring supports only the 'none', 'source' and 'springdoc' documentation providers (see supportedDocumentationProvider() at KotlinSpringServerCodegen.java:433). During processOpts() the CLI value is parsed with DocumentationProvider.ofCliOption() and rejected with an IllegalArgumentException if the parsed provider is valid for other generators but not for this one. The parser upper-cases the input, so provider values are case-insensitive, but 'swagger1'/'swagger2' — although valid enum constants — are not offered by kotlin-spring.

Source

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

                || (additionalProperties.containsKey(USE_SPRING_BOOT4)
                    && convertPropertyToBoolean(USE_SPRING_BOOT4));
        if (springBoot4Enabled) {
            additionalProperties.put(USE_JACKSON_3, "true");
        }

        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. Use `documentationProvider=springdoc` (the default for kotlin-spring) or `source`/`none`.
  2. If you specifically need swagger2/swagger-core generated specs, switch to `-g java-spring` (SpringCodegen supports those providers).
  3. Run `openapi-generator-cli config-help -g kotlin-spring` to list the documentationProvider values this generator actually accepts before setting them.

Example fix

# before
openapi-generator-cli generate -g kotlin-spring -i api.yaml \
  --additional-properties documentationProvider=swagger2
# after
openapi-generator-cli generate -g kotlin-spring -i api.yaml \
  --additional-properties documentationProvider=springdoc
Defensive patterns

Strategy: validation

Validate before calling

// allow-list mirrors supportedDocumentationProvider() for kotlin-spring
Set<String> supported = Set.of("NONE", "SOURCE", "SPRINGDOC");
String dp = String.valueOf(opts.getOrDefault("documentationProvider", "SPRINGDOC"))
        .toUpperCase(Locale.ROOT);
if (!supported.contains(dp)) {
    throw new IllegalArgumentException(
        "kotlin-spring documentationProvider must be one of " + supported);
}

Try / catch

try {
    new DefaultGenerator().opts(clientOptInput).generate();
} catch (IllegalArgumentException e) {
    // e.getMessage() names the unsupported provider; map it to the supported set for the user
    throw new BuildException("Invalid kotlin-spring options: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Running `-g kotlin-spring` with `--additional-properties documentationProvider=swagger1` or `documentationProvider=swagger2` (valid DocumentationProvider values that kotlin-spring does not support). Note: a completely unknown string like 'swagger' fails earlier, inside DocumentationProvider.ofCliOption()'s valueOf(), with a different 'No enum constant' message.

Common situations: Copy-pasting generator options from a java-spring project (which does support swagger2) into a kotlin-spring build; migrating Maven/Gradle plugin configOptions between the Java and Kotlin Spring generators; trying to use Swagger-Core UI instead of springdoc.

Related errors


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