Azure / Azure/azure-functions-host

Preserve datatype constraints provided in HttpTrigger route

Open
#2,279 16 comments 4 reactions 1 assignee Claimed by @gzuber View on GitHub
enhancement
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

[Route Constraints](https://docs.microsoft.com/en-us/aspnet/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2#constraints) allow specifying datatypes for query string parameters on HttpTrigger route property. These constraints are only used to match the route.
When using binding parameters datatype is converted to strings. For example:
```
{
"disabled": false,
"bindings": [{
"authLevel": "admin",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get"
],
"route": "InventoryPosition/{locationNumber:int}/{itemNumber:int}"
},
{
"name": "inventoryPositions",
"type": "documentdb",
"direction": "in",
"databaseName": "ihub",
"collectionName": "inventoryPosition",
"sqlQuery": "SELECT * FROM c WHERE c.locationNumber = udf.toInt({locationNumber}) AND c.itemNumber = udf.toInt({itemNumber})",
"connection": "DOCUMENTDB_CONNECTIONSTRING"
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
}

```
locationNumber and itemNumber have int constraints but are converted to string when using then doccument db query string.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.