RicoSuter/NSwag

After upgrade core 2.2=>3.1, class with inheritance is shown as object

Open

#3141 aperta il 3 nov 2020

Vedi su GitHub
 (10 commenti) (0 reazioni) (0 assegnatari)C# (1189 fork)batch import
help wantedproject: NSwag.AspNetCore

Metriche repository

Star
 (6291 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

In 2.2, the controllers accepting a paramater of DataSourceLoadOptions correctly showed the structure of the inherited DataSourceLoadOptionsBase. This is no longer the case in 3.1 - it is now just shown as an object. Any ideas how I can fix this?

[ModelBinder(BinderType = typeof(DataSourceLoadOptionsBinder))]
public class DataSourceLoadOptions : DataSourceLoadOptionsBase
{
    public IList CustomQueryParams { get; set; }

}

public class DataSourceLoadOptionsBinder : IModelBinder
{
    public Task BindModelAsync(ModelBindingContext bindingContext)
    {
        var loadOptions = new DataSourceLoadOptions();
        DataSourceLoadOptionsParser.Parse(loadOptions, key => bindingContext.ValueProvider.GetValue(key).FirstOrDefault());
        var _customQueryParams = bindingContext.ValueProvider.GetValue("customQueryParams").FirstOrDefault();
        if (_customQueryParams != null)
        {
            loadOptions.CustomQueryParams = JsonConvert.DeserializeObject<IList>(_customQueryParams, new JsonSerializerSettings
            {
                DateParseHandling = DateParseHandling.None
            });
        }
        bindingContext.Result = ModelBindingResult.Success(loadOptions);
        return Task.CompletedTask;
    }
}

Guida contributor