Missing '"nullable": true' in resulting jsonschema
See original GitHub issueI am using https://www.graphql-code-generator.com/ to generate types from graphql schemas. I am generating json schemas from those types, but fields that are nullable does not come out as nullable.
test.ts:
export type Maybe<T> = T | null;
export type Scalars = {
String: string;
};
export type CreateTransactionInput = {
readonly brokerTradeId?: Maybe<Scalars["String"]>;
};
> npx typescript-json-schema --noExtraProps test.ts CreateTransactionInput
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"brokerTradeId": {
"type": "string"
}
},
"type": "object"
}
In my mind, the result is missing below on property brokerTradeId
"nullable": true,
What am I doing wrong?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:5
Top Results From Across the Web
Ruby JSON Schema Validator Not Returning Expected Result
I am using the JSON schema validator gem to verify a response is coming back ... An expected True result would have the...
Read more >Solved: Parse JSON - validation failed for null values - h...
I am attempting to parse the JSON, which mostly works... except when null values ... Then I created the JSON Schema by pasting...
Read more >Notes about json schema handling in Spark SQL - Medium
The nullability of inferred fields will always be True even in case where the column has no null values. If you set the...
Read more >Understanding JSON Schema
string: "This is a string". • boolean: true false. • null: ... Missing the required “email” property makes the JSON document invalid:.
Read more >How to allow None (null) for fields in JSON Schema?
this is probably a little late but for consistency. I think you have a typo in your last schema. Instead of just `null`...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Came here for exactly that.
Some more of my context. I’ve defined a type:
I know that when I set
--strictNullCheck
I get atype: ['string', 'null']
in the resulting schema. However, the typescript support ofajv
complains that this is not valid JSON schema syntax and that the property should rather havenullable: true
set.So, I have no idea who is right on this one 😄
I have the same exact problem as described by @frontendphil Did you manage to resolve this issue somehow?