Skip to content

[PYTHON] additionalProperties not supported #8075

@ivan-gomes

Description

@ivan-gomes
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).

Swagger-codegen version

2.3.1

Swagger 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 ~/Downloads/swagger-codegen-cli-2.3.1.jar generate -i ~/Documents/mms.swagger.yaml -l php -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

#6130

Suggest a fix/enhancement

I believe that the additional properties can be stored in a dict, analogously to how they are handled in Java.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions