-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Generate server side asp.net (c#) code? #1469
Comments
@bagusflyer currently we do not have server generator for C# (WebApi). Do you have cycle to help implement it based on other server generator (e.g. JAX-RS, Sinatra, PHP Silex, etc) ? |
Unfortunatly I have no time to contribute nowadays but I am joining the request. |
The beta version of the C# WebApi generator can be as simple as the following to start with:
Then we'll implement other methods (POST, PUT, DELETE) one by one. |
Also commenting on this to join the request. |
I discovered https://github.com/domaindrivendev/Swashbuckle |
@NahumLitvin I believe Swashbuckle is for generating OpenAPI/Swagger spec and integration with other Swagger components (e.g. swagger-ui). The request here is to generate the server stub in C# Web Api given an OpenAPI/Swagger spec. |
So what exactly are you looking for as a start? A complete ASP. net WebAPI project? I may be able to help with that. I came here looking for the capability as we are moving to a design first approach, and highly leverage WebAPI at the company I'm working at. |
@nin9creative thanks for offering help. Yes, ideally a ASP.net WebApi that implements the following endpoints to start with:
Then we will construct the mustache template based on that. |
@nin9creative @wing328 I've started on two examples using .net 4.5 and asp.net 5. https://github.com/jimschubert/webapi-swagger-samples |
@jimschubert I think that's what we need as a starting point 🍻 Are you working on the generator for WebApi as well? (just want to avoid duplicated efforts) I'm working on automatically generating test cases for C# API client so I won't have time until I finish that. |
There are still some things I need to work out. The one project is .net 4.5 because mono doesn't do 4.5.2 and I kept getting errors on 4.5.1 and 4.6. Even then, the project doesn't run correctly through xsp4. I was going to see if there's a Windows 10 IoT container I can use. If not, I figured a successful compile would be enough verification. I think the swagger attributes for the asp.net 5 project can just be pulled from the other source. To make them equivalent, I would need to set up Swagger to pull from xml comments. Then I was going to create an integration test project like I have here for the asp.net 5 verification tool. |
@wing328 to answer your other question, no I hadn't yet started on the generator stuff. |
@jimschubert that's ok :) whoever has cycle to start working on the webapi generator please reply to let the community know to avoid duplicated efforts. |
I have a little time today, I think I'll start on the ASP.NET 5 web api server generator. |
I've committed my work in progress. https://github.com/jimschubert/swagger-codegen/tree/csharp_webapi_aspnet5_server May not have a lot of time this week, but don't want the code to get lost/forgotten. |
To all, thanks to contribution from @jimschubert we now have server stub generator for ASP.NET5. Please pull the latest and give it a try. If you want to help improve the generator, please refer to #2024 for a list of open tasks that are pending community contribution. |
@jimschubert How much work would be required to get a ASP.NET WebAPI codegen working on the .NET 4.6 Framework? I am not familar with the codegen aspects, but see that you did implement another service stub in .NET for < ASP.NET 5. Our use cases here are more slanted towards enterprise web api's on the current .NET 4.6 framework and stack. |
I think it would be relatively easy to create a single Web API generator that could target .NET 4.5.2 and .NET 4.6. I think the csharp, aspnet5, and CsharpDotNet2 generators should probably be abstracted to a common base type before adding another one specifically for Web API. I was planning to work on that next so there's not a lot of duplicated code. The models for Web API in .NET 4.6 should be identical to those in ASP.NET 5. You could create an empty Web API project, then generate the models and controllers only.
This would get you pretty far. I think you'd need to change |
@jimschubert @andrewkrowczyk what about adding CLI options to so support .NET 4.5.2 and .NET 4.6 in the |
@wing328 I was also thinking about maybe renaming it to aspnet and supporting 4.x as libraries. |
I may have some time to help out this week if there are specifics that need work.... -------- Original Message -------- @wing328https://github.com/wing328 I was also thinking about maybe renaming it to aspnet and supporting 4.x as libraries. Reply to this email directly or view it on GitHubhttps://github.com//issues/1469#issuecomment-181679275. This email is for the use of the intended recipient(s) only. If you have received this email in error, please notify the sender immediately and then delete it. If you are not the intended recipient, you must not keep, use, disclose, copy or distribute this email without the author's prior permission. We have taken precautions to minimize the risk of transmitting software viruses, but we advise you to carry out your own virus checks on any attachment to this message. We cannot accept liability for any loss or damage caused by software viruses. The information contained in this communication may be confidential and may be subject to the attorney-client privilege. If you are the intended recipient and you do not wish to receive similar electronic messages from us in the future then please respond to the sender to this effect. |
@andrewkrowczyk if it's not too much work, can you please modify the existing PetStore ASP.NET server stub to make it work with .NET 4.5.2/.NET 4.6? Ref: https://github.com/swagger-api/swagger-codegen/tree/master/samples/server/petstore/aspnet5 Then we will have a better idea on what needs to be modified to make the generator works with different .NET frameworks and start the reverse engineering. |
Ok will take a look. @andrewkrowczyk if it's not too much work, can you please modify the existing PetStore ASP.NET server stub to make it work with .NET 4.5.2/.NET 4.6?Ref: https://github.com/swagger-api/swagger-codegen/tree/master/samples/server/petstore/aspnet5Then we will have a better idea on what needs to be modified to make the generator works with different .NET frameworks and start the reverse engineering.— |
@andrewkrowczyk if you're implementing these changes, please be aware of pull #2062 in which the file structure of edit: Sorry, I meant |
@andrewkrowczyk FYI. #20162 has been merged into master. Please pull the latest master and let us know if you've any questions. |
From what I see, the two solutions for generating ASPNET5 vs the earlier versions will be a bit different overall - especially around the .NET solution and project file. Also, at work I'm almost thinking that as a go forward approach we'd be better off targeting the new ASPNET5 project structure and framework. All that to say, maybe flushing out the ASPNET5 version first would be better for the long term... |
@jimschubert Your fork for swagger-codegen will support ASP.net server stub code generation? |
@zh-wowtv the ASP.NET generator has been merged into master. You can find it in the v2.2.0 stable release or the latest master. (there's also NancyFx generator that you may find useful) |
@wing328 Great. Thank you so much. |
@wing328 thanks to everyone involved in this. |
@bmarshalsea thanks :) Credits to @jimschubert who has done most of the work for the ASP.NET core generator. (I believe you're also aware of the NancyFX generator for C# developers) If you or your team has any questions on swagger codegen during the evaluation, please let us know by opening a ticket |
Just a quick question regarding the asp 4.5 support, was that ever merged in? I don't see the option and currently we can only generate .net core projects which is very limiting given it isn't compatible with any asp.net 4.X projects (for referencing). @jimschubert had an example of the pet store working with asp .net 4.5 and @wing328 recommended adding cli options to toggle between the different versions of asp.net but I don't see any of that documented here. |
@atbe We decided to include only ASP.NET Core as a server generator. This was mostly because I thought maintaining non-core would be more difficult (MVC, Web Forms, and WebAPI). Core standardizes on things like DI and tooling, and supports the inclusion of .NET Framework artifacts (see https://docs.microsoft.com/en-us/dotnet/standard/net-standard). Would a configurable .NET Standard version allow you to consume those artifacts in .NET Core, or do you specifically need that additional Web framework support? |
I'm wondering if it's possible to generate server side asp.net code based on the swagger json or yaml file? Thanks.
The text was updated successfully, but these errors were encountered: