Action and Operation do not expose $select and $expand over entity types
Action and Operation do not expose $select and $expand over entity types while this is possible for /entity/propertyOfComplexType
Assemblies affected
Microsoft.OpenApi.OData 1.7.5
Steps to reproduce
Register additional function for entity set:
var fax = builder.EntityType<XFax>();
fax.Collection.Function(nameof("GetByNumber"))
.ReturnsFromEntitySet<XFax>("Fax")
.NonNullable()
.Parameter<string>("number").NonNullable();
Expected result
GetByNumber should have both $select and $expand operations because XFax is Entity type
Actual result
No operations available
Additional detail
I see that ComplexPropertyGetOperationHandler has the following logic:
- Expose $top, $skip, $search, $filter $count for a collection
- Try to expose $select and $expand
On the contrary EdmOperationImportOperationHandler has the following logic:
- Expose $top, $skip, $search, $filter $count for a collection
- Expose $select and $expand if 1. is true
Therefore I can't get $select and $expand for Function or Operation. Is it something explicitly prohibited by OData? How can I do this in a different way?
P.S. I think as a workaround I can make alternate key. But I don't see any examples for OData 8
I don't believe it is possible to use $select and $expand on the results of actions, as per OData. You can designate a function as composable and then it should be possible.
I have the same problem. I think $select and $expand are supported for functions and actions bound to an Entity or EntityCollection (as per https://learn.microsoft.com/en-us/odata/concepts/queryoptions-overview#conventions). Also I can use $select and $expand manually and it works; it's just the OpenAPI definition that's missing them.
Basic EdmModel for a bound Action:
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="MyNamespace">
<Action Name="GetSelection" IsBound="true">
<Parameter Name="bindingParameter" Type="Collection(MyModel)"/>
<Parameter Name="selection" Type="MyNamespace.SelectionModel"/>
<ReturnType Type="Collection(MyModel)"/>
</Action>
</Schema>
I can call this action with $expand and it works. To suppot this now I had to manually add those two query parameters to these endpoints by modifying the resulting openApiDoc (var openApiDoc = edmModel.ConvertToOpenApi(settings);.
I imagined this to be fixed in #485, but in 1.7.5 this is still a problem.