Problem has been resolved by using Swagger to generate the json file. Also as mentioned in one of the links from @dbc, [JsonDerivedType] needed to be added to all classes and interfaces in the inheritance hierarchy. This failed when using app.MapOpenApi() due to the duplicate key issue.