Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #12504
Closed
Open
Issue created Jun 01, 2022 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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.

Assignee
Assign to
Time tracking