Hi Sebastian,
thanks for the link! We found some time to look at Squidex again and try to evaluate it further
We managed to create the classes (by cloning the sample project, adjusting the json path to the Swagger Json from the cloud version in the project, and generating the classes. This works fine so far:
In case anyone else is looking for usage information on autogenerated classes, this might be helpful. Currently, there’s no documentation for it:
var squidexClientManger = new SquidexClientManager(
serviceUrl: "XXXX",
applicationName: "XXX",
clientId: "XXX",
clientSecret: "XXX");
var homeClient = new HomeClient(squidexClientManger.CreateHttpClient());
var foo = homeClient.GetHomeContentAsync(new Guid("XXX-XXX-X-X-d7436382f155"));
Yes, you are right. The autogenerated code is a little bit ugly since it introduces an intermediate wrapper class which is present the swagger defintion. In our case this was the result:
public partial class HomeDto
{
[Newtonsoft.Json.JsonProperty("service-block", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public HomeServiceBlockProperty ServiceBlock { get; set; }
</pre>
<pre>
public partial class HomeServiceBlockProperty
{
[Newtonsoft.Json.JsonProperty("iv", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.ICollection<Iv> Iv { get; set; }
With IV being
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.4.0 (Newtonsoft.Json v9.0.0.0)")]
public partial class Iv
{
[Newtonsoft.Json.JsonProperty("headline", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string Headline { get; set; }
[Newtonsoft.Json.JsonProperty("sub-headline", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string SubHeadline { get; set; }
// ...
What I hoped to get was HomeDto
with a List<HomeServiceBlockProperty>
where HomeServiceBlockProperty
contains the fields from Iv
.
Given that you are using NSwag to generate the classes, would you be able to provide a more “flattened” JSON representation that we can you for NSwag? =) So in addition to swagger/v1/swagger.json
, there could be a swagger/v1/swagger_autogenerate.json
which could produce the classes in the desired function. This should be a lot faster than writing code that generates the classes as plain text.