[BUG] 5.0 produces invalid Elm code with missing decoders/encoders for custom types
Created by: SiriusStarr
In the petstore example, it looks like custom types's don't have their encoders/decoders properly written:
orderDecoder : Json.Decode.Decoder Order_
orderDecoder =
Json.Decode.succeed Order_
|> maybeDecode "id" Json.Decode.int Nothing
|> maybeDecode "petId" Json.Decode.int Nothing
|> maybeDecode "quantity" Json.Decode.int Nothing
|> maybeDecode "shipDate" Api.Time.dateTimeDecoder Nothing
|> maybeDecode "status" <!!orderStatusDecoder should be here!!> Nothing
|> maybeDecode "complete" Json.Decode.bool (Just False)
encodeOrderPairs : Order_ -> List EncodedField
encodeOrderPairs model =
let
pairs =
[ maybeEncode "id" Json.Encode.int model.id
, maybeEncode "petId" Json.Encode.int model.petId
, maybeEncode "quantity" Json.Encode.int model.quantity
, maybeEncode "shipDate" Api.Time.encodeDateTime model.shipDate
, maybeEncode "status" <!!encodeOrderStatus should be here!!> model.status
, maybeEncode "complete" Json.Encode.bool model.complete
]
in
pairs
Additionally, there is an erroneous DEcoder in the middle of one of the ENcoders. fixed in master
This is the full diff between the output of 04dfff83 and a manually corrected version:
diff -r elm-openapi-test/src/Api/Data.elm elm-openapi-test-fix/src/Api/Data.elm
202c202
< , maybeEncode "status" model.status
---
> , maybeEncode "status" encodeOrderStatus model.status
246c246
< , maybeEncode "status" model.status
---
> , maybeEncode "status" encodePetStatus model.status
343c343
< |> maybeDecode "status" Nothing
---
> |> maybeDecode "status" orderStatusDecoder Nothing
376c376
< |> maybeDecode "status" Nothing
---
> |> maybeDecode "status" petStatusDecoder Nothing
Originally posted by @SiriusStarr in https://github.com/OpenAPITools/openapi-generator/issues/8218#issuecomment-747686514