Skip to content

[core] Set isMap on properties that updatePropertyForMap turns into maps - #25073

Open
manduinca wants to merge 2 commits into
OpenAPITools:masterfrom
manduinca:fix/python-31-untyped-map-property
Open

manduinca wants to merge 2 commits into
OpenAPITools:masterfrom
manduinca:fix/python-31-untyped-map-property

Conversation

@manduinca

@manduinca manduinca commented Oct 1, 2026 •

Copy link
Copy Markdown

Fixes #25054

In an OpenAPI 3.1 spec, a property with additionalProperties and no type is an AnyType schema, so setTypeProperties marks it isAnyType and never isMap. fromProperty still sends it through updatePropertyForAnyType → updatePropertyForMap, which sets isContainer and containerType = "map" but leaves isMap false. The python from_dict template only has isArray and isMap branches inside isContainer, so the field matches neither and is dropped, which is the map=None from the issue. Serialization works because to_dict doesn't need the flag.

updatePropertyForMap now also sets isMap, the same way updateParameterForMap already does for parameters, so a property that is a map container is always flagged as one. For a schema that already had type: object this changes nothing, since isMap was already true. The new case is an untyped schema with additionalProperties (3.1 here, or an untyped composed schema with additionalProperties), which now carries isMap together with isAnyType in every generator, not only python.

Tests:

  • DefaultCodegenTest#testUntypedMapPropertyIsMap: untyped, typed and $ref-valued map properties all come out with isMap. The untyped ones fail on master.
  • PythonClientCodegenTest#testUntypedMapPropertyIsDeserialized: the generated from_dict reads map, typedMap and modelMap. Fails on master.
  • Both use the new src/test/resources/3_1/issue_25054.yaml.

mvn test on modules/openapi-generator passes (5270 tests). ./bin/generate-samples.sh ./bin/configs/*.yaml (814 generators) and ./bin/utils/export_docs_generators.sh produce no changes, so no sample in the repo depends on the old behaviour.

cc Python technical committee: @cbornet @tomplus @krjakbrjak @fa0311

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

updatePropertyForMap now sets isMap, matching what updateParameterForMap already does, so OpenAPI 3.1 properties with only additionalProperties are flagged as maps.

This fixes the Python client dropping such fields in from_dict, since the template only handles isArray and isMap inside isContainer. Typed object map properties are unaffected.

Tests:

  • DefaultCodegenTest#testUntypedMapPropertyIsMap: untyped, typed and $ref-valued map properties all come out with isMap and containerType = "map"; the untyped ones fail on master.
  • PythonClientCodegenTest#testUntypedMapPropertyIsDeserialized: the generated from_dict reads map, typedMap and modelMap as Dict[str, ...]; fails on master.
  • Both use the new src/test/resources/3_1/issue_25054.yaml.

Written for commit 7842096. Summary will update on new commits.

Review in cubic

An OpenAPI 3.1 property with additionalProperties and no type is an
AnyType schema, so setTypeProperties never marks it as a map. It still
goes through updatePropertyForMap, which makes it a map container
(containerType "map") but leaves isMap false. Templates that branch on
isMap then skip it: the python client serialized the field but dropped it
in from_dict.

Fixes OpenAPITools#25054

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][PYTHON] 3.1 property with additionalProperties without type isn't deserialized

1 participant