Skip to content

Quote Strings in OData Route Templates #1152

@commonsensesoftware

Description

@commonsensesoftware

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

No response

Describe the solution you'd like

In certain contexts, OData strings are required to be single-quoted. The known scenarios are:

  • Composite Keys: Entity(Id=42, Name='Example')
  • Function Parameters: GetTaxRate(PostalCode='90210')

The issue is that the source route template does not provide or allow ' in the template. The previous route templates would be:

  • Entity(Id={id}, Name={name})
  • GetTaxRate(PostalCode={postalCode})

Adding literal single quotes in the template results in an error.

This behavior becomes an issue for components that are not OData-aware; specifically, the API Explorer, OpenAPI, and the Swagger UI. The Swagger UI will ultimately understand that the value is a string, but the input will not be quoted nor is the route template parameter quoted. As a result, the generated URL will be wrong and requests will fail.

The API Versioning API Explorer extensions for OData should be smart enough to detect such parameters and fix up the route template so that it is appropriately quoted. This will require no change from OpenAPI or the Swagger UI, but will allow these types of string parameters to be correctly formatted.

Additional context

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions