[elm] Process additionalProperties in parent alias when using composition (allOf)
Created by: mxinden
Description
This is a follow up to https://github.com/OpenAPITools/openapi-generator/issues/1140 and https://github.com/OpenAPITools/openapi-generator/pull/1262.
When I use the allOf keyword to compose GettableAlert
based on Alert
, the Annotation
is not defined as a Dict String String
but as a LabelSet
. But as discussed in https://github.com/OpenAPITools/openapi-generator/issues/1140 LabelSet
is not properly generated.
openapi-generator version
3.3.4-SNAPSHOT
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)
paths:
/alert:
get:
operationId: getAlert
description: Get an alert
parameters:
responses:
'200':
description: Get alerts response
schema:
'$ref': '#/definitions/alert'
definitions:
alert:
type: object
properties:
labels:
$ref: '#/definitions/labelSet'
required:
- labels
gettableAlert:
allOf:
- type: object
properties:
annotations:
$ref: '#/definitions/labelSet'
required:
- annotations
- $ref: '#/definitions/alert'
labelSet:
type: object
additionalProperties:
type: string
Command line used for generation
docker run --user=$(id -u ${USER}):$(id -g ${USER}) --rm -v ${PWD}:/local openapitools/openapi-generator-cli:latest generate -i /local/openapi.yaml -g elm -o /local/example
Steps to reproduce
Run above docker command with the above written OpenAPI specification. This results in:
{-
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.GettableAlert exposing (GettableAlert, decoder, encoder)
import Data.LabelSet as LabelSet exposing (LabelSet)
import Dict exposing (Dict)
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (optional, required)
import Json.Encode as Encode
type alias GettableAlert =
{ labels : Dict String String
-- I would expect `Dict String Strng` here as well.
, annotations : LabelSet
}
decoder : Decoder GettableAlert
decoder =
Decode.succeed GettableAlert
|> required "labels" (Decode.dict Decode.string)
|> required "annotations" LabelSet.decoder
encoder : GettableAlert -> Encode.Value
encoder model =
Encode.object
[ ( "labels", (Encode.dict identity Encode.string) model.labels )
, ( "annotations", LabelSet.encoder model.annotations )
]
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/1140 and https://github.com/OpenAPITools/openapi-generator/pull/1262