microsoft / typespec

https://typespec.io/
MIT License
3.92k stars 176 forks source link

Should typespec error if a model used for merge patch includes a nullable property #2875

Open m-nash opened 5 months ago

m-nash commented 5 months ago

In the below scenario since the model is used for merge patch it should include null in the possible range of values for any of its properties.

model Foo {
  name?: string
  description?: string | null
}

op Update(@header content-type: "application/merge-patch+json", ...Foo) : void
bterlson commented 5 months ago

I believe you mean should not include null? E.g. that you have an example of an error case, here? If so, I agree, although I could imagine ignoring/suppressing the error if you don't particularly care that you can't update a field's value to null for whatever reason.

markcowl commented 5 months ago
markcowl commented 5 months ago

est: 3