Skip to content

Support for additionalProperties and "free form" objects #218

Closed
@packyg

Description

@packyg

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

Our API contains some subresources that are not easily modeled in an OpenAPI spec. To get around this, we want to punt by modeling them as "free form" objects (an object with additionalProperties: true) and interacting with them as plain dicts instead of model classes.

Describe the solution you'd like

Support for the additionalProperties key, ideally in both use cases - specifying additional properties and specifying a freeform object

Additional properties:
MyModel:
  type: object
  properties:
    name:
      type: string
  additionalProperties:
    type: string

Should generate a model like

@attr.s(auto_attribs=True)
class MyModel:
  name: str
  additional_properties: Dict[str, str]
# ...
Free Form Object:
MyModel:
  type: object
  additionalProperties: true
@attr.s(auto_attribs=True)
class MyModel:
  additional_properties: Dict[str, Any]
# ...

Describe alternatives you've considered

Just using objects directly to declare these subresources instead of $refing a shared component schema to make it so the property gets generated as a plain dict.

Additional context

We do have a consistent model for the resource in question, just one that isn't easily modeled in OpenAPI. It's used as a property in several of our models so we would like to be able to indicate the relation by using a shared component schema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions