Skip to content

Comments

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

Closed
chris-kreidl wants to merge 3 commits intoarktypeio:mainfrom
chris-kreidl:main
Closed

fix(json-schema): spread enums before passing into type.enumerated#1565
chris-kreidl wants to merge 3 commits intoarktypeio:mainfrom
chris-kreidl:main

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

@github-project-automation github-project-automation bot moved this from To do to Done (merged or closed) in arktypeio Dec 16, 2025
@chris-kreidl
Copy link
Contributor Author

I'm an idiot. I forgot to branch before working on each of these. Will follow up with clean PRs.

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.

1 participant