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
In Open API 3.0, the Open API schema type field could only be a single string value.
In Open API 3.1, the Open API schema type field can be an array of string values.
This is especially useful when defining enums that are backed by multiple types.
Take the following TypeSpec example:
enum PetType { asString: "dog", asNumber: 1}
Our Open API 3.0 emitter will emit an error because enum can be a number or a string, but Open API schemas only support a single type. (Side note: could we support this via anyOf with multiple enum subschemas for Open API 3.0?)
With Open API 3.1, we could emit this valid schema (which our Json Schema emitter already does):
PetType:
type:
- string
- numberenum:
- dog
- 1
The text was updated successfully, but these errors were encountered:
In Open API 3.0, the Open API schema
type
field could only be a single string value.In Open API 3.1, the Open API schema
type
field can be an array of string values.This is especially useful when defining enums that are backed by multiple types.
Take the following TypeSpec example:
Our Open API 3.0 emitter will emit an error because enum can be a number or a string, but Open API schemas only support a single type. (Side note: could we support this via
anyOf
with multiple enum subschemas for Open API 3.0?)With Open API 3.1, we could emit this valid schema (which our Json Schema emitter already does):
The text was updated successfully, but these errors were encountered: