Skip to content

fix(json-schema): spread enums before passing into type.enumerated#1566

Merged
ssalbdivad merged 8 commits intoarktypeio:mainfrom
chris-kreidl:spread-enums
Dec 21, 2025
Merged

fix(json-schema): spread enums before passing into type.enumerated#1566
ssalbdivad merged 8 commits intoarktypeio:mainfrom
chris-kreidl:spread-enums

Conversation

@chris-kreidl
Copy link
Contributor

This PR aims to fix a bug in json-schema in which JSON Schemas that contained type and enum incorrectly threw an error.

Example JSON Schema:

const schema = {
    type: "object",
    properties: {
      status: {
        type: "string",
        enum: ["PENDING", "COMPLETE"]
      }
    }
  };

Should pass and result in a type('"PENDING" | "COMPLETE"'), but rather errored.

The cause was passing the enum array as an array to type.enumerated, rather than spreading it.

This PR patches parseCommonJsonSchema to spread the enum and adds a test case to verify the fix.

  • Code is up-to-date with the main branch
  • You've successfully run pnpm prChecks locally
  • There are new or updated unit tests validating the change

@chris-kreidl
Copy link
Contributor Author

ffs. i really need to learn more about using git in a multi-author/branch/fork environment. i did not mean for 48fcc90 and 0910220 to work their way into this PR.

Copy link
Member

@ssalbdivad ssalbdivad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries on the git issues, I screw that stuff up constantly. Thanks!

@ssalbdivad ssalbdivad merged commit ed541c4 into arktypeio:main Dec 21, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from To do to Done (merged or closed) in arktypeio Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done (merged or closed)

Development

Successfully merging this pull request may close these issues.

2 participants