RicoSuter/NSwag
View on GitHubAfter upgrade core 2.2=>3.1, class with inheritance is shown as object
Open
#3141 opened on Nov 3, 2020
help wantedproject: NSwag.AspNetCore
Description
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;
}
}