Repository navigation
The derived properties are included to the data schema. - #442
Conversation
|
I propose to not merge it since we shall be able to ignore derived properties (#429 (comment)) |
samatstariongroup
left a comment
There was a problem hiding this comment.
Verified locally at a8931bf: build clean, full test suite green. The merge endpoint is the only request body typed as an array of Data in the OpenAPI document, and the changed overload has a single caller (MergeAsync), so commit payloads are unaffected. The new assertions fail on the previous code.
samatstariongroup
left a comment
There was a problem hiding this comment.
lets wait with merging
antoineatsoprasteria
left a comment
There was a problem hiding this comment.
Additional point + inline comment ;:
-
One flag covers two different choices (SySML2.NET.REST/PsmApiClientOptions.cs). IncludeDerivedProperties controls both what we put in request bodies and the Prefer: include-derived header, which asks the server to compute derived properties in its responses. These are separate choices. A client may have to send full Data to a strict server without wanting every response to carry derived properties, and today it can't make that distinction. The same switch also adds derived properties to commit payloads, where the schema leaves them optional. I'd split it into two options: one for serializing derived properties in request bodies, and one for asking for them in responses.
The response side isn't wired up yet either. ReadDataAsync and ReadPagedDataAsync still deserialize with deserializeDerivedProperties: false, so whatever the server sends back for the preference is dropped. I'd let the server confirm it: when it honours the preference, it returns Preference-Applied: include-derived (RFC 7240) along with Vary: Prefer. The client then deserializes derived properties only when that header is present. That way a DTO never shows empty derived properties as if they were real values when the server simply ignored the request. A test should cover both cases: with the header the derived properties are filled in, and without it they stay unset.
-
The doc comment is wrong under the default settings (SySML2.NET.REST/PsmApiClient.cs). CreateContentAsync(IEnumerable, …) now says each item is "written as a full Data including its derived properties". With default options it does the opposite. The comment should state that this depends on the option, or drop the claim.
-
Pass the client options when the session is opened, not when it's constructed (SySML2.NET.REST/Session.cs). The settings depend on the server being targeted, and that's chosen in Open, which already creates a new PsmApiClient each time. Taking PsmApiClientOptions in Open (an overload of ISession.Open, so existing callers keep compiling) ties the options to the opened connection. A session can then be re-opened against another server with different options, and the constructor keeps taking only injected services.
-
The PR description overstates the fix. It says derived properties "are now included" in the merge body. They are only included when a caller opts in. With the defaults, MergeAsync still sends a body that fails the Data schema. The description should say the behaviour is opt-in, and #429 should be closed on that basis.
| /// <summary> | ||
| /// The RFC 7240 preference asking the server to include the derived properties in its responses | ||
| /// </summary> | ||
| private const string IncludeDerivedPreference = "include-derived"; |
There was a problem hiding this comment.
Move this constant and the "Prefer" into a dedicated static class into the SysML2.NET project so any backend implementation share identical constant
b7408cc to
8de302f
Compare
There was a problem hiding this comment.
It still hard-code "false"
There was a problem hiding this comment.
It still hard-code "false"
|



Prerequisites
Description
Fix #429 the derived properties is now included into resolution elements send by MergeAsync.