Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2021.09 improvements #7

Open
7 tasks
gkama opened this issue Sep 29, 2021 · 0 comments
Open
7 tasks

2021.09 improvements #7

gkama opened this issue Sep 29, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed kamafi core kamafi-core libraries

Comments

@gkama
Copy link
Member

gkama commented Sep 29, 2021

General improvements

kamafi.core.data

  • Add Roles to Constants.cs. Admin, etc.
  • To camel case extension method. public static string ToCamelCase(this string s) (Source kamafi-liability)
  • Remove white spaces extension method. public static string RemoveWhitespace(this string s) (Source kamafi-liability)
  • Add FluentValidation camel case resolved CamelCasePropertyNameResolver (Source kamafi-liability)

kamafi.core.middleware

Improvements for the middleware package

OpenApi

  • Add support to take in string[] ApiSupportedVersions. Example is as follows
public static string[] ApiSupportedVersions
    => new string[]
    {
        "v1.0"
    };
  • Add support to take in optional DefaultUnsupportedApiVersionMessage

Example of a message

public static string DefaultUnsupportedApiVersionMessage = $"Unsupported API version specified. The supported versions are {string.Join(", ", ApiSupportedVersions)}";

This (DefaultUnsupportedApiVersionMessage) needs to be replaced in the following middleware (which is being called by the Versioning one)

public class ApiVersioningErrorResponseProvider : DefaultErrorResponseProvider
{
    public override IActionResult CreateResponse(ErrorResponseContext context)
    {
        var problem = new KamafiProblemDetailBase
        {
            Code = StatusCodes.Status400BadRequest,
            Message = Constants.DefaultUnsupportedApiVersionMessage
        };

        return new ObjectResult(problem)
        {
            StatusCode = StatusCodes.Status400BadRequest
        };
    }
}

The solution would be to add more optional configuration in KamafiConfiguration object. Then pass down the configuration to the ApiVersioningErrorResponseProvider. The message will be inherited from the ApiSupportedVersions string array

public class KamafiConfiguration : IKamafiConfiguration
{
    public IConfiguration Config { get; set; }
    public string OpenApiName { get; set; }
    public string OpenApiVersion { get; set; }
    public string DefaultApiVersion { get; set; }
    public string XmlCommentsPath { get; set; }

    // Something along the lines of
    public string[] ApiSupportedVersions { get; set; } = null;
}

Eventing

  • Rename AddEventingRestClient to AddKamafiEventingRestClient
@gkama gkama added enhancement New feature or request kamafi core kamafi-core libraries labels Sep 29, 2021
@gkama gkama self-assigned this Sep 29, 2021
@gkama gkama added good first issue Good for newcomers help wanted Extra attention is needed labels Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed kamafi core kamafi-core libraries
Projects
None yet
Development

No branches or pull requests

1 participant