I have a specific case - I'm bulding an Azure Function endpoint that can take dynamic request payload, after that function is executed it takes the request body, and validates it against correct JSON schema that is stored somewhere in the storage. The schema is chosen based on the URL parameter.
Here's a snippet of the function:
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(PublishResult))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(PublishResult))]
[FunctionName("Publish")]
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "publish/{eventType}")] HttpRequest req,
[Blob("storage/{eventType}.json", FileAccess.Read)] Stream validationSchema,
string eventType, ExecutionContext ctx)
{
JObject jResult;
(isValid, error, jResult) = await ValidateRequestObject(req, eventType, validationSchema);
if (!isValid)
{
_log.LogWarning("Invalid object. {Id}, {ObjectError}", id, error);
return new BadRequestObjectResult(new PublishResult(id, error));
}
// function logic
}
So my issue here is that I'd like to configure Swashbuckle so that it generates different request body based on these JSON schemas that I have. I can't figure out how to tell Swashbuckle to use my own custom JSON schemas for this.
I know that it should probably be done by implementing IOperationFilter but I can't really get it right. I've found few cases that are similar but not quite what I'm looking for.
Help would be much appreciated!