You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
This has the same effective behavior as your proposal when patternProperties and properties are not present, but slightly different behavior if they are present (because they affect additionalProperties and not propertyNames. However, that can usually be worked around. And mostly propertyNames + additionalProperties are used when properties and patternProperties are not being used, because those other keywords already constrain the names.
OAS 3.1 (out soon!) will include full compatibility with the most recent JSON Schema draft, so this will be addressed automatically in that release.
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:
or with multiple value types allowed
The text was updated successfully, but these errors were encountered: