quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

[BUG]: Error generating lottie scheme code

Open EduardoPadilha opened this issue 1 year ago • 2 comments

Issue Type

When trying to generate code from a schema I get an error

Context (Environment, Version, Language)

Input Format: json schema Output Language: C#

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

Description

I'm trying to generate a c# class from the schema provided by lottie at https://lottiefiles.github.io/lottie-docs/schema/lottie.schema.json. I copy the raw into a utf-8 file and submit it to the CLI command or copy it directly from the link and paste it into the website https://app.quicktype.io/

Input Data

I think it is too big to isolate into something smaller and understandable, I will leave again the link of the schema provided: https://lottiefiles.github.io/lottie-docs/schema/lottie.schema.json

Expected Behaviour / Output

Generate schema classes

Current Behaviour / Output

Nothing appears on the website and the CLI returns the message: "Error: s.codePointAt is not a function."

Steps to Reproduce

  1. Download the json schema from the above link
  2. Save it in a local file with the name "lottie.schema.json"
  3. Run the following command "quicktype -s schema lottie.schema.json -o src/Models.cs" in the same directory

EduardoPadilha avatar Sep 27 '24 15:09 EduardoPadilha

I've replicated this issue as well. I've found it comes down to this culprit, a property with the following type:

    oneOf:
        - const: 0
          title: CONST_ZERO
        - const: 1
          title: CONST_ONE
        - const: 2
          title: CONST_TWO

It seems the system has issues with generating int-based enums? I'm trying it with the Python generator at the moment.

iconmaster5326 avatar Aug 27 '25 16:08 iconmaster5326

Here's where this bug triggers from the Lottie JSON schema from above:

                "oneOf": [
                    {
                        "title": "True",
                        "const": 1
                    },
                    {
                        "title": "False",
                        "const": 0
                    }
                ]

iconmaster5326 avatar Aug 27 '25 16:08 iconmaster5326