Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Unassigned: ApiExplorer not returning expected descriptions. It should probably consider like request time action match based on route/query parameters. [1293]

$
0
0
__Scenario__:
User likes to support uri path extension mapping on actions where we get a single item (ex: GetCustomer(id), Get(id))

__Attached__ a katana selfhost repro.

__Issue__:
ApiExplorer doesn't return a description like "api/Values/{id}.{ext}" as expected even though during the actual runtime it works.

__Cause__:
For each route in the route table, ApiExplorer probes each action on the controller to see if its reachable. For the "DefaultApiWithExtension2" route and ValuesController below, ApiExplorer finds 2 duplicate descriptions like below:
Get() -> GET api/Values/{id}.{ext}
Get(id) -> GET api/Values/{id}.{ext}

ApiExplorer then filters out descriptions which it thinks would cause request time ambiguity, but actually during request time there is no ambiguity as action match logic works fine.

__Configuration__:
```
// GET api/Values/10.json
config.Routes.MapHttpRoute(
name: "DefaultApiWithExtension2",
routeTemplate: "api/{controller}/{id}.{ext}",
defaults: null,
constraints: new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) }
);

// GET api/Values
// GET api/Values/10
// POST api/Values
// PUT api/Values/10
// DELETE api/Values/10
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
```

__Controller__:
```
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}

// GET api/values/5
public string Get(int id)
{
return "value";
}

// POST api/values
public void Post([FromBody]string value)
{
}

// PUT api/values/5
public void Put(int id, [FromBody]string value)
{
}

// DELETE api/values/5
public void Delete(int id)
{
}
}
```
__Based on my repro code__:
Expected api description count: 1
Actual api description count: 0

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>