Skip to content

The derived properties are included to the data schema. - #442

Merged
zeynepatsoprasteria merged 4 commits into
developmentfrom
429-mergeasync-sends-resolution-elements-without-the-derived-properties-the-data-schema-requires
Dec 1, 2026
Merged

zeynepatsoprasteria merged 4 commits into
developmentfrom
429-mergeasync-sends-resolution-elements-without-the-derived-properties-the-data-schema-requires

Conversation

@zeynepatsoprasteria

Copy link
Copy Markdown

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the SysML2.NET code style guidelines
  • I have provided test coverage for my change (where applicable)

Description

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

@antoineatsoprasteria

Copy link
Copy Markdown
Collaborator

I propose to not merge it since we shall be able to ignore derived properties (#429 (comment))

@samatstariongroup samatstariongroup left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 samatstariongroup left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets wait with merging

@antoineatsoprasteria antoineatsoprasteria left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional point + inline comment ;:

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Comment thread SySML2.NET.REST/PsmApiClient.cs Outdated
/// <summary>
/// The RFC 7240 preference asking the server to include the derived properties in its responses
/// </summary>
private const string IncludeDerivedPreference = "include-derived";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this constant and the "Prefer" into a dedicated static class into the SysML2.NET project so any backend implementation share identical constant

@zeynepatsoprasteria
zeynepatsoprasteria force-pushed the 429-mergeasync-sends-resolution-elements-without-the-derived-properties-the-data-schema-requires branch from b7408cc to 8de302f Compare November 30, 2026 15:01
Comment thread SySML2.NET.REST/PsmApiClient.cs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still hard-code "false"

Comment thread SySML2.NET.REST/PsmApiClient.cs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still hard-code "false"

@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@zeynepatsoprasteria
zeynepatsoprasteria merged commit 1631945 into development Dec 1, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MergeAsync sends resolution elements without the derived properties the Data schema requires

3 participants