Csharp Code

At the following page you can take a look at the generated code, the code is based on this TypeAPI specification. This is only a demo to give you a first insight, for live examples feel free to login at the backend and use the live generator.

Client.cs

/**
 * Client automatically generated by SDKgen please do not edit this file manually
 * @see https://sdkgen.app
 */


using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using RestSharp;
using Sdkgen.Client;
using Sdkgen.Client.Credentials;
using Sdkgen.Client.Exception;


public class Client : ClientAbstract
{
    public Client(string baseUrl, ICredentials credentials) : base(baseUrl, credentials)
    {
    }

    public TestTag Test()
    {
        return new TestTag(
            this.HttpClient,
            this.Parser
        );
    }




    public static Client BuildAnonymous(string baseUrl)
    {
        return new Client(baseUrl, new Anonymous());
    }
}

Error.cs

/**
 * Error automatically generated by SDKgen please do not edit this file manually
 * @see https://sdkgen.app
 */

using System.Text.Json.Serialization;

public class Error
{
    [JsonPropertyName("success")]
    public bool? Success { get; set; }

    [JsonPropertyName("message")]
    public string? Message { get; set; }

}

ErrorException.cs

/**
 * ErrorException automatically generated by SDKgen please do not edit this file manually
 * @see https://sdkgen.app
 */


using Sdkgen.Client.Exception;


public class ErrorException : KnownStatusCodeException
{
    public Error Payload;

    public ErrorException(Error payload)
    {
        this.Payload = payload;
    }
}

HelloWorld.cs

/**
 * HelloWorld automatically generated by SDKgen please do not edit this file manually
 * @see https://sdkgen.app
 */

using System.Text.Json.Serialization;

public class HelloWorld
{
    [JsonPropertyName("message")]
    public string? Message { get; set; }

}

Response.cs

/**
 * Response automatically generated by SDKgen please do not edit this file manually
 * @see https://sdkgen.app
 */

using System.Text.Json.Serialization;

public class Response
{
    [JsonPropertyName("success")]
    public bool? Success { get; set; }

    [JsonPropertyName("message")]
    public string? Message { get; set; }

}

TestTag.cs

/**
 * TestTag automatically generated by SDKgen please do not edit this file manually
 * @see https://sdkgen.app
 */


using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using RestSharp;
using Sdkgen.Client;
using Sdkgen.Client.Exception;


public class TestTag : TagAbstract {
    public TestTag(RestClient httpClient, Parser parser): base(httpClient, parser)
    {
    }


    /**
     * Returns a hello world message
     */
    public async Task<HelloWorld> GetHello()
    {
        Dictionary<string, object> pathParams = new();

        Dictionary<string, object> queryParams = new();

        List<string> queryStructNames = new();

        RestRequest request = new(this.Parser.Url("/hello/world", pathParams), Method.Get);
        this.Parser.Query(request, queryParams, queryStructNames);


        RestResponse response = await this.HttpClient.ExecuteAsync(request);

        if (response.IsSuccessful)
        {
            var data = this.Parser.Parse<HelloWorld>(response.Content);

            return data;
        }

        var statusCode = (int) response.StatusCode;
        throw new UnknownStatusCodeException("The server returned an unknown status code: " + statusCode);
    }
    /**
     * Returns available todo entries
     */
    public async Task<Todos> GetEntries(int startIndex, int count)
    {
        Dictionary<string, object> pathParams = new();

        Dictionary<string, object> queryParams = new();
        queryParams.Add("startIndex", startIndex);
        queryParams.Add("count", count);

        List<string> queryStructNames = new();

        RestRequest request = new(this.Parser.Url("/todo", pathParams), Method.Get);
        this.Parser.Query(request, queryParams, queryStructNames);


        RestResponse response = await this.HttpClient.ExecuteAsync(request);

        if (response.IsSuccessful)
        {
            var data = this.Parser.Parse<Todos>(response.Content);

            return data;
        }

        var statusCode = (int) response.StatusCode;
        throw new UnknownStatusCodeException("The server returned an unknown status code: " + statusCode);
    }
    /**
     * Inserts a new todo entry
     */
    public async Task<Response> Insert(Todo payload)
    {
        Dictionary<string, object> pathParams = new();

        Dictionary<string, object> queryParams = new();

        List<string> queryStructNames = new();

        RestRequest request = new(this.Parser.Url("/todo", pathParams), Method.Post);
        this.Parser.Query(request, queryParams, queryStructNames);
        request.AddJsonBody(JsonSerializer.Serialize(payload));

        request.AddOrUpdateHeader("Content-Type", "application/json");

        RestResponse response = await this.HttpClient.ExecuteAsync(request);

        if (response.IsSuccessful)
        {
            var data = this.Parser.Parse<Response>(response.Content);

            return data;
        }

        var statusCode = (int) response.StatusCode;
        throw new UnknownStatusCodeException("The server returned an unknown status code: " + statusCode);
    }
    /**
     * Returns a hello world message
     */
    public async Task<HelloWorld> ThrowException()
    {
        Dictionary<string, object> pathParams = new();

        Dictionary<string, object> queryParams = new();

        List<string> queryStructNames = new();

        RestRequest request = new(this.Parser.Url("/exception", pathParams), Method.Get);
        this.Parser.Query(request, queryParams, queryStructNames);


        RestResponse response = await this.HttpClient.ExecuteAsync(request);

        if (response.IsSuccessful)
        {
            var data = this.Parser.Parse<HelloWorld>(response.Content);

            return data;
        }

        var statusCode = (int) response.StatusCode;
        if (statusCode == 500)
        {
            var data = this.Parser.Parse<Error>(response.Content);

            throw new ErrorException(data);
        }

        throw new UnknownStatusCodeException("The server returned an unknown status code: " + statusCode);
    }


}

Todo.cs

/**
 * Todo automatically generated by SDKgen please do not edit this file manually
 * @see https://sdkgen.app
 */

using System.Text.Json.Serialization;

public class Todo
{
    [JsonPropertyName("title")]
    public string? Title { get; set; }

}

Todos.cs

/**
 * Todos automatically generated by SDKgen please do not edit this file manually
 * @see https://sdkgen.app
 */

using System.Text.Json.Serialization;

public class Todos
{
    [JsonPropertyName("totalResults")]
    public int? TotalResults { get; set; }

    [JsonPropertyName("startIndex")]
    public int? StartIndex { get; set; }

    [JsonPropertyName("itemsPerPage")]
    public int? ItemsPerPage { get; set; }

    [JsonPropertyName("entry")]
    public System.Collections.Generic.List<Todo>? Entry { get; set; }

}

part of the Apioo-Project