public class EventQuery
{
public EventQuery(long? eventId, string tag)
{
EventId = eventId;
Tag = tag;
}
public long? EventId { get; }
public string Tag { get; }
}
public class EventQueryConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
return base.ConvertFrom(context, culture, value);
}
}
// in EventsController.cs
[HttpGet("{query}")]
[Produces("application/protobuf")]
public string Get([FromQuery] EventQuery query)
{
...
}
// in Startup.cs
public void ConfigureServices(IServiceCollection services)
{
TypeDescriptor.AddAttributes(typeof(EventQuery), new TypeConverterAttribute(typeof(EventQueryConverter)));
}
System.Collections.Generic.KeyNotFoundException: The given key 'WebApplication3.EventQuery' was not present in the dictionary.
at System.Collections.Generic.Dictionary2.get_Item(TKey key)
at Swashbuckle.AspNetCore.SwaggerGen.PrimitiveSchemaGenerator.GenerateSchemaFor(Type type, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.ChainableSchemaGenerator.GenerateSchema(Type type, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchema(Type type, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateParameter(ApiDescription apiDescription, ApiParameterDescription apiParameter, SchemaRepository schemaRepository)
at System.Linq.Enumerable.WhereSelectListIterator2.ToList()
at System.Linq.Enumerable.ToListTSource
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
See c1fb708e3fe3f2c62abf4a85b91786f38b66582e. This is what have happened for this scenario in older versions.
@domaindrivendev I can see the v5-rc2 was released earlier, than the commit you've posted (22 March vs 17 May). Could you release a new rc version with the latest fixes?
Most helpful comment
@domaindrivendev I can see the v5-rc2 was released earlier, than the commit you've posted (22 March vs 17 May). Could you release a new rc version with the latest fixes?