We have written an XData server with a Service that doesn't use a database, so no Aurelius entities are defined.
We have classes defined which are inputs to functions on the Service, and others that are outputs.
The problem we are trying to solve is that when the Swagger is imported in C# (using Newtonsoft) the objects are defined but aren't created. So, the imported Swagger looks like this (partial)
Current XData Swagger : public partial class TCreateLabelRequest
[Newtonsoft.Json.JsonProperty("shipFrom", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public TGFSAddress ShipFrom { get; set; }
[Newtonsoft.Json.JsonProperty("shipTo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public TGFSAddress ShipTo { get; set; }
However, when we import from another Swagger (written in Node.js) we get the following:
Current Node Swagger : public partial class CreateLabelRequest
[Newtonsoft.Json.JsonProperty("shipFrom", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required]
public Address ShipFrom { get; set; } = new Address();
[Newtonsoft.Json.JsonProperty("shipTo", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required]
public Address ShipTo { get; set; } = new Address();
Note that the definitions have new Address() appended. This seems to be the result of the required flag being set to Always (Required = Newtonsoft.Json.Required.Always
) rather than Default (Required = Newtonsoft.Json.Required.Default
).
Is there a way to set this in XData on the class definition? Or is there another way this could be acheived?
Thanks