I create a service "EditCustomer", which is very similar as "EditPerson" in PhoneBook example. It works fine, but the API shows on Swagger UI as POST (green bar), instead of PUT (brown bar). What did I miss?
The only thing different is that, the "Person" entity inherent from FullAuditedEntity and IMustHaveTenant, but my "Customer" entity inherent from Entiy only. Is that the reason? If so, how do I work around it?
Thanks,
6 Answer(s)
-
0
Hi @ fguo,
Can you try to change your metod name to UpdateCustomer and see if it is displayed as PUT ?
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
It does the trick! Thanks!
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Great :)
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Is there a way to make swagger map actions/methods that start with "Edit" to PUT? Some configuration option maybe? I can't find any information on that.
I started working with AspNetZero by following your step-by-step-guide using "Edit" all the time. I just encountered the fact that swaggers maps them all to POST. Changing every action/method to start with "Update" is quite some task at the point where i am now ...
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
From the ASP.NET Core documentation's Application Services as Controllers section:
You can use any ASP.NET Core attributes to change the HTTP methods or routes of the actions. This requires you to add a reference to the Microsoft.AspNetCore.Mvc.Core package.
[HttpPut] public async Task EditCustomer(EditCustomerDto input)Or you can do it by convention: https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2939
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Thanks aaron :D I did try to use the attributes but couldn't figure out which reference I was missing - thank you very much for pointing it out!
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)