@@ -69,8 +69,8 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
6969 private boolean useSwashbuckle = true ;
7070 protected int serverPort = 8080 ;
7171 protected String serverHost = "0.0.0.0" ;
72- protected CliOption swashbuckleVersion = new CliOption (SWASHBUCKLE_VERSION , "Swashbuckle version: 3.0.0, 4.0.0, 5.0.0" );
73- protected CliOption aspnetCoreVersion = new CliOption (ASPNET_CORE_VERSION , "ASP.NET Core version: 5.0, 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)" );
72+ protected CliOption swashbuckleVersion = new CliOption (SWASHBUCKLE_VERSION , "Swashbuckle version: 3.0.0, 4.0.0, 5.0.0, 6.0.0 " );
73+ protected CliOption aspnetCoreVersion = new CliOption (ASPNET_CORE_VERSION , "ASP.NET Core version: 6.0, 5.0, 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)" );
7474 private CliOption classModifier = new CliOption (CLASS_MODIFIER , "Class Modifier for controller classes: Empty string or abstract." );
7575 private CliOption operationModifier = new CliOption (OPERATION_MODIFIER , "Operation Modifier can be virtual or abstract" );
7676 private CliOption modelClassModifier = new CliOption (MODEL_CLASS_MODIFIER , "Model Class Modifier can be nothing or partial" );
@@ -197,13 +197,15 @@ public AspNetCoreServerCodegen() {
197197 aspnetCoreVersion .addEnum ("3.0" , "ASP.NET Core 3.0" );
198198 aspnetCoreVersion .addEnum ("3.1" , "ASP.NET Core 3.1" );
199199 aspnetCoreVersion .addEnum ("5.0" , "ASP.NET Core 5.0" );
200+ aspnetCoreVersion .addEnum ("6.0" , "ASP.NET Core 6.0" );
200201 aspnetCoreVersion .setDefault ("3.1" );
201202 aspnetCoreVersion .setOptValue (aspnetCoreVersion .getDefault ());
202203 cliOptions .add (aspnetCoreVersion );
203204
204205 swashbuckleVersion .addEnum ("3.0.0" , "Swashbuckle 3.0.0" );
205206 swashbuckleVersion .addEnum ("4.0.0" , "Swashbuckle 4.0.0" );
206207 swashbuckleVersion .addEnum ("5.0.0" , "Swashbuckle 5.0.0" );
208+ swashbuckleVersion .addEnum ("6.0.0" , "Swashbuckle 6.0.0" );
207209 swashbuckleVersion .setDefault ("3.0.0" );
208210 swashbuckleVersion .setOptValue (swashbuckleVersion .getDefault ());
209211 cliOptions .add (swashbuckleVersion );
@@ -378,7 +380,7 @@ public void processOpts() {
378380 supportingFiles .add (new SupportingFile ("gitignore" , packageFolder , ".gitignore" ));
379381 supportingFiles .add (new SupportingFile ("validateModel.mustache" , packageFolder + File .separator + "Attributes" , "ValidateModelStateAttribute.cs" ));
380382 supportingFiles .add (new SupportingFile ("typeConverter.mustache" , packageFolder + File .separator + "Converters" , "CustomEnumConverter.cs" ));
381- if (aspnetCoreVersion .getOptValue ().startsWith ("3." ) || aspnetCoreVersion .getOptValue ().startsWith ("5.0" )) {
383+ if (aspnetCoreVersion .getOptValue ().startsWith ("3." ) || aspnetCoreVersion .getOptValue ().startsWith ("5.0" ) || aspnetCoreVersion . getOptValue (). startsWith ( "6." ) ) {
382384 supportingFiles .add (new SupportingFile ("OpenApi" + File .separator + "TypeExtensions.mustache" , packageFolder + File .separator + "OpenApi" , "TypeExtensions.cs" ));
383385 }
384386 supportingFiles .add (new SupportingFile ("Project.csproj.mustache" , packageFolder , packageName + ".csproj" ));
@@ -610,7 +612,7 @@ private void setBuildTarget() {
610612 private void setAspnetCoreVersion (String packageFolder ) {
611613 setCliOption (aspnetCoreVersion );
612614
613- if (aspnetCoreVersion .getOptValue ().startsWith ("3." ) || aspnetCoreVersion .getOptValue ().startsWith ("5.0" )) {
615+ if (aspnetCoreVersion .getOptValue ().startsWith ("3." ) || aspnetCoreVersion .getOptValue ().startsWith ("5.0" ) || aspnetCoreVersion . getOptValue (). startsWith ( "6." ) ) {
614616 compatibilityVersion = null ;
615617 } else if ("2.0" .equals (aspnetCoreVersion .getOptValue ())) {
616618 compatibilityVersion = null ;
@@ -627,6 +629,7 @@ private void setAspnetCoreVersion(String packageFolder) {
627629
628630 private String determineTemplateVersion (String frameworkVersion ) {
629631 switch (frameworkVersion ) {
632+ case "6.0" :
630633 case "5.0" :
631634 case "3.1" :
632635 return "3.0" ;
@@ -679,6 +682,13 @@ private void setIsFramework() {
679682 useFrameworkReference = true ;
680683 additionalProperties .put (USE_FRAMEWORK_REFERENCE , useFrameworkReference );
681684 additionalProperties .put (TARGET_FRAMEWORK , "net5.0" );
685+ } else if (aspnetCoreVersion .getOptValue ().startsWith ("6." )) {
686+ LOGGER .warn (
687+ "ASP.NET core version is {} so changing to use frameworkReference instead of packageReference " ,
688+ aspnetCoreVersion .getOptValue ());
689+ useFrameworkReference = true ;
690+ additionalProperties .put (USE_FRAMEWORK_REFERENCE , useFrameworkReference );
691+ additionalProperties .put (TARGET_FRAMEWORK , "net6.0" );
682692 } else {
683693 if (additionalProperties .containsKey (USE_FRAMEWORK_REFERENCE )) {
684694 useFrameworkReference = convertPropertyToBooleanAndWriteBack (USE_FRAMEWORK_REFERENCE );
@@ -705,7 +715,7 @@ private void setUseNewtonsoft() {
705715 }
706716
707717 private void setUseEndpointRouting () {
708- if (aspnetCoreVersion .getOptValue ().startsWith ("3." ) || aspnetCoreVersion .getOptValue ().startsWith ("5." )) {
718+ if (aspnetCoreVersion .getOptValue ().startsWith ("3." ) || aspnetCoreVersion .getOptValue ().startsWith ("5." ) || aspnetCoreVersion . getOptValue (). startsWith ( "6." ) ) {
709719 LOGGER .warn ("ASP.NET core version is {} so switching to old style endpoint routing." , aspnetCoreVersion .getOptValue ());
710720 useDefaultRouting = false ;
711721 additionalProperties .put (USE_DEFAULT_ROUTING , useDefaultRouting );
@@ -725,7 +735,13 @@ private void setSwashbuckleVersion() {
725735 LOGGER .warn ("ASP.NET core version is {} so changing default Swashbuckle version to 5.0.0." , aspnetCoreVersion .getOptValue ());
726736 swashbuckleVersion .setOptValue ("5.0.0" );
727737 additionalProperties .put (SWASHBUCKLE_VERSION , swashbuckleVersion .getOptValue ());
728- } else {
738+ }
739+ else if (aspnetCoreVersion .getOptValue ().startsWith ("6." )) {
740+ LOGGER .warn ("ASP.NET core version is {} so changing default Swashbuckle version to 6.0.0." , aspnetCoreVersion .getOptValue ());
741+ swashbuckleVersion .setOptValue ("6.0.0" );
742+ additionalProperties .put (SWASHBUCKLE_VERSION , swashbuckleVersion .getOptValue ());
743+ }
744+ else {
729745 // default, do nothing
730746 LOGGER .info ("Swashbuckle version: {}" , swashbuckleVersion .getOptValue ());
731747 }
0 commit comments