AspNetCoreOData
AspNetCoreOData copied to clipboard
Swagger not encoding multiple key string values
Assemblies affected ASP.NET Core OData 8.0.11
Describe the bug Swagger doesn't encode string values in quotes on entity query by key with multiple key properties. Thus exception is raised : Microsoft.OData.ODataException: 'The key value (XXX) from request is not valid. The key value should be format of type 'Edm.String'.'
Reproduce steps
- Clone the repo, launch the ODataRoutingSample project from the solution.
- Go to
GET /People(FirstName={keyFirstName},LastName={keyLastName}) - Fill in keyFirstName and keyLastName
- Send the HTTP request
Expected behavior Swagger request works.
@adrien-constant Based on OData spec, the string literal is a single-quoted string.
You should call the API as (for example): GET /People(FirstName='abc',LastName='efg')
We are considering to generate GET /People(FirstName='{keyFirstName}',LastName='{keyLastName}').
Maybe we can add a configuration to support it.