-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Optional generation of abstract WebAPI controllers #884
Optional generation of abstract WebAPI controllers #884
Conversation
…from ControllerTemplate
…nd GenerateAbstractController setting is added + created new test classes
…faces and GenerateAbstractController setting is added
…are deleted. ControllerGenerationFormat parameter is added. (default:partial)Test classes are deleted and new test class is added.
|
We should call the setting ControllerStyle and use an enum ControllerStyle (Partial/Abstract) Move the setting from SwaggerToCSharpGeneratorSettings to SwaggerToCSharpWebApiControllerGeneratorSettings Please create properties on the template model (GeneratePartialControllers/GenerateAbstractControllers) instead of inline in the template (this way we can better move to another template engine later)
We done all changes. Could you have a look please? |
Why did you move |
Because in the old case the using System.Net.Http was added to every controller class. (in controller template) and generated code was wrong. So I moved it like the using additional namespaces. |
Ok, I think it is no longer used because we use full qualified types everywhere... (removed). |
Ok, everything looks good. Thanks for the PR. |
Thank you for your quick reply and help |
When can you release NSwag.MSBuild package ? |
Please use the CI artifacts or CI nuget feed: https://ci.appveyor.com/project/rsuter/nswag-25x6o/build/artifacts I think a new version is released next week |
Implementation of solution discussed for #870
Optional parameter to control the output format of generated Web API controllers. The default continues to be output of partial classes and interfaces. The optional parameter enables output of abstract controllers.
We made a small change to what was discussed in the issue: instead of having two boolean switches for emitting abstract classes or interfaces, we decided to have a single parameter called 'ControllerGenerationFormat' which currently supports the values 'partial' (default) and 'abstract'. Two reasons: 1) It could be extended in future to support other generation approaches. 2) We thought having lots of booleans would allow specification of undesired options. We didn't see, for example, why anyone would want to generate an interface for an abstract class and saw no reason to support this.
The motivation is to be able to design web services 'contract-first' from a swagger specification with the controller 'skeleton' auto-generated at build-time. This means that only the controller implementation (and the swagger specification) need to be committed to source.