(New to Api documentation)
I am somewhat confused with the difference between SwaggerUI and SwaggerHub.
Currently I have a C# Asp.net Web API code and Swashbuckle.AspNetCore is reading the code and the API is being documented on Swagger UI.
I have adopted a code first approach as everything is already coded. However, I would like to have my API documented in SwaggerHub.
I have currently not found any solutions of this online.
Is this possible and how do I go about doing it?
This is extremely easy to accomplish.
Once your document is generated by Swashbuckle, all that's needed for you to do is "push" the documentation to your instance of SwaggerHub. You can do this using one of two tools:
The create or update command from the SwaggerHub CLI: https://github.com/SmartBear/swaggerhub-cli
The POST /apis/{owner}/{api} endpoint from SwaggerHub's registry API : https://app.swaggerhub.com/apis-docs/swagger-hub/registry-api/1.0.62#/APIs/saveDefinition
With both of these tools you can programmatically send documentation from your build environment to SwaggerHub (as well as a lot of other cools things!).
Related
I'm currently trying to migrate an existing server-side application which uses Firebase Cloud Messaging. To my understanding, this NuGet package is suitable for that; I have successfully referenced it in the existing C# project.
However, the documentation available here is indeed a very documented, but does not give a step-by-step example on how to initiate a call. How can I formulate a call to the API? I have done so in the past successuflly with a customized HTTP request, but don't understand how to do this with the API.
Has anyone successully used this API before and could give some insights? Although I use C#, any experience already made with a different language will be appreciated.
We have a Web API project now I have to create a tool where I can test the methods of the Web API. I need to create a tool where if I give the request I need to get the XML response in UI. What approach should I follow?
You can use SwaggerUI as documentation and request testing tool. More information about Swagger can be found at their official site.
There are some helpful guides how to configure SwaggerUI for your application:
1. ASP.NET MVC Web API 2: https://dotnettutorials.net/lesson/how-to-use-swagger-in-web-api
2. ASP.NET Core Web API: https://learn.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle
Use Accept header while sending the request as "application/json" or "application/xml". Add xml formatting to list of formatters if not already done.
Read more on content negotiation here
https://learn.microsoft.com/en-us/aspnet/web-api/overview/formats-and-model-binding/content-negotiation
I am not sure what you mean by saying that you need to get the XML response in UI. If you need to test something manually and actually see the returned response, then Swagger is the most popular and easy-to-use option I would suggest you.
However, if you need to write automated tests, I would highly recommend you to try the MyTested ASP.Net framework. I personally use it in every web project that I do. It is pretty easy to start writing all kind of tests, it has a lot of functionalities within and can be configured for almost every case. The author is a very kind person and a friend of mine that dedicates most of its time on that project and can always relate to your problems (if such exist) and needs to build a better product.
If you are looking to perform integration tests against your APIs, you can use Postman: Postman
Hello VirtoCommrece People its an honor working with such product,
its a bit complex to me at my level so please forgive me if im asking some basic newbe questions ,
how dose the data comes from the platfrom to the api ?
i tried to delete the _workcontext from the index action nothing happen
i deleted the angular services the images gone but the data stayed so can anyone tell me
?
As I can understand, you're interesting in how data comes from platform to storefront. Storefront has auto-generated code (by AutoRest util from Microsoft) to call platform RESTful API from C#. This APIs called via frontend user with special api key. You can find more info here:
Working with Platform API
How to generate module API C# client using AutoRest
I read the OneNote Api Documentation https://dev.onenote.com/docs
But I don´t understand how to make a request to the OneNote API with c# web application in order to get all the pages in my OneNote.
I already got the Application Id, Application Secret Id and Redirect URL, but i don´t know where do I have to use them, because I have never done and http request and the documentation only provide the following: https://www.onenote.com/api/v1.0/me/notes/pages, so I don´t know how to send the id´s, redirect url and Authorization: Bearer.
Could you provide me the specific code to get a successful connection to OneNote API using Application Id, Application Secret Id and Redirect URL.
And the code structure to make a http request in order to get all the pages, notebooks, etc
I would appreciate if you could help me with this.
I would recommend using Microsoft Graph instead of the standalone OneNote API. Microsoft Graph includes support for OneNote. There is also an SDK for .NET available. There are also code samples for ASP.NET, UWP and Xamarin.
Before you can use the Graph API (or most any REST API for that matter), you will need to obtain an authorization token (i.e. the bearer token you referred to in your question). There are libraries available for simplifying this process. Behind the scenes, these libraries are executing an OAUTH 2.0 flow. You can read about what is going on under the covers here.
I believe the link they have on the OneNote Dev page is broken. The team has put together a public repository that contains a bunch of sample code in a myriad of languages including C#.
This is the main repo
Web API (ASP.NET Core) Repo
I believe the easiest way to understand these concepts is to look at sample code that does authentication. I recommend this sample:
https://github.com/OneNoteDev/MsGraph_OneNoteApiSampleAspNetCore
Btw - the demo is here: https://onenoteapisamplegraph.azurewebsites.net
Thank you everyone I have Checked all the links that you provided me and they were very useful, I did a connection to Microsoft Graph with the authorization token and I got access to my OneNote pages.
Thank you for your help.
I'm starting a side project that will integrate heavily with Facebook. I'm going to use React in the front-end and it will talk to a REST ws made with asp.net core web api.
The idea is that in this API I will make the calls to Facebook.
Basically, I want to: login, get/post messages from Messenger, get/post comments and messages from a business page.
I googled a little and didn't find many resources or examples of how to do this integrations other than the Facebook documentation, that has a lot of stuff and I don't know very well where to look.
I also found this SDK for .NET but it looks a bit dated https://github.com/facebook-csharp-sdk/facebook-csharp-sdk and
So, my question is: Is reading the documentations entirely really the best solution?
If anyone could at least give me a hint where to go I'd be really thankful. Would it be better/easier to integrate with Facebook with other stack than c#/asp.net?
Also, if there's any other API, SDK or something already built in .NET that would help with that I'd be grateful.
Thanks in advance.
I am one of .net developers working with Facebook API more then 5 years and we have tried to use "Facebook SDK for C#". It has more issues then benefits. In result we end up with our own small Facebook API client. Basically it is just a "RestSharp" HTTP library, "Newtonsoft.Json" for serialization/deserialization and couple of generic functions where you supply Facebook API endpoint, and specify what class you expect back as generic parameter.
var accounts = client.Get<Accounts>("me/accounts");
var createResponse = client.Post<CreateResponse>("123456779/feed", postToCreate);
Facebook SDK for C# works great for standard .NET
https://hackerapp.com/net/
https://github.com/facebook-csharp-sdk/facebook-csharp-sdk
As for .NET Core I think you are out of luck at the moment. Unless you want to port it to .NET Core yourself.
Automated Customer Service bots are not uncommon in FB, but code is hard to find. I assume you had setup you App's domain and got it reviewed and approved by FB.
I tried to set a chat-bot with both, python and .NET, and I must say the python Api is much more complete, quick, and less buggy than the C# one. But, as far as I know, only the PyApi has integrated reactions (haven't tried them).
Therefore, you will need to do this manually by using the Facebook Api by sending direct GET/POST request triggered by your ASP.NET, or use some kind of inter-language platform such as IronPython to workaround the problem (which basically assembly the call, add the Key and secret, and CURL-it).
As final remark (not a very motivating one), there is documentation for post reactions, but not for message as you can see here (posts), and here (messenger).
You can perform a lot of the facebook operations on the client side using their javascript SDK.
https://developers.facebook.com/docs/javascript
In regards to getting up to speed on server side API calls from .NET you can check out the facebook graph api explorer. It can be helpful for discovery.
https://developers.facebook.com/tools/explorer/
In case someone is looking for this topic, I had the same needs myself. After not finding a Facebook SDK to use with .NET Core, I've created a new open source .NET Standard unofficial SDK for Facebook: https://github.com/developer82/FacebookCore