Swagger Json is malformed in the sense that it cannot be serialized or deserialized in many languages because it allows for properties with illegal variable names such as forward slash. Take this common example from the Swagger website:
http://petstore.swagger.io/v2/swagger.json
If you copy and past the json in to this common Json -> C# converter, you get an error. Try it out:
It kind of works here: https://www.freecodeformat.com/json2csharp.php
But, this is the C# that is generated:
public class Paths
{
/// <summary>
///
/// </summary>
public /pet /pet { get; set; }
/// <summary>
///
/// </summary>
public /pet/findByStatus /pet/findByStatus { get; set; }
/// <summary>
///
/// </summary>
public /pet/findByTags /pet/findByTags { get; set; }
/// <summary>
///
/// </summary>
public /pet/{petId} /pet/{petId} { get; set; }
/// <summary>
///
/// </summary>
public /pet/{petId}/uploadImage /pet/{petId}/uploadImage { get; set; }
/// <summary>
///
/// </summary>
public /store/inventory /store/inventory { get; set; }
/// <summary>
///
/// </summary>
public /store/order /store/order { get; set; }
/// <summary>
///
/// </summary>
public /store/order/{orderId} /store/order/{orderId} { get; set; }
/// <summary>
///
/// </summary>
public /user /user { get; set; }
/// <summary>
///
/// </summary>
public /user/createWithArray /user/createWithArray { get; set; }
/// <summary>
///
/// </summary>
public /user/createWithList /user/createWithList { get; set; }
/// <summary>
///
/// </summary>
public /user/login /user/login { get; set; }
/// <summary>
///
/// </summary>
public /user/logout /user/logout { get; set; }
/// <summary>
///
/// </summary>
public /user/{username} /user/{username} { get; set; }
}
Note: it is totally malformed.
Is there a way to get this stuff in and out of an object model without resorting to trawling through the object model with Newtonsoft's JObjects etc.?