AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

Swagger not encoding multiple key string values

Open adrien-constant opened this issue 3 years ago • 1 comments

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 avatar Aug 27 '22 10:08 adrien-constant

@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.

xuzhg avatar Aug 30 '22 23:08 xuzhg