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
Missing '"nullable": true' in resulting jsonschema #419
Comments
Came here for exactly that. Some more of my context. I've defined a type: type A = string | null I know that when I set So, I have no idea who is right on this one :D |
In my case, I'm using the programmatic version. For: When I execute: I get: It should be |
I have the same exact problem as described by @frontendphil |
I have same question about #419 (comment). |
You can manage it using validationKeywords option. await TJS.exec(`${projectFolder}/tsconfig.json`, "*", {
...TJS.getDefaultArgs(),
required: true,
noExtraProps: true,
defaultNumberType: "integer",
include: ["**/*.dto.ts"],
validationKeywords: ["example", "nullable"],
out,
}); I get in my output : "title": {
"description": "title of the item.",
"example": "'My title'",
"nullable": true,
"type": "string"
}, |
This works, but it is |
This is apparently needed for TypeScript to know anything at all about `| null`, so that typescript-json-schema can pick that up and add it to the right place in the generated schemas. See also: YousefED/typescript-json-schema#419 Test Plan: Looked at generated output, seems reasonable. Tests pass. Reviewers: jozef-mokry, km-nur, flooey Reviewed By: flooey Pull Request: getcord/monorepo#4998 monorepo-commit: a50605311aba8e93c1abb8174b6e378b71f9bddf
Ran into this issue as well - we had a project that couldn't have strict mode on; Adding the work around that worked for us: The strictNullChecks option isn't respected unless you also have "strict: true" set in your tsconfig also. If you can not have "strict: true" set in your tsconfig (or on by default) you can force the null value to show in the schema by adding the @nullable annotation to your property:
produces:
|
I 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:
In my mind, the result is missing below on property brokerTradeId
What am I doing wrong?
The text was updated successfully, but these errors were encountered: