Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type toJsonSchema() does not include information about value defaults #1279

Open
fnimick opened this issue Jan 28, 2025 · 1 comment
Open
Assignees
Labels
confirmed The maintainers of the repo would like to address this enhancement New feature or request

Comments

@fnimick
Copy link
Contributor

fnimick commented Jan 28, 2025

Report a bug

🔎 Search Terms

jsonschema, json schema, default

🧩 Context

  System:
    OS: macOS 15.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 134.95 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.13.1 - ~/.asdf/installs/nodejs/20.13.1/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 10.5.2 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 9.7.0 - ~/.asdf/shims/pnpm
  npmPackages:
    arktype:  2.0.0 
    typescript: ^5.7.3 => 5.7.3 

🧑‍💻 Repro

let objWithDefault = type({nameWithDefault: 'string = "foo"'});
objWithDefault.toJsonSchema();
// { type: 'object', properties: { nameWithDefault: { type: 'string' } } }
// should resolve to:
// { type: 'object', properties: { nameWithDefault: { type: 'string', default: 'foo' } } }

This issue prevents Arktype defaults from working with sveltekit-superforms with the generated json schema, since superforms fills defaults based on the json schema provided by the validation adapter.

@fnimick fnimick added the bug Something isn't working label Jan 28, 2025
@github-project-automation github-project-automation bot moved this to To do in arktypeio Jan 28, 2025
@ssalbdivad ssalbdivad moved this from To do to Backlog in arktypeio Jan 28, 2025
@ssalbdivad ssalbdivad added confirmed The maintainers of the repo would like to address this enhancement New feature or request and removed bug Something isn't working labels Jan 28, 2025
@ssalbdivad
Copy link
Member

Yeah, currently only the concrete input type is included without metadata or format.

I will address this alongside some other upcoming changes to the API to make it more powerful and flexible (#1110, #1227)

@ssalbdivad ssalbdivad moved this from Backlog to In progress in arktypeio Feb 1, 2025
@ssalbdivad ssalbdivad moved this from In progress to Planned in arktypeio Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed The maintainers of the repo would like to address this enhancement New feature or request
Projects
Status: Planned
Development

No branches or pull requests

2 participants