Skip to content

[Suggestion, Feature Request] precise definitions of additionalProperties key and value types #2241

@atothek1

Description

@atothek1

To enable a precise definition for additional properties especially for automated processing of API contract, like code generation I suggest the following new keyword in addition of the type property to define the key type and the value type.

keyOf:

  • can be of any valid scalar type provided by the OpenAPI specs
  • can be a reference to an enum definition
MyKeyEnum:
  type: string
  enum:
    - A
    - B
    - C
MyDictionary:
  type: object
  additionalProperties:
    keyOf:
      - $ref: '#/components/schemas/MyKeyEnum'
    type: string

or with multiple value types allowed

MyKeyEnum:
  type: string
  enum:
    - A
    - B
    - C
MyDictionary:
  type: object
  additionalProperties:
    keyOf:
      - $ref: '#/components/schemas/MyKeyEnum'
    anyOf:
      - type: string
      - type: integer

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