Skip to content

Infinite <<loop>> when using named fields #211

@paulyoung

Description

@paulyoung

This data type:

data Foo
  = Bar Foo
  | Baz Foo
  deriving (Generic, ToJSON, ToSchema)

Produces this JSON:

{
  "swagger": "2.0",
  "info": {
    "version": "",
    "title": ""
  },
  "definitions": {
    "Foo": {
      "minProperties": 1,
      "maxProperties": 1,
      "type": "object",
      "properties": {
        "Baz": {
          "$ref": "#/definitions/Foo"
        },
        "Bar": {
          "$ref": "#/definitions/Foo"
        }
      }
    }
  },
  "paths": {}
}

However, if I attempt to name the field like this:

data Foo
  = Bar { _1 :: Foo }
  | Baz { _2 :: Foo }
  deriving (Generic, ToJSON, ToSchema)

I get:

<<loop>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions