Skip to content

OData OpenAPI AllowedQueryOptions is not generated correctly #853

Closed
@dnperfors

Description

@dnperfors

Using .NET 6, OData 8 and the preview version of the library, I have some problems with generating correct swagger documentation for the AllowedQueryOptions.
All the code is based on the ODataOpenApiExample in the main branch.

Given the following:
options in Program.cs:

options.Count().Select().OrderBy();

On top of the OrdersController Get method:

[EnableQuery( MaxTop = 100, AllowedQueryOptions = Select | Top | Skip | Count )]

I get not 4, but 5 fields in the swagger documentation:
image
I wouldn't expect the "OrderBy" field and when I use it I get a 400 Bad Request with the message: " Query option 'OrderBy' is not allowed".

When I add:

[EnableQuery( MaxTop = 100, AllowedQueryOptions = Select | Top | Skip | Count | Filter )]

I do get the filter field, but I can't use it because I get the message: "The property 'customer' cannot be used in the $filter query option." (Although this might be more of a OData issue)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions