Skip to content

Angular schema nullability definitions incorrectly done #2092

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

Open
jonimake opened this issue May 15, 2025 · 4 comments · May be fixed by #2103
Open

Angular schema nullability definitions incorrectly done #2092

jonimake opened this issue May 15, 2025 · 4 comments · May be fixed by #2103
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jonimake
Copy link

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?

@jonimake jonimake changed the title Angular model nullability definitions incorrectly done Angular schema nullability definitions incorrectly done May 15, 2025
@melloware
Copy link
Collaborator

Probably just a bug in the angular client if you want to debug and submit a PR

@melloware melloware added the bug Something isn't working label May 17, 2025
@jonimake
Copy link
Author

Looks like the change in #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.

@melloware
Copy link
Collaborator

PR would be great!

@jonimake jonimake linked a pull request May 20, 2025 that will close this issue
3 tasks
@jonimake
Copy link
Author

PR is over here: #2103

Let me know if anything else needs to be done, wasn't sure about the changelog part in the checklist.

@melloware melloware added this to the 7.10.0 milestone May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants