Last updated
Was this helpful?
Last updated
Was this helpful?
For security reasons, the System.Text.Json
serializer will not serialize types that are not explicitly referenced at compile time.
This can be a challenge when dealing with polymorphic API outputs. As a workaround, the Management API provides two options for enabling polymorphic outputs.
This approach requires that all output models implement the same interface - for example:
The ProducesResponseType
annotation on the endpoints must also be updated to use the interface:
This approach requires that all output models implement a common base class. The base class will define all its derived types by annotation - for example:
The ProducesResponseType
annotation on the endpoints must also be updated to use the base class:
How to support polymorphic outputs from custom Management APIs