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

[BUG] Inherited interface level Headers attribute does not work #1027

Closed
jmichas opened this issue Jan 21, 2021 · 3 comments
Closed

[BUG] Inherited interface level Headers attribute does not work #1027

jmichas opened this issue Jan 21, 2021 · 3 comments
Labels

Comments

@jmichas
Copy link

jmichas commented Jan 21, 2021

Describe the bug
Headers attribute placed at the interface level of an inherited interface does not work.
For instance if you have

public interface IWebApi : IAccountApi
{
   void Foo(); //hack to make api not error when using only inherited methods
}

[Headers("Authorization: Bearer")]
public interface IAccountApi
{
   Task GetUserAccountBalance(string userId);
}

causes my integration tests that use the refit client to hang with no error or crash with no details.

Moving the [Headers()] to the method level works.

public interface IAccountApi
{
   [Headers("Authorization: Bearer")]
   Task GetUserAccountBalance(string userId);
}

The workaround is completely fine, but in the case where you want to use authorization for a lot of methods and or something like a version header where you would want the entire interface to use the same version, it becomes cumbersome.

Expected behavior
You would expect that the Headers attribute wouldn't cause the dotnet process to crash and or hang.

Screenshots

Environment

  • OS: MacOS 10.15.7
  • Visual Studio Mac 8.8.5
  • Asp.Net Core API v3.1

Additional context
My refit api interfaces are in a separate project so they can be shared between integration tests and my mobile client.

@jmichas jmichas added the bug label Jan 21, 2021
clairernovotny added a commit that referenced this issue Jan 24, 2021
@clairernovotny
Copy link
Member

Do you have a repro? I added tests for this scenario and they pass:

9e5260e

@ChrisPulman
Copy link
Member

Issue notified as resolved.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants