-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Open
Labels
Description
Description
When generating Elm code with a schema that has an array
property with items of type string
enum, the generated code is invalid. The encoder tries to encode the enum as an integer, which is incorrect. The function it tries to reference does not exist.
openapi-generator version
7.16.0
OpenAPI declaration file content or url
{
"openapi" : "3.0.1",
"info" : {
"title" : "OpenAPI definition",
"version" : "v0"
},
"servers" : [ {
"url" : "http://127.0.0.1:4000",
"description" : "Generated server url"
} ],
"paths": {},
"components" : {
"schemas" : {
"TestObject" : {
"type" : "object",
"properties" : {
"body" : {
"type" : "array",
"items": {
"type" : "string",
"enum" : [ "ENUM_FIRST", "ENUM_SECOND", "ENUM_THIRD" ]
}
}
}
}
}
}
}
Generation Details
npx @openapitools/openapi-generator-cli generate -i openapi.json -g elm -o elm
Steps to reproduce
Run the generated command, see that the generated file contains:
encodeTestObjectBody : TestObjectBody -> Json.Encode.Value
encodeTestObjectBody =
Json.Encode.int << intFromTestObjectBody
while it should be
encodeTestObjectBody : TestObjectBody -> Json.Encode.Value
encodeTestObjectBody =
Json.Encode.string << stringFromTestObjectBody
Suggest a fix
See above. Fix is to correctly interpret the enum as a string.