-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi
Milestone
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.
Like https://github.com/dotnet/aspnetcore/pull/58193/files
Describe the solution you'd like
Usage in mvc controller
[ProducesResponseType<PaginatedResponseResult<GetAdminUserDto>>(StatusCodes.Status200OK, SchemaId = "PaginatedGetAdminUserDto")]
Output schema: PaginatedGetAdminUserDto
Additional context
add a schemaId filed. then we can read customized schemaId in there,
internal static string? GetSchemaReferenceId(this JsonTypeInfo jsonTypeInfo, bool isTopLevel = true)
{
var type = jsonTypeInfo.Type;
var underlyingType = Nullable.GetUnderlyingType(type);
if (isTopLevel && OpenApiConstants.PrimitiveTypes.Contains(underlyingType ?? type))
{
return null;
}
// Short-hand if the type we're generating a schema reference ID for is
// one of the simple types defined above.
if (_simpleTypeToName.TryGetValue(type, out var simpleName))
{
return simpleName;
}
// Although arrays are enumerable types they are not encoded correctly
// with JsonTypeInfoKind.Enumerable so we handle the Enumerable type
// case here.
if (jsonTypeInfo is JsonTypeInfo { Kind: JsonTypeInfoKind.Enumerable } || type.IsArray)
{
return null;
}
if (jsonTypeInfo is JsonTypeInfo { Kind: JsonTypeInfoKind.Dictionary })
{
return null;
}
return type.GetSchemaReferenceId(jsonTypeInfo.Options);
}
No response
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi