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
Improve enum support as map keys by utilizing the newly added propertyNames JSON Schema in OpenAPI 3.1.
Background
There's a mismatch in support of enums as map keys between Smithy and OpenAPI. Currently when converting a smithy definition containing a map shape with an enum as key, the generated Open API spec discards all enum information and treats the map shape a simple string to object mapping.
Given this simple Smithy service:
$version: "2"
namespace enumkeys.example
use aws.protocols#restJson1
@restJson1
service ExampleService {
version: "1.0.0"
operations: [MajorCitiesByCountry]
}
@http(method: "GET", uri: "/cities", code: 200)
@readonly
operation MajorCitiesByCountry {
output : Response
}
enum Country {
UK = "UK"
FR = "FR"
US = "US"
DE = "DE"
}
string City
list Cities {
member: City
}
map CitiesByCountry {
key: Country
value: Cities
}
structure Response {
@required
majorCities: CitiesByCountry
}
the output open api spec looks like this (notice how the CitiesByCountry object has lost all traces of the enum and it's values):
Instead of discarding all enum information, we could leverage the newly added support for the propertyNames JSON Schema and output the CitiesByCountry object like this:
Thanks for opening this issue! We'd accept a change along these lines if you or your team is open to contributing it. For this specific feature, it should be gated by the OpenApiVersion.VERSION_3_1_0 configuration.
Improve enum support as map keys by utilizing the newly added
propertyNames
JSON Schema in OpenAPI 3.1.Background
There's a mismatch in support of enums as map keys between Smithy and OpenAPI. Currently when converting a smithy definition containing a map shape with an enum as key, the generated Open API spec discards all enum information and treats the map shape a simple string to object mapping.
Given this simple Smithy service:
the output open api spec looks like this (notice how the
CitiesByCountry
object has lost all traces of the enum and it's values):Suggested approach
Instead of discarding all enum information, we could leverage the newly added support for the
propertyNames
JSON Schema and output theCitiesByCountry
object like this:The text was updated successfully, but these errors were encountered: