You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make toJsonSchema method compatible with OpenAPI spec / @fastify/swagger for enums / unions #1328
Make output of toJsonSchema method on enums/unions compatible with OpenAPI spec and make the output look the same to other popular tools like zod-to-json-schema for zod.
🤷 Motivation
Make it easier to use arktype as a validator in fastify or other backend frameworks for documentation.
I am trying to migrate from zod as a validator for my API written in fastify. Everything expect swagger is working properly but since the json schema generated for enums/unions is different between zod/typebox and arktype I couldn't get enums to work properly on swagger.
💡 Solution
Change how we generate JSON schema for enums/unions in arktype to match other popular tools.
💡 Code
This repo contains an example of not working path parameters enums for v param - for zod v is 0 | 1 but for arktype it's only 0 -> the enum is displayed properly.
I tried both literal string union "'0' | '1'" and type.enumerated and the output was the same.
This issue tho might be not fully related to arktype becuase the generated JSON schema is totally valid it just doesn't work well with open api spec or @fastify/swagger itself but it's a big blocker when it comes to migration as the documentation is a really important part and currently there are no other libraries than @fastify/swagger for fastify ecosystem.
Reacted by Misha Kaletsky, blagodus, Lucas Cândido and floratmin
Activity
ssalbdivad commentedon Apr 7, 2025
Fixed in
2.1.19🎉