microsoft / microsoft/typespec
JsonPatch - Support dependency types that are not dynamic
Open
emitter:client:csharp
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
If a dynamic model has a property that is a type from a different library which does not contain the JsonPatch property we need to do the following in the serialization code:
```C#
if (Optional.IsDefined(Foo) && !Patch.Contains("$.foo"u8))
{
ReadOnlyMemory rom = ModelReaderWriter.Write(Foo, options).ToMemory();
JsonPatch jp = new(rom);
Patch.ApplyTo(jp, "$.foo"u8);
jp.WriteTo(writer);
}
```
Similarly, for deserializing, the container JsonPatch would need to apply any properties that are not represented by Foo and use a prepended prefix so that the path is still correct.
Contributor guide
Assessment
This issue has not been assessed yet.