I have an endpoint to query details about a "person". Problem, the response could be of type "PhysicalPerson" or "LegalPerson". Both inherit the same "BasePerson" class.
Here is my current code:
[HttpGet("personne/{idpersonne}")]
[ProducesResponseType(typeof(PersonneMoraleType), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(PersonnePhysiqueType), (int)HttpStatusCode.OK)]
public async Task<ActionResult> GetPerson(string idpersonne, [FromQuery] bool avecDocuments = false)
{
return Ok(await _app.LraConnector.LirePersonne(idpersonne, avecDocuments));
}
Problem, swagger only describe the second type (physical), but if I answer a LegalPerson, it throw a scheme exception. If I use the "BasePerson", both answers works fine, but it's not described properly.
Is there something I can do to improve that?