Skip to content

[BUG]: Forbidden identifiers too strict for Haskell enums #2868

@bchinn-arista

Description

@bchinn-arista

Issue Type

Quicktype output

Context (Environment, Version, Language)

Input Format: JSON Schema
Output Language: Haskell

CLI, npm, or app.quicktype.io: CLI and app.quicktype.io
Version:

Description

Error is marked as a forbidden global identifier, so enums named error are renamed to avoid clashing, but this is unnecessary for enums, which are already suffixed.

cc @algas

Input Data

{
  "id": "http://json-schema.org/geo",
  "$schema": "http://json-schema.org/draft-06/schema#",
  "description": "A geographical coordinate",
  "type": "string",
  "enum": ["ok", "error"]
}

Expected Behaviour / Output

data Health
    = ErrorHealth
    | OkHealth
    deriving (Show)

Current Behaviour / Output

data Health
    = HealthErrorHealth
    | OkHealth
    deriving (Show)

Steps to Reproduce

Possible Solution

  1. Aeson imports should be excluded from the forbidden list; the generator should import Data.Aeson qualified
  2. Forbidden identifiers should be renamed only when it exactly matches. If a suffix is being added, it should not be renamed

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions