Turnerj / forem-dotnet

.NET API interface for Forem apps. Forem is the platform which powers DEV and other online communities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improving Documentation (Readme)

Turnerj opened this issue · comments

Currently the readme is pretty light on documentation and doesn't even link to the appropriate DEV API documentation for the endpoints that are exposed. It would be useful adding links and examples where appropriate.

Hello @Turnerj

I can help with this.

Awesome - let me know if you have any issues or questions. 🙂

Basically, the Readme should describe the usage of all the api methods with example (request and response), correct?

Basically, yeah. I'm thinking explain the mapping between the specific classes here and the API endpoint for DEV/Forem, with a link off to Forem's API docs - that way anyone looking at this library knows without a doubt what it is actually doing. If there is a decent description on the linked API docs, feel free to use that to describe what it does. Throwing in a short code block of what the C# code looks like would be really helpful too. 🙂

The library is Deprecated on Nuget. And are they other ways to install the library?

When I originally started the library, it was before DEV announced the platform itself would be named Forem. Because the API will be the same across all Forem instances, I renamed the library on NuGet through the not-so-fun process of deprecating old versions and trying to signal for uses to go to Forem.Api. You'll be able to find the latest version of the library here: https://www.nuget.org/packages/Forem.Api

Okay. thanks

playing with the library, I realized DI doesn't work. It doesn't return an instance of HttpClient instead null is returned.

sp.GetService<HttpClient>()

Yep - I saw that other issue which mentions the same thing, good pick up on the issue. Like I explained there, basically HttpClient is a dependency that the user would ideally configure. The GetService should actually be GetRequiredService for better exception handling rather than a NullPointerException.

You need a snippet like this in the DI root, it adds a HttpClient.

services.AddHttpClient();
services.AddTransient(provider =>
{
	//This is a workaround till .NET 5 which fixes the issue of no default HttpClient
	return provider.GetRequiredService<IHttpClientFactory>().CreateClient(string.Empty);
});

Cool. Thanks