Reputation: 4592
I have two api endpoints
[HttpGet("/items/{id:guid}")]
public IActionResult GetItemById(Guid id)
{
[HttpGet("/items/{code}")]
public IActionResult GetItemByCode(string code)
{
Swagger seems to deal with those without any problem. I've looked into the OpenAPI json file and noticed that the guid endpoint has a format property in the parameter object set to "uuid". The code endpoint doesn't have this property set at all. The type parameter of both is set to "string", so I believe this is how swagger differentiate them. I wanted to import this json file to Azure API Gateway, but it failed because it's seeing both of them as the same signature. Does it mean that Azure doesn't support format property of the parameter object? Is it part of the v3 specification? Are there any plans for this to be supported in Azure in the nearest future? Was trying to look for any info regarding that, but couldn't find any details.
Upvotes: 1
Views: 295
Reputation: 7795
Yes, from APIM point of view those are the same. I'm really not sure how OpenAPI spec would handle those either, sure you can write such spec file, but what would that mean is unclear. I couldn't find any word about this is OpenAPIv2.
Such specs are problematic at runtime as well. One would have to have a quite comprehensive priority order to parameter types to make it somehow work, and I feel that this may not satisfy all. Imagine a call is made:
/items/9c850ade-c083-4f66-b03d-3fdecffb8bd0
should it match id:guid or code:string? This is not immediately clear. So it's best to avoid such ambiguities.
Upvotes: 1