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

Optional generation of abstract WebAPI controllers #884

Merged

Conversation

ma499
Copy link

@ma499 ma499 commented Aug 15, 2017

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.

@RicoSuter
Copy link
Owner

  • 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 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)
@gozdebozkurt
Copy link
Contributor

We done all changes. Could you have a look please?

@RicoSuter RicoSuter merged commit ec7c2f8 into RicoSuter:master Aug 16, 2017
RicoSuter added a commit that referenced this pull request Aug 16, 2017
@RicoSuter
Copy link
Owner

Why did you move if (Model.WrapResponses){#>using System.Net.Http; to the file template?

@gozdebozkurt
Copy link
Contributor

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.

RicoSuter added a commit that referenced this pull request Aug 16, 2017
@RicoSuter
Copy link
Owner

Ok, I think it is no longer used because we use full qualified types everywhere... (removed).

@RicoSuter
Copy link
Owner

Ok, everything looks good. Thanks for the PR.

@gozdebozkurt
Copy link
Contributor

Thank you for your quick reply and help

@gozdebozkurt
Copy link
Contributor

When can you release NSwag.MSBuild package ?
Thanks

@RicoSuter
Copy link
Owner

Please use the CI artifacts or CI nuget feed:

https://ci.appveyor.com/project/rsuter/nswag-25x6o/build/artifacts
https://www.myget.org/gallery/nswag-ci

I think a new version is released next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants