Skip to content

[REQ] [Python] improve additional_properties_type #5489

Description

@spacether

Is your feature request related to a problem? Please describe.

@sebastien-rosset did work that uncovered that additionalProperties: {}
should set additional property value data types to:
{str: (bool, date, datetime, dict, float, int, list, str)}
whereas python-experimental currently sets it to:
(bool, date, datetime, dict, float, int, list, str)

Describe the solution you'd like

For additionalProperties: {} or additionalProperties: True
change the type definition to:
additional_properties_type = ({str: (bool, date, datetime, dict, float, int, list, str)}, )

Also per spec version https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md and higher
additionalProperties accepts a boolean value and defaults to True if omitted.

For additionalProperties: False or null use
additional_properties_type = None

For an object with no definition except a description:
additional_properties_type = (bool, date, datetime, dict, float, int, list, str)

For an object with no definition except a description + nullable: True:
additional_properties_type = (bool, date, datetime, dict, float, int, list, str, none_type)

Related Issues/PRs

#5317 generation of composedSchemas with additionalProperties: True
#5387 describes how to handle nullable:True
#5316 comments added describing what booleans util functions return when additionalProperties is False/True/Schema
#5391 adds util function isAnyType adds sample spec example models

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions