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] No stub generated if derived interface does not contain Refit methods #1019

Closed
daangruijters opened this issue Jan 8, 2021 · 4 comments · Fixed by #1035
Closed

[BUG] No stub generated if derived interface does not contain Refit methods #1019

daangruijters opened this issue Jan 8, 2021 · 4 comments · Fixed by #1035
Labels

Comments

@daangruijters
Copy link

Describe the bug
Refit does not recognize derived interfaces as a Refit-interface, if the derived interface does not contain methods decorated with a Refit attribute.

Steps To Reproduce

  1. Create a generic Refit-interface, for example:
public interface ICrudOperations<TEntity> where TEntity : class    
{
    [Delete("/{id}")]
    Task<IActionResult> Delete(long id);

    [Get("")]
    Task<TEntity> Get(long id);

    [Get("")]
    Task<IEnumerable<TEntity>> GetAll();

    [Post("")]
    Task<TEntity> Create(TEntity dto);

    [Put("/{id}")]
    Task<IActionResult> Update(long id, TEntity dto);
}
  1. Now create another interface that inherits from this interface:
public interface IOrdersAPI : ICrudOperations<Order>
{
}
  1. Now create a client based on the second interface:

RestService.For<IOrdersAPI>(url);

Refit will throw an exception because it does not recognize 'IOrdersAPI' as a Refit-interface.

Expected behavior
Stub will be generated, even if the derived interface does not specify any Refit methods itself.

@clairernovotny
Copy link
Member

Should be fixed by the latest code in main. The next 6.0 preview should have the fix, can you please verify with that?

@clairernovotny
Copy link
Member

Actually realized it's won't work yet. The generator is looking for methods with and won't see derived types.

@daangruijters
Copy link
Author

Tested and works like a charm, thank you!

@github-actions
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 Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants