Skip to content

[REQ] New ASP.NET Core 3.0 server generator #2350

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

Closed
wing328 opened this issue Mar 10, 2019 · 18 comments
Closed

[REQ] New ASP.NET Core 3.0 server generator #2350

wing328 opened this issue Mar 10, 2019 · 18 comments

Comments

@wing328
Copy link
Member

wing328 commented Mar 10, 2019

To start with, we'll need to create the following:

  • new AspNetCore3ServerCodegen.java based on AspNetCoreServerCodegen.java
  • new resource folder modules/openapi-generator/src/main/resources/aspnetcore3 based on modules/openapi-generator/src/main/resources/aspnetcore (2.0 or 2.1)
  • add batch file to generate Petstore samples under samples/server/petstore/aspnetcore3

cc @SeanFarrow

@SeanFarrow
Copy link
Contributor

SeanFarrow commented Mar 10, 2019 via email

@A-Joshi
Copy link
Contributor

A-Joshi commented Mar 20, 2019

@SeanFarrow
Have been slowly adding in library and other support for the aspnetcore generator particularly for 2.2 and happy to collaborate for 3.0.

@etherealjoy
Copy link
Contributor

etherealjoy commented Mar 20, 2019

I am interested in ASP.NET Core 3.0 and I have lots of manual things that I do with the 2.1 generator and I would really like a clean sheet .NET Core 3 including clients and

Some features I would be interested/suggesting

  • DI mechanism to leave generated code untouched
  • Microsoft's json parser instead of json.NET

@A-Joshi
Copy link
Contributor

A-Joshi commented Mar 21, 2019 via email

@wing328
Copy link
Member Author

wing328 commented Mar 30, 2019

Discussions related to authentication support: #2352

@etherealjoy
Copy link
Contributor

Which generator should we base this from , current asp.net core?

@A-Joshi
Copy link
Contributor

A-Joshi commented Apr 17, 2019

Based on what I seen so far Migrate from ASP.NET Core 2.2 to 3.0 Preview 2 it might not be that difficult to simply extend the current current generator for one more version.

Particularly for the library and other classes. There's more in common than different, and there are some features that I am looking at for the current generator (e.g. Roslyn) that would be simpler to add in one place.

@etherealjoy - can you summarize the manual changes that you have to do to go from 2.1 to 3.0?

@etherealjoy
Copy link
Contributor

etherealjoy commented Apr 18, 2019

I did these

  • update TFM
  • Change The Configure services
  • Add Json.NET manually
  • Adapt Configure services and Configure due to change in hosting environment and Json.NET
  • Update package versions
  • Add nuget config

Additionally I was wondering if we use Json.NET or use MS internal Json package
Nice to have would be the DI mechanism to inject the API handlers instead of manually editing the HomeController. This is tedious everytime we generate code due to API update.
What I usually do is keep the Handler is another project and import them in Home controller

@A-Joshi
Copy link
Contributor

A-Joshi commented Apr 18, 2019

@etherealjoy it might be simpler to adopt the approach of using the generator to generate an abstract class and have the server implement it. I am waiting for #2629 to be merged and will be able to provide more concrete examples.

@etherealjoy
Copy link
Contributor

Additionally using current aspnetcore generator I had to rearrange the layout of the folders and update the base images to point to mcr

@A-Joshi
Copy link
Contributor

A-Joshi commented Apr 19, 2019

@etherealjoy might be helpful if you can create a simple example with the generated original code and the modified to work with 3.0 code.

@SeanFarrow
Copy link
Contributor

I'm now starting to look at Asp.Net core 3.0 and I would not recommend just upgrading the current generator as is as things like routing have changed. Also, for backwarrd compatibility, we will need to support Json.Net which has been removed in 3.0, but is still opt-in.

I'm currently working on the Asp.net Core 2.x authorization/authentication support to ensure we support all security schemes in OAS v3, but can then look at this in more detail.

Finally, asp.net core is still in preview, so to my thinking there really isn't any rush.

@etherealjoy
Copy link
Contributor

The most important thing for me why I am working with .NET Core 3.0 already is official support for Linux arm64.
Upcoming feature in .NET Core 3.0, single file bundle makes it easier for deployment and deploying in Linux containers is a breeze. Pretty much like Go

But lets wait for MS Build and see

I believe the ASP.NET Core 3.0 would be better off being a new generator.
Regarding JSON.NET I think we can discuss if we start using MS JSON Parser instead or continue with it.

@A-Joshi
Copy link
Contributor

A-Joshi commented May 5, 2019

@etherealjoy @SeanFarrow I have it creating properly with 3.0 preview4: routing is still old and uses newtonsoft. Will put in the PR for it in a day or two (need to clean up the generator so the 2.2 break introduced is fixed).

For the new features I suspect it will not be too difficult to extend.

However I still hold that generating the server code is probably not the best approach - it will be better to use the generator to generate an abstract class, and then have the server implement an abstract class. I am documenting the approach - it leads to a better roundtrip for the server side development.

@SeanFarrow
Copy link
Contributor

SeanFarrow commented May 5, 2019 via email

@A-Joshi
Copy link
Contributor

A-Joshi commented May 5, 2019

@SeanFarrow - you can look at https://github.com/ihsmarkitoss/openapi-generator/tree/feature/version3 - still missing a little cleanup. but generally works if you set aspnetCoreVersion = 3.0 in thepom.xml

From the branch 2.2 and 2.1 will beak (I know the issue but need to fix it)

@A-Joshi
Copy link
Contributor

A-Joshi commented May 5, 2019

I have submitted the preliminary support changes in the PR #2824

@wing328
Copy link
Member Author

wing328 commented Aug 10, 2019

Closed via #2824

@wing328 wing328 closed this as completed Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants