-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Labels
Milestone
Description
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-SNAPSHOTImage 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: stringInvalid 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-STca4PUI5TSteps 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