Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openapi 3.1 - add support for defining schema type as a list #5011

Open
chrisradek opened this issue Nov 7, 2024 · 0 comments
Open

openapi 3.1 - add support for defining schema type as a list #5011

chrisradek opened this issue Nov 7, 2024 · 0 comments
Labels
emitter:openapi3 Issues for @typespec/openapi3 emitter

Comments

@chrisradek
Copy link
Member

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
    - number
  enum:
    - dog
    - 1
@chrisradek chrisradek added the emitter:openapi3 Issues for @typespec/openapi3 emitter label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:openapi3 Issues for @typespec/openapi3 emitter
Projects
None yet
Development

No branches or pull requests

1 participant