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
  • #1140
Closed
Open
Issue created Sep 28, 2018 by Administrator@rootContributor

[elm] failed to generate map from object with additionalProperties

Created by: mxinden

Description

I am trying to generate an elm client based on an OpenAPI spec (see below). The spec contains a map (labelSet) represented as an object with the additionalProperties field and no properties field like described in the swagger docs.

Generating the client with the command mentioned below generates an invalid LabelSet.elm file.

openapi-generator version
$ docker run openapitools/openapi-generator-cli:latest version

3.3.0-SNAPSHOT

Image ID: acde33bd7281

OpenAPI declaration file content or url
---

swagger: '2.0'

info:
  version: 0.0.1
  title: Alertmanager API
  description: API of the Prometheus Alertmanager (https://github.com/prometheus/alertmanager)
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html

consumes:
  - "application/json"
produces:
  - "application/json"

paths:
  /alerts:
    get:
      operationId: xxx
      description: xxx
      parameters:
      responses:
        '200':
          description: xxx
          schema:
            type: array
            items:
              '$ref': '#/definitions/alert'
definitions:
  alert:
    type: object
    properties:
      labels:
        $ref: '#/definitions/labelSet'
  labelSet:
    type: object
    additionalProperties:
      type: string
Invalid output file

LabelSet.elm:

{-
   Alertmanager API
   API of the Prometheus Alertmanager (https://github.com/prometheus/alertmanager)

   OpenAPI spec version: 0.0.1

   NOTE: This file is auto generated by the openapi-generator.
   https://github.com/openapitools/openapi-generator.git
   Do not edit this file manually.
-}


module Data.LabelSet exposing (LabelSet, labelSetDecoder, labelSetEncoder)

import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (optional, required)
import Json.Encode as Encode
import Maybe exposing (map, withDefault)


type alias LabelSet =
    {     }


labelSetDecoder : Decoder LabelSet
labelSetDecoder =
    Decode.succeed LabelSet



labelSetEncoder : LabelSet -> Encode.Value
labelSetEncoder model =
    Encode.object
        ]
Command line used for generation

docker run --user=1000:1000 --rm -v /home/mxinden/go/src/github.com/prometheus/alertmanager/ui/app/../..:/local openapitools/openapi-generator-cli:latest generate \                                                                                                             
        -i /local/api/v2/openapi.yaml\
        -g elm \
        --version \
        -o /local/ui/app/./openapi-STca4PUI5T
Steps to reproduce

Running elm format on the above LabelSet.elm file results in:

-- SYNTAX PROBLEM ---------------------------------------- src/Data/LabelSet.elm

I ran into something unexpected when parsing your code!

34elm-format: <stderr>: hPutChar: invalid argument (invalid character)
make: *** [Makefile:24: format] Error 1
Assignee
Assign to
Time tracking