Generated code from IDE throws error

Hi - I'm using the Radzen IDE to create a Blazor Server side application that gets its data from an API (this IDE is awesome, btw.) I have a service that returns a simple list of strings to be bound to a DropDown. I was getting an error that the Deserialization had failed and saw that this was the generated code:

return await JsonSerializer.DeserializeAsync<IEnumerable<HttpResponseMessage>>(stream, new JsonSerializerOptions
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                    PropertyNameCaseInsensitive = true,
                });

I changed the type in this code, as well as the return type of the method to this and it works as expected now.

  return await JsonSerializer.DeserializeAsync<IEnumerable<string>>(stream, new JsonSerializerOptions
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                    PropertyNameCaseInsensitive = true,
                });

When I open the manually edited code again in the Radzen IDE, it regenerates it again with the code that errors. Is there a way in the IDE to tell it explicitly what type to use?

Thanks!

Don

Hi @kingdona,

Radzen will generate the code according to the service meta data. For example with Spotify service used in our docs getNewReleases method is defined with specific response


The meta code will looks like this:


And the generated code will be strongly typed:

Is this something that will be fixed in a future update?

There is nothing for fixing. I'm trying to illustrate you how you should describe your REST service in order to get proper code.

So your code errors out because it defines the return type improperly and you think that I should change my service when there is nothing wrong with it? Seriously?

No. You should not change your service, just describe it properly as shown with Spotify service. We can't change Spotify service either.