orval
orval copied to clipboard
Angular schema nullability definitions incorrectly done
I'm using orval 7.9.0 and I have the following component schema:
"components": {
"schemas": {
"TestDto":{
"type":"object",
"required":[
"Foo",
"Bar"
],
"properties":{
"Foo":{
"type":"string"
},
"Bar":{
"nullable":true,
"type":"string"
},
"Foobar":{
"nullable":true,
"type":"string"
}
}
}
}
}
and the generated model with angular client output is as such:
export interface TestDto {
Foo: string;
/** @nullable */
Bar: string;
/** @nullable */
Foobar?: string;
}
As you can see the Bar and Foobar properties both have the "nullable" comment (but Bar surprisingly isn't nullable nor optional at all) and Foobar is just an optional property.
If I generate with zod client output I get what I expected:
export interface TestDto {
Foo: string;
/** @nullable */
Bar: string | null;
/** @nullable */
Foobar?: string | null;
}
Is there any specific reason for why angular generation works this way or is it just a bug?
Probably just a bug in the angular client if you want to debug and submit a PR
Looks like the change in https://github.com/orval-labs/orval/pull/1200 is the root cause here. Removed the angular client check and now the models are correctly generated. I suspect a proper fix for this would be to generate non-nullable scalar values only for url params when generating angular code.
PR would be great!
PR is over here: https://github.com/orval-labs/orval/pull/2103
Let me know if anything else needs to be done, wasn't sure about the changelog part in the checklist.
@snebjorn here is another Angular one that got started with a PR but never finished if you want to look!