[BUG] [elm] UUIDs in path parameters generate invalid code
Created by: mawis
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When the API contains a UUID that has to be inserted in the request path, openapi-generator-cli generates invalid elm code.
openapi-generator version
I'm using the version I just compiled from the master branch (commit 88e24900).
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: Bug demonstration API
description: |
This API is ment as a minimal example to show the problem openapi-generator
currently has with UUID fields when generating code for elm.
version: 0.1.0
servers:
- url: /demo
paths:
/demo/{id}:
get:
tags:
- Demo
description: Demonstration for the UUID serialization problem
parameters:
- name: id
in: path
description: some path parameter
required: true
schema:
type: string
format: uuid
responses:
204:
description: we don't care about the response in this example
content: {}
Generation Details
I generate the elm binding using the following code on the command line:
java -jar ~/source/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i demo.yaml -g elm -o output
Steps to reproduce
- Store the API definition from above in a file named
demo.yml
- Run the above mentioned command line
- Check the file
output/src/Api/Request/Demo.elm
The generated code reads:
{-
Bug demonstration API
This API is ment as a minimal example to show the problem openapi-generator currently has with UUID fields when generating code for elm.
The version of the OpenAPI document: 0.1.0
NOTE: This file is auto generated by the openapi-generator.
https://github.com/openapitools/openapi-generator.git
DO NOT EDIT THIS FILE MANUALLY.
For more info on generating Elm code, see https://eriktim.github.io/openapi-elm/
-}
module Api.Request.Demo exposing
( demoIdGet
)
import Api
import Api.Data
import Dict
import Http
import Json.Decode
import Json.Encode
import Uuid exposing (Uuid)
{-| Demonstration for the UUID serialization problem
-}
demoIdGet : Uuid -> Api.Request ()
demoIdGet id_path =
Api.request
"GET"
"/demo/{id}"
[ ( "id", identityUuid.toString id_path ) ]
[]
[]
Nothing
(Json.Decode.succeed ())
The problem here is the following line:
[ ( "id", identityUuid.toString id_path ) ]
identityUuid
is no function that exists in elm. The line should actually read like this (i.e. the identity
shouldn't be there):
[ ( "id", Uuid.toString id_path ) ]
Suggest a fix
I have fixed this locally and will open a pull request with the fix next.