Why ArkType when providing JSON Schema returns nulls as "{"const": null}"?
Hi,
I want to generate OpenApi 3.0 from Arktype schema, in order to do so, first step in the pipeline is to convert to json schema using built-in
toJSONSchema
. Problem being that mentioned built-in function returns nulls
from schema in a bit weird format with "const: null" and for example further when I'm using tools to generate openapi it just doesn't work correctly. That wouldn't be that big of a deal if not for types generation from openapi, where all those nulls
are treaded as unknowns
. I've tested both @hey-api/openapi-ts
and openapi-typescript
to generate types and both don't recognize it as null
. For converting from json-schema to openapi I'm using openapi-json-schema
. I would be very thanful if you could help me resolve that.3 Replies
I'm actually working on just this kind of thing now:
https://github.com/orgs/arktypeio/projects/4/views/1
So
type: "null"
is the more standard form I guess? interesting. const: null
is the more natural representation IMO- why create a type category when you already have it as a single value?
I will adjust the default there to match what you describe.
Let me know if you run into any other inconsistencies that aren't already logged as issues there.Thank you very much 😄
This is addressed in
2.1.19