Azure / Azure-Functions

1.12k stars 199 forks source link

Api Definition/OpenAPI - Api Management Import Failure #948

Open michaelvannevel opened 6 years ago

michaelvannevel commented 6 years ago

I have an API Management Service and an Azure Function. When trying to import the OpenApi spec via the API Management service 'Import Function' button I get an error. The error states something similar to 'values in your route template must be included as parameters to the function'. So if i create an httpfunction and use modelbinding by following [HttpTrigger]MyModel model it is bound with both values from the route and the querystring if its a get request. So the question is why do I get this error? Is it that the open api spec is being created incorrectly or?

michaelvannevel commented 6 years ago

For example say i have history/{id} as my route. I have a model public class MyModel { public int Id{get;set;} public string Name{get;set;} }

I call it with http://someurl.com/history/14?name=bob Model binding would provide a MyModel with an Id of 14 and a Name of bob. My function has an argument express as: [HttpTrigger]MyModel model.

My guess is that the OpenApi spec is not including the object MyModel, and for that reason is throwing the previously mentioned error.

ColbyTresness commented 5 years ago

@eamonoreilly for OpenAPI