Skip to content

Instantly share code, notes, and snippets.

View babula38's full-sized avatar
🏠
Working from home

Babula babula38

🏠
Working from home
View GitHub Profile

Declare enum in Swagger openAPI Schema via C# code

Schema = new OpenApiSchema
                  {
                      Type = "integer",
                      Enum = typeof(MyEnumType).GetEnumValues()
                                               .Cast<int>()
                                               .Select(value => (Microsoft.OpenApi.Any.IOpenApiAny)new Microsoft.OpenApi.Any.OpenApiInteger(value))
                                               .ToList()
                  }
@babula38
babula38 / HttpClientLoggingExtension.md
Created March 9, 2022 07:29
Extension method to log HttpClient Request as Raw string.
public static class HttpClientExtensions
{
    public static async Task<string> ToRawString(this HttpRequestMessage request)
    {
        var sb = new StringBuilder();

        var line1 = $"{request.Method} {request.RequestUri} HTTP/{request.Version}";
        sb.AppendLine(line1);
@babula38
babula38 / Handy-tools
Created June 3, 2021 05:24
Handy-tools
### Quick api to test http
https://httpbin.org/
https://httpstat.us/500
@babula38
babula38 / Handy-Git-Commands.md
Last active July 21, 2022 08:12
Handy-Git-Commands

WARNING: git clean deletes all your untracked files/directories and can't be undone.

Sometimes just clean -f does not help. In case you have untracked DIRECTORIES, -d option also needed:

WARNING: this can't be undone!

git reset --hard HEAD git clean -f -d git pull