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

Use of constants in HTTP attributes does not generate proxies #602

Closed
knightmeister opened this issue Feb 3, 2019 · 6 comments
Closed
Labels
enhancement semantic-analysis Bug reports/change requests that would require semantic analysis in the stub generator up-for-grabs

Comments

@knightmeister
Copy link

Might be related to #263, however the error and use case are different.

I have the base address (i.e. RoutePrefix) for my API controllers defined in a constants file. I was trying to consume the Refit API from UWP and was getting the error message:

'IUserApiV1 doesn't look like a Refit interface. Make sure it has at least one method with a Refit HTTP method attribute and Refit is installed in the project.'

I created a simple project and noticed I got the autogenerated class in ILSpy. I then started trying to reproduce to work out why it wasn't being added.

It turns out that defining the value like this:

    [Post(SharedConstants.__USER_API_ROUTE + "/authenticate")]
    Task<AuthenticateResponse> Authenticate([Body] AuthenticateRequest request);

Refit will not find the interface. If I remove the constant, it then correctly discovers the interface and builds the proxy.

@bauca
Copy link

bauca commented Feb 14, 2019

Same problem here! This feature is a nice to have, it would save a lot of work in the future for those who have a lot of endpoints mapped through a string literal instead of a const.

@clairernovotny
Copy link
Member

This is the same as #263 and would require significant work in the parser to support. I'd accept a PR if someone wants to undertake that work.

This comment still stands: #263 (comment)

@bauca
Copy link

bauca commented Feb 21, 2019

Ok, @onovotny is there any start point where I could take a look to investigate the problem? I would like to see how much work would it require so I could see if I can accomplish it in my free time :)

@bennor bennor added the semantic-analysis Bug reports/change requests that would require semantic analysis in the stub generator label Jun 11, 2019
@clairernovotny
Copy link
Member

Should be implemented in #1029

@clairernovotny
Copy link
Member

Please try v6.0-preview.84 and file bugs as you come across them.

@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
enhancement semantic-analysis Bug reports/change requests that would require semantic analysis in the stub generator up-for-grabs
Projects
None yet
Development

No branches or pull requests

4 participants