I have an OData service built as .NET 5 web api, that exposes entity types and sets for different parts of the system- a public one for general data export and a "private" one that is used for internal applications.
Some of these entity sets are meant for the "private" part are not yet (or will never be) ready for public exposure. I have excluded them from Swagger and user would get 404 when trying accessing it with the authentication that is used in the public part of the service.
My issue is with $metadata endpoint that returns description about all the entity sets. So when a public user accesses the service, it sees entities that it should not.
Is there a way to exclude specific entity sets from the $metadata?
I've tried overriding ODataMetadataSerializer to exclude unwanted schema elements, but it does't allow manipulating the EDM model before generating the response.