-
-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathJsonApiRequestFormatMetadataProvider.cs
More file actions
34 lines (29 loc) · 1.03 KB
/
JsonApiRequestFormatMetadataProvider.cs
File metadata and controls
34 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Formatters;
namespace JsonApiDotNetCore.OpenApi.Swashbuckle;
/// <summary>
/// Determines the Content-Type used in OpenAPI documents for request bodies of JSON:API endpoints.
/// </summary>
internal sealed class JsonApiRequestFormatMetadataProvider : IInputFormatter, IApiRequestFormatMetadataProvider
{
/// <inheritdoc />
[ExcludeFromCodeCoverage]
public bool CanRead(InputFormatterContext context)
{
return false;
}
/// <inheritdoc />
[ExcludeFromCodeCoverage]
public Task<InputFormatterResult> ReadAsync(InputFormatterContext context)
{
throw new UnreachableException();
}
/// <inheritdoc />
public IReadOnlyList<string> GetSupportedContentTypes(string? contentType, Type objectType)
{
ArgumentNullException.ThrowIfNull(objectType);
return OpenApiContentTypeProvider.Instance.GetRequestContentTypes(objectType);
}
}