[BUG] [Elm] Uuid import and encoding missing
Created by: andys8
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
If a path variable is of type Uuid
, the import and the encoding is missing.
Output (without comment):
module Request.UserController exposing (get)
import Data.User as User exposing (User)
import Dict
import Http
import Json.Decode as Decode
import Url.Builder as Url
get :
{ onSend : Result Http.Error User -> msg
, basePath : String
, userId : Uuid
}
-> Cmd msg
get params =
Http.request
{ method = "GET"
, headers = []
, url =
Url.crossOrigin params.basePath
[ "users", params.userId ]
[]
, body = Http.emptyBody
, expect = Http.expectJson params.onSend User.decoder
, timeout = Just 30000
, tracker = Nothing
}
openapi-generator version
v4.0.0-beta2
OpenAPI declaration file content or url
"/users/{userId}": {
"get": {
"tags": ["user-controller"],
"summary": "get",
"operationId": "get",
"parameters": [
{
"name": "userId",
"in": "path",
"description": "userId",
"required": true,
"type": "string",
"format": "uuid"
}
],
"responses": {
"200": {
"description": "OK",
"schema": { "$ref": "#/definitions/User" }
},
"401": { "description": "Unauthorized" },
"403": { "description": "Forbidden" },
"404": { "description": "Not Found" }
},
"deprecated": false
}
}
Command line used for generation
docker run --rm -v /server-sdk:/local openapitools/openapi-generator-cli:v4.0.0-beta2 generate -i /local/swagger.json -o /local/sdk/elm -g elm --invoker-package abc --additional-properties elmEnableCustomBasePaths=true
Steps to reproduce
Build and look into output in Request files.
Related issues/PRs
This PR introduced UUIDs. https://github.com/OpenAPITools/openapi-generator/pull/1516
Suggest a fix
- add import
- uuid to string with prm
This is what the output should look like (without comment)
module Request.UserController exposing (get)
-- CHANGED: Uuid import added manually
import Data.User as User exposing (User)
import Dict
import Http
import Json.Decode as Decode
import Url.Builder as Url
import Uuid exposing (Uuid)
get :
{ onSend : Result Http.Error User -> msg
, basePath : String
, userId : Uuid
}
-> Cmd msg
get params =
Http.request
{ method = "GET"
, headers = []
, url =
Url.crossOrigin params.basePath
[ "users"
, -- CHANGED: UUID.toString added manually
Uuid.toString params.userId
]
[]
, body = Http.emptyBody
, expect = Http.expectJson params.onSend User.decoder
, timeout = Just 30000
, tracker = Nothing
}