Does anyone know if it is possible to map deserilize a custom wrapper object in a route? IDs in my system is strings, and we have therefore made an
External
External
class. The only point of this, is to improve code readability, to easy be able to view what is ids, and what is not.
We have made a serilizer, that maps maps the class to a string in any JSON schemes. However, this serilizer does not seem to work, when we use the class in a route.
Can we do it via a serilizer or some middleware, or do I have to take a string as input, and map it to
ExternalId
ExternalId
in my controller?
[HttpGet("{id}")] public async Task<MyDTO> GetSomething([FromRoute] ExternalId id) { var result = await _service.GetSomething(id); return result.ToDTO(); }
[HttpGet("{id}")] public async Task<MyDTO> GetSomething([FromRoute] ExternalId id) { var result = await _service.GetSomething(id); return result.ToDTO(); }
public class ExternalId{ public string Id { get; set; } public ExternalId() {} public ExternalId(string id) { Id = id; }
public class ExternalId{ public string Id { get; set; } public ExternalId() {} public ExternalId(string id) { Id = id; }