forge-api-dotnet-client
forge-api-dotnet-client copied to clipboard
Bug in .NET core proxies
I've experienced some issues when using this library for developping a proxy via Web Api .NET Core 2.2 :
Autodesk.Viewing.endpoint.setEndpointAndApi(${EnpointApiUrl}/api/forge, 'modelDerivativeV2');
Hope thoses issues will be fixed in next release.
- First error was produced in DerivativesApi when using GetManifestAsyncWithHttpInfo and GetDerivativeManifestAsyncWithHttpInfo.
To fix that, some little modification in ApiClient / Deserailize as
- actual coding :
if (asType) return JsonConvert.DeserializeObject(response.Content, type, serializerSettings);
return new DynamicJsonResponse(JObject.Parse(response.Content));
- need to be fixed by :
if (type == typeof(Manifest))
return JObject.Parse(response.Content);
if (type == typeof(BucketObjects))
return new DynamicJsonResponse(JObject.Parse(response.Content));
else
return new DynamicJsonResponse(JObject.Parse(response.Content));
- Bug found when downloading in DerivativesApi / GetDerivativeManifestAsyncWithHttpInfo
return new ApiResponse<Object>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
**localVarResponse.RawBytes**); // null is not good here !
- Bug number 9 (no views) and to avoid array with integer indexes when rendering to json as 0: {...}, need to fix in DanamicJsonResponse by adding this:
internal static void ProcessObjectArrayToList(JObject obj, DynamicDictionary dict)
{
foreach (KeyValuePair<string, JToken> pair in obj)
{
if (pair.Value.GetType() == typeof(JValue))
{
dict.Dictionary[pair.Key] = ((JValue)pair.Value).Value;
}
else if (pair.Value.GetType() == typeof(JObject))
{
DynamicDictionary subDict = new DynamicDictionary();
ProcessObject((JObject)(pair.Value), subDict);
dict.Dictionary[pair.Key] = subDict;
}
else if (pair.Value.GetType() == typeof(JArray))
{
//DPN
//DynamicDictionary subDict =new DynamicDictionary () ;
var subDict = new List<dynamic>();
ProcessArrayToList((JArray)(pair.Value), subDict);
dict.Dictionary[pair.Key] = subDict;
}
}
}
internal static void ProcessArrayToList(JArray obj, List<dynamic> dict)
{
int i = 0;
foreach (JToken item in obj)
{
if (item.GetType() == typeof(JValue))
{
//dict.Dictionary [i.ToString ()] =((JValue)item).Value ;
dict.Add(((JValue)item).Value);
}
else if (item.GetType() == typeof(JObject))
{
DynamicDictionary subDict = new DynamicDictionary();
ProcessObject((JObject)(item), subDict);
//dict.Dictionary [i.ToString ()] =subDict ;
dict.Add(subDict);
}
else if (item.GetType() == typeof(JArray))
{
//DynamicDictionary subDict =new DynamicDictionary ();
var subDict = new List<dynamic>();
ProcessArrayToList((JArray)item, subDict);
//dict.Dictionary [i.ToString ()] =subDict ;
dict.Add(subDict);
}
i++;
}
}
Thank you for your awesome work ! Max.