@@ -35,7 +35,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
35
35
private static final String ASP_NET_CORE_VERSION_OPTION = "--aspnet-core-version" ;
36
36
private static final String INTERFACE_ONLY_OPTION = "--interface-only" ;
37
37
private static final String INTERFACE_CONTROLLER_OPTION = "--interface-controller" ;
38
- private final String DEFAULT_ASP_NET_CORE_VERSION = "2.2 " ;
38
+ private final String DEFAULT_ASP_NET_CORE_VERSION = "3.0 " ;
39
39
private String aspNetCoreVersion ;
40
40
41
41
@ SuppressWarnings ("hiding" )
@@ -151,13 +151,33 @@ public void processOpts() {
151
151
supportingFiles .add (new SupportingFile ("Program.mustache" , packageFolder , "Program.cs" ));
152
152
supportingFiles .add (new SupportingFile ("Project.csproj.mustache" , packageFolder , this .packageName + ".csproj" ));
153
153
supportingFiles .add (new SupportingFile ("Dockerfile.mustache" , packageFolder , "Dockerfile" ));
154
- } else {
154
+ supportingFiles .add (new SupportingFile ("Startup.mustache" , packageFolder , "Startup.cs" ));
155
+
156
+ supportingFiles .add (new SupportingFile ("Filters" + File .separator + "BasePathFilter.mustache" , packageFolder + File .separator + "Filters" , "BasePathFilter.cs" ));
157
+ supportingFiles .add (new SupportingFile ("Filters" + File .separator + "GeneratePathParamsValidationFilter.mustache" , packageFolder + File .separator + "Filters" , "GeneratePathParamsValidationFilter.cs" ));
158
+
159
+ } else if (aspNetCoreVersion .equals ("2.1" )) {
155
160
apiTemplateFiles .put ("2.1/controller.mustache" , ".cs" );
156
161
addInterfaceControllerTemplate ();
157
162
158
163
supportingFiles .add (new SupportingFile ("2.1/Program.mustache" , packageFolder , "Program.cs" ));
159
164
supportingFiles .add (new SupportingFile ("2.1/Project.csproj.mustache" , packageFolder , this .packageName + ".csproj" ));
160
165
supportingFiles .add (new SupportingFile ("2.1/Dockerfile.mustache" , packageFolder , "Dockerfile" ));
166
+ supportingFiles .add (new SupportingFile ("Startup.mustache" , packageFolder , "Startup.cs" ));
167
+
168
+ supportingFiles .add (new SupportingFile ("Filters" + File .separator + "BasePathFilter.mustache" , packageFolder + File .separator + "Filters" , "BasePathFilter.cs" ));
169
+ supportingFiles .add (new SupportingFile ("Filters" + File .separator + "GeneratePathParamsValidationFilter.mustache" , packageFolder + File .separator + "Filters" , "GeneratePathParamsValidationFilter.cs" ));
170
+ } else {
171
+ apiTemplateFiles .put ("3.0/controller.mustache" , ".cs" );
172
+ addInterfaceControllerTemplate ();
173
+
174
+ supportingFiles .add (new SupportingFile ("3.0/Program.mustache" , packageFolder , "Program.cs" ));
175
+ supportingFiles .add (new SupportingFile ("3.0/Project.csproj.mustache" , packageFolder , this .packageName + ".csproj" ));
176
+ supportingFiles .add (new SupportingFile ("3.0/Dockerfile.mustache" , packageFolder , "Dockerfile" ));
177
+ supportingFiles .add (new SupportingFile ("3.0/Startup.mustache" , packageFolder , "Startup.cs" ));
178
+
179
+ supportingFiles .add (new SupportingFile ("3.0" + File .separator + "Filters" + File .separator + "BasePathFilter.mustache" , packageFolder + File .separator + "Filters" , "BasePathFilter.cs" ));
180
+ supportingFiles .add (new SupportingFile ("3.0" + File .separator + "Filters" + File .separator + "GeneratePathParamsValidationFilter.mustache" , packageFolder + File .separator + "Filters" , "GeneratePathParamsValidationFilter.cs" ));
161
181
}
162
182
163
183
if (!additionalProperties .containsKey (CodegenConstants .API_PACKAGE )) {
@@ -178,16 +198,11 @@ public void processOpts() {
178
198
supportingFiles .add (new SupportingFile ("gitignore" , packageFolder , ".gitignore" ));
179
199
supportingFiles .add (new SupportingFile ("appsettings.json" , packageFolder , "appsettings.json" ));
180
200
181
- supportingFiles .add (new SupportingFile ("Startup.mustache" , packageFolder , "Startup.cs" ));
182
-
183
201
supportingFiles .add (new SupportingFile ("validateModel.mustache" , packageFolder + File .separator + "Attributes" , "ValidateModelStateAttribute.cs" ));
184
202
supportingFiles .add (new SupportingFile ("web.config" , packageFolder , "web.config" ));
185
203
186
204
supportingFiles .add (new SupportingFile ("Properties" + File .separator + "launchSettings.json" , packageFolder + File .separator + "Properties" , "launchSettings.json" ));
187
205
188
- supportingFiles .add (new SupportingFile ("Filters" + File .separator + "BasePathFilter.mustache" , packageFolder + File .separator + "Filters" , "BasePathFilter.cs" ));
189
- supportingFiles .add (new SupportingFile ("Filters" + File .separator + "GeneratePathParamsValidationFilter.mustache" , packageFolder + File .separator + "Filters" , "GeneratePathParamsValidationFilter.cs" ));
190
-
191
206
supportingFiles .add (new SupportingFile ("wwwroot" + File .separator + "README.md" , packageFolder + File .separator + "wwwroot" , "README.md" ));
192
207
supportingFiles .add (new SupportingFile ("wwwroot" + File .separator + "index.html" , packageFolder + File .separator + "wwwroot" , "index.html" ));
193
208
supportingFiles .add (new SupportingFile ("wwwroot" + File .separator + "web.config" , packageFolder + File .separator + "wwwroot" , "web.config" ));
@@ -361,7 +376,7 @@ private void setAspNetCoreVersion() {
361
376
} else {
362
377
this .aspNetCoreVersion = optionValue ;
363
378
}
364
- if (!this .aspNetCoreVersion .equals ("2.0" ) && !this .aspNetCoreVersion .equals ("2.1" ) && !this .aspNetCoreVersion .equals ("2.2" )) {
379
+ if (!this .aspNetCoreVersion .equals ("2.0" ) && !this .aspNetCoreVersion .equals ("2.1" ) && !this .aspNetCoreVersion .equals ("2.2" ) && ! this . aspNetCoreVersion . equals ( "3.0" ) ) {
365
380
LOGGER .error ("version '" + this .aspNetCoreVersion + "' is not supported, switching to default version: '" + DEFAULT_ASP_NET_CORE_VERSION + "'" );
366
381
this .aspNetCoreVersion = DEFAULT_ASP_NET_CORE_VERSION ;
367
382
}
0 commit comments