For service methods that return collection of non-entity types REST API checks that case and throws an exception from JSONConverter.processServiceMethodResult().
if (!checkCollectionItemTypes((Collection) result, Entity.class))
throw new IllegalArgumentException("Items that are not instances of Entity found in service method result");
Whereas returning non-entity types (not wrapped in a collection) is allowed.
Returning a collection of non-entity types should be allowed as well.
Original issue: https://youtrack.haulmont.com/issue/PL-8131