Created by: matsubara0507
cc @eriktim
Generate wrong Elm code when response schema is Map (Dict).
e.g. generate from
openapi: 3.0.1
info:
title: My title
description: API under test
version: 1.0.0
servers:
- url: https://localhost:9999/root
paths:
/dict1:
get:
responses:
'200':
description: 'return dictonary'
content:
application/json:
schema:
type: object
additionalProperties:
type: boolean
/dict2:
get:
responses:
'200':
description: 'return Object has dictionary'
content:
application/json:
schema:
$ref: '#/components/schemas/Hoge'
components:
schemas:
Hoge:
type: object
properties:
hoge:
type: object
additionalProperties:
type: boolean
to
dict1Get : Api.Request (Dict.Dict String Bool)
dict1Get =
Api.request
"GET"
"/dict1"
[]
[]
[]
Nothing
(Json.Decode.dict Api.Data.boolDecoder)
dict2Get : Api.Request Api.Data.Hoge
dict2Get =
Api.request
"GET"
"/dict2"
[]
[]
[]
Nothing
Api.Data.hogeDecoder
hogeDecoder : Json.Decode.Decoder Hoge
hogeDecoder =
Json.Decode.succeed Hoge
|> maybeDecode "hoge" (Json.Decode.dict Json.Decode.boolboolDecoder) Nothing
but expected
dict1Get : Api.Request (Dict.Dict String Bool)
dict1Get =
Api.request
"GET"
"/dict1"
[]
[]
[]
Nothing
(Json.Decode.dict Json.Decode.bool)
dict2Get : Api.Request Api.Data.Hoge
dict2Get =
Api.request
"GET"
"/dict2"
[]
[]
[]
Nothing
Api.Data.hogeDecoder
hogeDecoder : Json.Decode.Decoder Hoge
hogeDecoder =
Json.Decode.succeed Hoge
|> maybeDecode "hoge" (Json.Decode.dict Json.Decode.bool) Nothing
fix it
PR checklist
-
Read the contribution guidelines. -
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
Run the following to build the project and update samples: ./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh
./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH. -
File the PR against the correct branch: master
(5.3.0),6.0.x
-
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.