Skip to content

skip and top disappear with inheritance generic controller #582

@franfr57

Description

@franfr57

Hello,

I want to test the ASP.NET Core example with OData API Explorer (https://github.com/microsoft/aspnet-api-versioning/tree/master/samples/aspnetcore/SwaggerODataSample))

I want to create a basic controller to transmit methods to my main controllers via inheritance.

Here is the controller I created with the Get method of PeopleController (v3):
`public class BaseController2 : ODataController
{
[Produces("application/json")]
[ProducesResponseType(typeof(ODataValue<IEnumerable>), Status200OK)]
public IActionResult Get(ODataQueryOptions options)
{
var validationSettings = new ODataValidationSettings()
{
AllowedQueryOptions = Select | OrderBy | Top | Skip | Count,
AllowedOrderByProperties = { "firstName", "lastName" },
AllowedArithmeticOperators = AllowedArithmeticOperators.None,
AllowedFunctions = AllowedFunctions.None,
AllowedLogicalOperators = AllowedLogicalOperators.None,
MaxOrderByNodeCount = 2,
MaxTop = 100,
};

        try
        {
            options.Validate(validationSettings);
        }
        catch (ODataException e)
        {
            return BadRequest();
        }

        var people = new[]
        {
            new Person()
            {
                Id = 1,
                FirstName = "John",
                LastName = "Doe",
                Email = "[email protected]",
                Phone = "555-987-1234",
            },
            new Person()
            {
                Id = 2,
                FirstName = "Bob",
                LastName = "Smith",
                Email = "[email protected]",
                Phone = "555-654-4321",
            },
            new Person()
            {
                Id = 3,
                FirstName = "Jane",
                LastName = "Doe",
                Email = "[email protected]",
                Phone = "555-789-3456",
            }
        };

        return Ok(options.ApplyTo(people.AsQueryable()));
    }
}`

Then I inherit PeopleController from the BaseController.

The problem is that in swagger, the skip and top methods disappear.

Do you know how I can solve this problem?

Thank you.

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions