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