Comments (8)
@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.
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.
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.
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.
@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.
Using Refit 6.0.1
& 6.3.2
this works flawlessly:
(Cancellation also works like it should)
from refitter.
@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.
This feature is now released as v0.5.0
from refitter.
Related Issues (20)
- Hyphens with JsonStringEnumConverter results in `JSON value could not be converted` HOT 7
- Response is always nullable under `generateNullableReferenceTypes` HOT 2
- Source generator does not work in .Net 8 HOT 1
- Support for OpenAPI version 3.1.0 HOT 2
- Non string/boolean CodeGeneratorSettings are not honored HOT 3
- Generate the client from multiple versions HOT 1
- `remove-unused-schema` not working for collection-type responses HOT 1
- Asana API "cannot derive from sealed type" HOT 4
- Code Generator creates unsafe interface method names HOT 1
- Code Generator adds numeric suffix to Interface method name when not needed HOT 3
- Add the facility to exclude namespaces from generated code HOT 5
- Asana API specs strange naming HOT 2
- Refit Fails on Jira OpenAPI specs HOT 5
- Serializer improvements HOT 1
- All Contributors Bot HOT 12
- Polly.Extensions.Http deprecated in favour of Microsoft.Extensions.Http.Resilience HOT 3
- Support generating immutable records HOT 8
- AnyType + BodySerializationMethod HOT 4
- Support generating multiple files HOT 2
- Support custom format-mappings via Key-Value configuration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from refitter.