-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
[ISSUE][1.2.1-preview.54] Some impediments using CLI version. Is not enough for my needs? #450
Comments
@smietanka Thanks for taking the time to report this
From v1.2.1 you can split the output into multiple files, but it's pretty primitive and can only split it into 3 files:
Technically, it's possible to split up the Refit interfaces into multiple files. I designed the system in a way that I should be able to easily.
I piggy-back on NSwag for parsing the OpenAPI spec and generating contracts. I get all contracts generated as a single string and I don't intend to analyze and break that single large string down into multiple files. If I can find a way to use NSwag to generate single contracts at a time then I will in the future add support for generating multiple files for the contracts
I haven't figured out a way to get NSwag to not disable warnings. This is common practice in code generators as they have to support multiple versions of the framework. Refitter (and NSwag) generates code that is compatible with .NET Framework 4.x -> .NET Standard 2.0 -> .NET Core 9.0 It's probably a personal thing, but I treat generated code like pulling in a third-party library and I don't care much about how to structure code that I didn't write. That said, the way I use Refitter is to generate "Client SDK's" for the API's that I build from the CI/CD platform that I use
Refitter purely looks at the OpenAPI spec and maps the details in I'm generally very open to pull requests so if you have ideas or things you want to add to Refitter that you think you can build yourself then I'll make sure that if you create a pull request we get your changes in 😄 |
Thanks for your response :) Yeah, splitting files for each client would be really useful not only for readability but also for git history, etc. Basically, all kinds of splitting contracts or interfaces into different files would really help with git history :)
Thanks I will try to check the code what could be changed here |
Hey, I just started working with Refitter a couple of days ago. It's a really cool tool, but it seems like a couple of options are not working as expected (or I am missing something), and I do have a problem with creating a proper configuration and parameters for the CLI command to generate contracts and interfaces.
So my case looks like this, I need to build interfaces and contracts after each build of project. I have an ASP.NET WebAPI with two controllers and some models, for now just as simple as possible. So I have created a "refitter.targets" file which I included inside the
.csproj
of my API. Inside targets I have couple<Exec command>
targets where I am callingdotnet tool restore
,dotnet tool update
and of course this commanddotnet refitter $(OpenApiDocumentation) -o $(RefitterOutputDirectory) -n $(ProjectName).Client --contracts-output $(RefitterContractsOutputDirectory) --contracts-namespace $(ProjectName).Contract --no-accept-headers --use-api-response --cancellation-tokens
As I mentioned I have 2 controllers named:
CoolController
andWeatherForecastController
RefitInterfaces.cs
andContracts.cs
but I would like to see multiple clients with proper names likeICoolClient
andIWeatherForecastClient
with methods that belong only to these specific controllers. I have used--multiple-interfaces ByTag
option and its looks pretty fine, but is there an option to split these interfaces into different files?Error.cs
,User.cs
, etc.Contracts.cs
I see a lot of disabled warnings. Is there a way to pass some kind of settings/configuration to the NSwag from Refitter?I really appreciate any help you can provide.
The text was updated successfully, but these errors were encountered: