I have a azure function (HTTP trigger) which uses attributes of the OpenApi NuGet package. See a example of my function:
[FunctionName(nameof(GetTestModel))]
[OpenApiOperation(
operationId: nameof(GetTestModel),
Summary = $"Summary")]
[OpenApiParameter(
name: "id",
Description = "The Id of the object.",
Required = true)]
[OpenApiParameter(
name: nameof(TestRequestModel.TraceId),
Description = "The TraceId/CorrelationId to use for this request path",
In = ParameterLocation.Header)]
[OpenApiResponseWithBody(
HttpStatusCode.OK,
"application/json",
typeof(TestResponseModel),
Description = $"An object containing all information about the retrieved {nameof(TestResponseModel)}.")]
[OpenApiResponseWithBody(
HttpStatusCode.NotFound,
"application/json",
typeof(CustomHttpError),
Description = "An object containing information about occured errors/exceptions")]
public async Task<ActionResult<TestResponseModel>> Run(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "test")]
TestRequestModel request)
{
// do stuff.
}
As you can see that are a lot of attributes. I would like to reduce it to 1 custom attribute, like this:
[FunctionName(nameof(GetTestModel))]
[OpenApiCustom(nameof(GetTestModel), typeof(TestResponseModel), typeof(TestResponseModel)]
public async Task<ActionResult<TestResponseModel>> Run(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "test")]
TestRequestModel request)
{
// do stuff.
}
Is this possible?