Reputation: 8402
I have built an application running on Azure (ASP.Net Core 2.1) that involves microservices and a client application:
Client app (Android) --calls--> microservice A (gateway) --forwards-> microservice B
In the microservice B, I have the following method defined in an Controller
:
[HttpPatch]
[SwaggerOperation(OperationId = nameof(PatchEntityAsync))]
[Route(ApiConstants.Constraints.ControlId, Name = nameof(PatchEntityAsync))]
[SwaggerResponse(StatusCodes.Status204NoContent, "Result of the patch")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[Consumes(MediaTypes.Application.JsonPatch)]
public async Task PatchEntityAsync(string tenantId, Guid entityId, JsonPatchDocument<EntityModel> entityUpdates)
{
//
}
The method accepts a JsonPatchDocument
to apply on an EntityModel
. After generating the swagger and running autorest, I get the following auto generated method:
Task<HttpOperationResponse> PatchEntityWithHttpMessagesAsync(string tenantId, System.Guid controlId, IList<Operation> entityPatches = default(IList<Operation>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
This auto generated client is being used by microservice A who has a similar Controller that accepts a JsonPatchDocument.
Problem
However, it seems that I have lost the type constraint: it is no longer advertised that microservice B requires a list of updates on an EntityModel
type.
Question
How can microservice A transfer a generic JsonPatchDocument<>
to microservice B without having to manipulate the data?
Upvotes: 6
Views: 506