Swashbuckle.AspNetCore icon indicating copy to clipboard operation
Swashbuckle.AspNetCore copied to clipboard

Route parameters not used correctly?

Open RobThree opened this issue 1 year ago • 2 comments

This works:

[HttpGet("{id}")]
public Task<ConnectionProductDTO> GetAsync(long id, CancellationToken cancellationToken = default)
    => _connectionproductservice.GetAsync(id, cancellationToken);

Request URL: https://localhost:5001/api/v1/foo/907306994157748224

This doesn't:

[HttpGet("{id}")]
public Task<ConnectionProductDTO> GetAsync(ObjectId id, CancellationToken cancellationToken = default)
    => _connectionproductservice.GetAsync(id, cancellationToken);

Request URL: https://localhost:5001/api/v1/foo/{id}?id=907306994157748224

Note the {id}?id=... in the above url.

The only difference is long vs ObjectId in the controller method. I am still git-bisecting and figuring out what changed; but this did work a year ago. The ObjectId can be (implicitly) cast from/to a long.

Oh, I also tried adding [FromRoute] to the argument to no avail.

Has something changed?

RobThree avatar Dec 14 '22 14:12 RobThree

Is that ObjectId from MongoDb? I believe it has changed rather than swashbuckle?

Havunen avatar Apr 14 '24 06:04 Havunen

Please provide a minimal reproducible example as a GitHub repository that demonstrates the issue you're experiencing so we can look into this further.

martincostello avatar Apr 14 '24 10:04 martincostello