So I have never had to define a class that the object name is going to vary. I have a collection of objects and the json result defines the key of the object (the name) as a string that is different for every object but really is should just be a property.
Live Json for inspection: Bungie Api Docs
Where "/User/GetBungieNetUserById/{id}/"
should be a variable called endpoint. But their data uses it as a key for an object. Visual Studio defines a class like this when I use paste special.
C# Class:
public class Paths
{
[JsonProperty(PropertyName = "/User/GetBungieNetUserById/{id}/")]
public UserGetbungienetuserbyidId UserGetBungieNetUserByIdid { get; set; }
...
When I am looking for something like this:
public class Paths
{
public Endpoint[] Endpoints { get; set; }
}
public class Endpoint
{
//Lots of properties
public string route { get; set; }
}
Simplified example:
{
"openapi": "3.0.0",
"paths": {
"/User/GetBungieNetUserById/{id}/": {
"summary": "User.GetBungieNetUserById",
"description": "Loads a bungienet user by membership id.",
"get": {
"tags": [
"User"
],
"description": "Loads a bungienet user by membership id.",
"operationId": "User.GetBungieNetUserById",
"parameters": [{
"name": "id",
"in": "path",
"description": "The requested Bungie.net membership id.",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}],
"responses": {
"200": {
"$ref": "#/components/responses/User.GeneralUser"
}
}
}
},
// Many additional properties named after endpoints, e.g.:
"/User/GetUserAliases/{id}/": {
}
}
}