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
Today, if I use the following Smithy enum definition:
@documentation("The status of the enrollment request.")
enumEnrollmentStatus {
@documentation("The enrollment request is pending review.")
PENDING="PENDING",
@documentation("The enrollment request has been approved.")
APPROVED="APPROVED",
@documentation("The enrollment request has been rejected.")
REJECTED="REJECTED"
}
The following OpenAPI output will be produced, as can be seen below, the per item documentation lines are lost:
{
"EnrollmentStatus": {
"type": "string",
"description": "The status of the enrollment. Only Stedi can set or update this property.",
"enum": [
"PENDING",
"APPROVED",
"REJECTED"
]
}
}
Using OAS 3.1.x (and JSON Schema 2020-12) enums can be defined with oneOf along with const to allow documentation to included for each item, for example:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"status": {
"type": "string",
"description": "The status of the enrollment request.",
"oneOf": [
{
"const": "PENDING",
"description": "The enrollment request is pending."
},
{
"const": "APPROVED",
"description": "The enrollment request has been approved."
},
{
"const": "REJECTED",
"description": "The enrollment request has been rejected."
}
]
}
}
}
It would be great if we could have the same support in the openapi plugin.
The text was updated successfully, but these errors were encountered:
To help move this forward since it would be really useful for us:
One possible approach might be to handle this similarly to how unions and maps are configured in the OpenAPI plugin, with the unionStrategy and mapStrategy configuration settings. (Though maybe this would additionally need to be scoped to specific versions of JsonSchema and open-api?)
A potential solution could be:
A new configuration setting called enumStrategy that supports:
enum (current default behavior using simple array-formatted string enum)
oneOf (new behavior using oneOf with const values to preserve member docs)
It seems like at least the following would need to be updated (probably I am missing some other things):
Today, if I use the following Smithy enum definition:
The following OpenAPI output will be produced, as can be seen below, the per item documentation lines are lost:
Using OAS 3.1.x (and JSON Schema 2020-12) enums can be defined with
oneOf
along withconst
to allow documentation to included for each item, for example:It would be great if we could have the same support in the openapi plugin.
The text was updated successfully, but these errors were encountered: