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
  • #2759
Closed
Open
Issue created Apr 29, 2019 by Administrator@rootContributor3 of 6 checklist items completed3/6 checklist items

[BUG] [Elm] elmPrefixCustomTypeVariants

Created by: andys8

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description
    "Answers": {
      "type": "object",
      "required": [
        "houseLiving",
        "liabilityLegalProtection",
        "pets"
      ],
      "properties": {
        "houseLiving": {
          "type": "string",
          "enum": [
            "RENTED",
            "OWN_HOUSE",
            "OWN_FLAT",
            "PARENTS_HOUSE",
            "SHARED_FLAT",
            "RENT_FREE"
          ]
        },
        "liabilityLegalProtection": {
          "type": "array",
          "items": { "type": "string", "enum": ["BUILDER", "LANDLORD"] }
        },
        "pets": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["DOG", "CAT", "HORSE", "AQUARIUM"]
          }
        }
      },
      "title": "Answers"
    }
type HouseLiving
    = HouseLivingRENTED
    | HouseLivingOWNHOUSE
    | HouseLivingOWNFLAT
    | HouseLivingPARENTSHOUSE
    | HouseLivingSHAREDFLAT
    | HouseLivingRENTFREE


type LiabilityLegalProtection
    = LiabilityLegalProtectionLiabilityLegalProtectionLiabilityLegalProtectionLiabilityLegalProtectionBUILDER
    | LiabilityLegalProtectionLiabilityLegalProtectionLiabilityLegalProtectionLiabilityLegalProtectionLANDLORD

type Pets
    = PetsPetsPetsPetsDOG
    | PetsPetsPetsPetsCAT
    | PetsPetsPetsPetsHORSE
    | PetsPetsPetsPetsAQUARIUM

The actual output for LiabilityLegalProtection and Pets should only add the prefix a single time.

openapi-generator version

v4.0.0-beta3

Command line used for generation
    docker run --rm \
                -v "$PWD:/local" \
                openapitools/openapi-generator-cli:${OPEN_API_VERSION} generate \
                    -i /local/swagger.json \
                    -o "/local/$SDK_DIR/$generator" \
                    -g "$generator" \
                    --invoker-package "crm" \
                    --additional-properties elmEnableCustomBasePaths=true \
                    --additional-properties elmPrefixCustomTypeVariants=true
Suggest a fix

https://github.com/OpenAPITools/openapi-generator/blob/69ad9a9957fc0dca9dbd792cb9a6a3b6f5bf197c/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java#L696-L698

A fix would be to check if the prefix is already part of the value. This will work, but will not remove the root cause. It seems that certain cases leed to concatenating the prefix 4 times. In other cases it's working fine.

@eriktim What do you think?

Assignee
Assign to
Time tracking