OpenAPITools/openapi-generator · error · RuntimeException

Error! Codegen Property not yet supported in getPydanticType

Error message

Error! Codegen Property not yet supported in getPydanticType: %s

What it means

In AbstractPythonCodegen's pydantic type-mapping pass, getPydanticType(CodegenProperty, ...) must reduce every property to a Python type through its handled branches (primitives, containers, enums, and model refs/imports). A property that matches no branch falls through to this RuntimeException, meaning the generator has no pydantic type mapping for that property shape — an implementation gap in the generator, not a configuration mistake.

Source

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

                            if (circularImports.get(cp.getDataType()).contains(classname)) {
                                hasModelsToImport = true;
                                postponedModelImports.add(cp.getDataType());
                                postponedExampleImports.add(cp.getDataType());
                                // cp.getDataType() import map of set contains this model (classname), don't import
                                LOGGER.debug("Skipped importing {} in {} due to circular import.", cp.getDataType(), classname);
                            } else {
                                // not circular import, so ok to import it
                                hasModelsToImport = true;
                                modelImports.add(cp.getDataType());
                                exampleImports.add(cp.getDataType());
                            }
                        } else {
                            LOGGER.error("Failed to look up {} from the imports (map of set) of models.", cp.getDataType());
                        }
                    }
                    result = new PythonType(cp.getDataType());
                } else {
                    throw new RuntimeException("Error! Codegen Property not yet supported in getPydanticType: " + cp);
                }
            }

            return result;
        }

        private String finalizeType(CodegenProperty cp, PythonType pt) {
            if (!StringUtils.isEmpty(cp.description)) { // has description
                pt.annotate("description", cp.description);
            }

            // field
            String publicName = (String) cp.vendorExtensions.get(X_PY_PUBLIC_NAME);
            if (publicName != null) {
                String aliasName = cp.vendorExtensions.containsKey(X_PY_EXPLICIT_PUBLIC_NAME)
                        || cp.vendorExtensions.containsKey(X_PY_LEGACY_PUBLIC_NAME)
                        ? publicName
                        : cp.baseName;

View on GitHub (pinned to fcec517be3)

Solutions

  1. Read the CodegenProperty dump in the message to find the failing property, then simplify it — hoist nested oneOf/anyOf into named component schemas the mapper can import as models
  2. Upgrade openapi-generator to the latest release; pydantic type coverage improves constantly
  3. If it still fails on the current release, open a GitHub issue with the model snippet — the message itself says the case is not yet supported

Example fix

# before
settings:
  type: object
  additionalProperties:
    oneOf:
      - type: string
      - type: number

# after (hoisted into an importable schema)
settings:
  type: object
  additionalProperties:
    $ref: '#/components/schemas/SettingValue'
Defensive patterns

Strategy: try-catch

Try / catch

try {
    new DefaultGenerator().opts(clientOptInput).generate();
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("not yet supported in getPydanticType")) {
        // message dumps the full CodegenProperty: use it to locate and simplify that model
        throw new BuildFailure("Unsupported pydantic property shape: " + e.getMessage(), e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Generating Python (pydantic v2 output) when a model property has a shape the mapper does not cover — e.g. a map whose additionalProperties is a composed oneOf/anyOf, arrays of free-form objects, or other deeply nested compositions, depending on release. The message prints the full CodegenProperty toString, which identifies the offending property.

Common situations: Large real-world specs (payments/cloud APIs) with unusual property constructs; upgrading a spec to OpenAPI 3.1 composition styles while the generator is pinned to an older release.

Related errors


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