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

new concept #784

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

new concept #784

wants to merge 4 commits into from

Conversation

HauklandJ
Copy link
Contributor

@HauklandJ HauklandJ commented Sep 23, 2024

Description

This is a new solution, compare to #773.

Here we annotate controllers. This means we do not have to update all enums with an annotation and remember it for future enums, and do the same for enums from storage/platform.

The tradeoff is the scaffolding to make this happen.

See PartiesController for usage.

Related Issue(s)

  • #{issue number}

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

public void Configure(MvcOptions options)
{
var jsonOptions = _jsonOptions.Get(_jsonSettingsName);
var logger = _loggerFactory.CreateLogger<EnumAsNumberFormatter>();

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This assignment to
logger
is useless, since its value is never read.
}
}

internal class EnumToNumberJsonConverter<TEnum> : JsonConverter<TEnum>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a custom converter? Isn't number encoding the default?

@@ -21,6 +22,7 @@ namespace Altinn.App.Api.Controllers;
/// </summary>
[Authorize]
[ApiController]
[JsonSettingsName("EnumAsNumber")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the setting name should just be AltinnApis or something? Denoting that whatever settings are injected are what is required to make our own APIs stable?

Now maybe we should consider API conventions as well so that we don't have to remember this attribute everywhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants