Git Product home page Git Product logo

Comments (8)

christianhelle avatar christianhelle commented on August 22, 2024

@kirides This is trivial to implement and I can get started with this immediately. Unless you want to give it a shot yourself?

from refitter.

kirides avatar kirides commented on August 22, 2024

We're currently in the evaluation phase of deciding to use this tool to generate our clients, sadly i can't provide an implementation at this stage... bureaucracy

from refitter.

christianhelle avatar christianhelle commented on August 22, 2024

I'm currently trying this out and I can see that Refit doesn't seem to like CancellationToken cancellationToken = default

I generated this code

[Get("/pet/{petId}")]
Task<Pet> GetPetById(long petId, CancellationToken cancellationToken = default);

But when I run it I just get a Make sure it has at least one method with a Refit HTTP method attribute and Refit is installed in the project. error when I run the generated code

Unhandled exception. System.InvalidOperationException: ISwaggerPetstore 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.
   at Refit.RestService.GetGeneratedType(Type refitInterfaceType) in /_/Refit/RestService.cs:line 173
   at Refit.RestService.For(Type refitInterfaceType, HttpClient client, IRequestBuilder builder) in /_/Refit/RestService.cs:line 76
   at Refit.RestService.For[T](HttpClient client, IRequestBuilder`1 builder) in /_/Refit/RestService.cs:line 20
   at Refit.RestService.For[T](HttpClient client, RefitSettings settings) in /_/Refit/RestService.cs:line 34
   at Refit.RestService.For[T](String hostUrl, RefitSettings settings) in /_/Refit/RestService.cs:line 54
   at Refit.RestService.For[T](String hostUrl) in /_/Refit/RestService.cs:line 65
   at MyNamespace.Program.TestPetstoreUsingDirectTypes() in C:\projects\christianhelle\refitter\test\ConsoleApp\Program.cs:line 34
   at MyNamespace.Program.Main(String[] args) in C:\projects\christianhelle\refitter\test\ConsoleApp\Program.cs:line 11
   at MyNamespace.Program.<Main>(String[] args)

I'm investigating as why this is

from refitter.

kirides avatar kirides commented on August 22, 2024

Sounds interesting, manually specifying it in a .NET 6.0 project works fine.

Here is the code from refit that checks for its existence (many places call that, and other chains also check for its existence)
https://github.com/reactiveui/refit/blob/ef463956936fcdfd248d120672fe0bb7ff93d5ac/Refit/RequestBuilderImplementation.cs#L474

from refitter.

christianhelle avatar christianhelle commented on August 22, 2024

@kirides did you get the interface containing a CancellationToken in the arguments to work? I have no luck with this. I already have the code for generating an interface that uses CancellationToken as the last argument but I can't get the interface to work

from refitter.

kirides avatar kirides commented on August 22, 2024

Using Refit 6.0.1 & 6.3.2 this works flawlessly:
(Cancellation also works like it should)

image

from refitter.

christianhelle avatar christianhelle commented on August 22, 2024

@kirides I honestly couldn't get CancellationToken to work, but if your example works then I trust you on that. Generating code that uses CancellationTokens was trivial to implement and I expect to release this feature this in the afternoon

from refitter.

christianhelle avatar christianhelle commented on August 22, 2024

This feature is now released as v0.5.0

from refitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.