Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
Similar to the issue asking to automatically create OpenApiParameters when using BindAsync in Minimal API, implementing TryParse
for Minimal API custom binding will describe the parameter as object
.
Describe the solution you'd like
If a type implements TryParse
, at a minimum, the parameter should be described as a string.
Additional context
The workaround currently requires the use of a custom schema transformer such as this:
builder.Services.AddOpenApi(options =>
{
options.AddSchemaTransformer((schema, context, _) =>
{
var isParsable = context.JsonTypeInfo.Type.GetInterfaces()
.Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IParsable<>));
if (isParsable)
schema.Type = "string";
return Task.CompletedTask;
});
});