[BUG] [PYTHON] additionalProperties not supported
Created by: ivan-gomes
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
Generated Python clients do not have the ability to access the additional properties of models with additionalProperties
defined. The only ones that can be accessed are those that are explicitly defined in the model and the rest are ignored. In contrast, the generated Java models extend HashMap when additionalProperties
are defined and they can get accessed by Map#get(String).
openapi-generator version
4.0.0
OpenAPI declaration file content or url
Element:
type: "object"
required:
- "id"
properties:
id:
type: "string"
name:
type: "string"
additionalProperties:
type: "object"
Full specification: https://github.com/Open-MBEE/mms/blob/develop/mms-ent/repo-amp/src/main/amp/web/mms/mms.swagger.yaml
Command line used for generation
java -jar /path/to/openapi-generator-cli.jar generate -i /path/to/mms.swagger.yaml -l python -o ~/tmp
Steps to reproduce
Inspecting the generated Element.py
file after executing the command above with the specification above. There is also a usage of additionalProperties
in the Petstore API that exhibits the same behavior.
Related issues/PRs
Clone of issue made and fixed in swagger-api/swagger-codegen
: https://github.com/swagger-api/swagger-codegen/issues/8075
Suggest a fix
I believe that the additional properties can be stored in a dict, analogously to how they are handled in Java.