JamesRandall / FunctionMonkey

Write more elegant Azure Functions with less boilerplate, more consistency, and support for REST APIs. Docs can be found at https://functionmonkey.azurefromthetrenches.com
MIT License
294 stars 50 forks source link

Not able to parse string[] #88

Closed umashankarsharma closed 5 years ago

umashankarsharma commented 5 years ago

Hi James,

I am giving something like below in my model class. but compiler shows the below issue.

public class GetCaseEntitiesQuery : ICommand<ErrorResponse>
    {

    [JsonProperty("ids")]
    public string[] Ids { get; set; }

    }
}

Unhandled Exception: FunctionMonkey.ConfigurationException: CS0117:'string' does not contain a definition for 'TryParse' SourceFile

JamesRandall commented 5 years ago

Could you try making that a List please and let me know if that helps please? The query parameters don't currently work with basic arrays. Its on my list :)

umashankarsharma commented 5 years ago

Hi James,

You are quick :) . I wanted to do that but Unfortunately , I could not change the contract of API's :(.

Thanks a lot.

Uma

JamesRandall commented 5 years ago

You caught me at my email :)

Changing it to a list won't change the external contract (I assume that's what you mean) - and if you're passing the ids down to some internal service via a command handler you should be able to do a .ToArray on it.

umashankarsharma commented 5 years ago

Thanks, James. Let me try it.

umashankarsharma commented 5 years ago

The "List Ids { get; set; }" did not work either... But I got another way of doing that.

public dynamic Ids { get; set; }

This works.

Thanks a lot, James.

MikesGlitch commented 5 years ago

I'm getting this issue as well. I'm on the latest beta

JamesRandall commented 5 years ago

Hi @CodeRevver - do you mean with an array?

I've just rerun the integration tests and the scenario I'm expecting to work is working. That is with a command like the following:

public class HttpListQueryParamCommand : ICommand<int>
{
    public List<int> Value { get; set; }
}

If you have a different variant on this could you post it here for me please! See if I can get to the bottom of this as it sounds like there is something I might be missing.

MikesGlitch commented 5 years ago

@JamesRandall I've reproduced it here:

Thanks for getting back to us so quickly - it's appreciated.

JamesRandall commented 5 years ago

Thanks for that - I see what's wrong now. I'll get a fix out shortly.

Thanks both for reporting it and helping me get to the bottom of it!

JamesRandall commented 5 years ago

I've resolved this and pushed an update to Nuget v3.0.13-beta5.

Thanks again for your help.