-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Net.Http
Milestone
Description
Background and motivation
RFC 9512 registered application/yaml as the media type for YAML in February 2024.
It would be useful if a constant for it were added to the MediaTypeNames.Application class alongside other similar constant values, such as for JSON and XML.
application/gzip was recently added by #103575 to resolve #95446 so I assume it's not locked-down for additions like similar types in ASP.NET Core are.
API Proposal
namespace System.Net.Mime;
public static partial class MediaTypeNames
{
public static partial class Application
{
+ /// <summary>Specifies that the <see cref="MediaTypeNames.Application"/> data is in YAML format.</summary>
+ public const string Yaml = "application/yaml";
}
}API Usage
public async Task WriteDocumentAsync(
OpenApiDocument document,
OpenApiSpecVersion version,
HttpContext httpContext)
{
using var stream = new MemoryStream();
using var streamWriter = new StreamWriter(stream);
var yamlWriter = new OpenApiYamlWriter(streamWriter);
document.Serialize(yamlWriter, version);
httpContext.Response.ContentType = MediaTypeNames.Application.Yaml;
await httpContext.Response.BodyWriter.WriteAsync(stream.ToArray(), httpContext.RequestAborted);
await httpContext.Response.BodyWriter.FlushAsync(httpContext.RequestAborted);
}Alternative Designs
None.
Risks
None.
julealgon
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Net.Http