twilio / twilio-oai

The Twilio OpenAPI Specification
MIT License
123 stars 77 forks source link

Date fields do not contain date values, instead "string" #92

Open kjbkjb opened 1 year ago

kjbkjb commented 1 year ago

Issue Summary

Wrongly typed data for dates. Dummy dates are returned with the string literal "string" as the value which blows up in the json parser.

Steps to Reproduce

  1. Using the Twilio c# rest client library, perform an AccountResource.Create action

Code Snippet


var account = AccountResource.Create(
                friendlyName: $"SMS Provider Account (orgId: {organizationId})",
                client: client
           );

//The mock server responds with incorrect data for all date fields:
//{\"auth_token\":\"string\",\"date_created\":\"string\",\"date_updated\":\"string\",\"friendly_name\":\"string\",\"owner_account_sid\":\"stringstringstringstringstringstri\",\"sid\":\"stringstringstringstringstringstri\",\"status\":\"active\",\"subresource_uris\":{},\"type\":\"Trial\",\"uri\":\"string\"}"

  // from the Twilio rest client library, the json parsing throws type errors for dates (below)
    public static AccountResource Create(CreateAccountOptions options, ITwilioRestClient client = null)
    {
      client = client ?? TwilioClient.GetRestClient();
      return AccountResource.FromJson(client.Request(AccountResource.BuildCreateRequest(options, client)).Content);
    }

Exception/Log

Twilio.Exceptions.ApiException
Could not convert string to DateTime: string. Path 'date_created', line 1, position 46.
   at Twilio.Rest.Api.V2010.AccountResource.FromJson(String json)
   at Twilio.Rest.Api.V2010.AccountResource.Create(CreateAccountOptions options, ITwilioRestClient client)
   at Twilio.Rest.Api.V2010.AccountResource.Create(String friendlyName, ITwilioRestClient client)
   at TotalExpert.Comms.Sms.TwilioManagement.SubaccountCreator.CreateSubaccount(LegacyId organizationId) in /Users/kevin.boedigheimer/totalexpert/sms-service/CommandProcessor/TwilioManagement/SubaccountCreator.cs:line 28

Newtonsoft.Json.JsonReaderException
Could not convert string to DateTime: string. Path 'date_created', line 1, position 46.
   at Newtonsoft.Json.JsonReader.ReadDateTimeString(String s)
   at Newtonsoft.Json.JsonTextReader.FinishReadQuotedStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsDateTime()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
   at Twilio.Rest.Api.V2010.AccountResource.FromJson(String json)

Technical details:

twilio-dx commented 1 year ago

Ahoy! Thank you for opening your first issue here! If this request is regarding troubleshooting your application, please reach out to the support team via https://support.twilio.com.

kjbkjb commented 1 year ago

If this is an issue with Prism and not the spec, please comment.