mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 02:25:20 +00:00
[ASP.NET Core] minor format fix, better null check (#2778)
* aspnet core format fix, better null check * minor wording change * update doc
This commit is contained in:
parent
40759a57fb
commit
05053f5b8a
@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -g aspnetcore -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/aspnetcore --additional-properties packageGuid={3C799344-F285-4669-8FD5-7ED9B795D5C5} $@"
|
||||
ags="generate -g aspnetcore -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/aspnetcore/2.1/ -o samples/server/petstore/aspnetcore --additional-properties packageGuid={3C799344-F285-4669-8FD5-7ED9B795D5C5} $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
@ -28,6 +28,6 @@ sidebar_label: aspnetcore
|
||||
|operationModifier|Operation Modifier can be virtual, abstract or partial| |virtual|
|
||||
|buildTarget|Target to build an application or library| |program|
|
||||
|generateBody|Generates method body.| |true|
|
||||
|operationIsAsync|Set methods to async or sync.| |false|
|
||||
|operationIsAsync|Set methods to async or sync (default).| |false|
|
||||
|operationResultTask|Set methods result to Task<>.| |false|
|
||||
|modelClassModifier|Model Class Modifier can be nothing or partial| |partial|
|
||||
|
@ -142,9 +142,9 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
addOption(COMPATIBILITY_VERSION, "ASP.Net Core CompatibilityVersion", compatibilityVersion);
|
||||
|
||||
aspnetCoreVersion.addEnum("2.0", "ASP.NET COre V2.0");
|
||||
aspnetCoreVersion.addEnum("2.1", "ASP.NET COre V2.1");
|
||||
aspnetCoreVersion.addEnum("2.2", "ASP.NET COre V2.2");
|
||||
aspnetCoreVersion.addEnum("2.0", "ASP.NET COre 2.0");
|
||||
aspnetCoreVersion.addEnum("2.1", "ASP.NET Core 2.1");
|
||||
aspnetCoreVersion.addEnum("2.2", "ASP.NET Core 2.2");
|
||||
aspnetCoreVersion.setDefault("2.2");
|
||||
aspnetCoreVersion.setOptValue(aspnetCoreVersion.getDefault());
|
||||
addOption(aspnetCoreVersion.getOpt(), aspnetCoreVersion.getDescription(), aspnetCoreVersion.getOptValue());
|
||||
@ -180,13 +180,13 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
classModifier.setOptValue(classModifier.getDefault());
|
||||
addOption(classModifier.getOpt(), classModifier.getDescription(), classModifier.getOptValue());
|
||||
|
||||
operationModifier.addEnum("virtual", "Keep method virtual ");
|
||||
operationModifier.addEnum("virtual", "Keep method virtual");
|
||||
operationModifier.addEnum("abstract", "Make method abstract");
|
||||
operationModifier.setDefault("virtual");
|
||||
operationModifier.setOptValue(operationModifier.getDefault());
|
||||
addOption(operationModifier.getOpt(), operationModifier.getDescription(), operationModifier.getOptValue());
|
||||
|
||||
buildTarget.addEnum("program", "Generate code for standalone server");
|
||||
buildTarget.addEnum("program", "Generate code for a standalone server");
|
||||
buildTarget.addEnum("library", "Generate code for a server abstract class lbrary");
|
||||
buildTarget.setDefault("program");
|
||||
buildTarget.setOptValue(buildTarget.getDefault());
|
||||
@ -197,7 +197,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
generateBody);
|
||||
|
||||
addSwitch(OPERATION_IS_ASYNC,
|
||||
"Set methods to async or sync.",
|
||||
"Set methods to async or sync (default).",
|
||||
operationIsAsync);
|
||||
|
||||
addSwitch(OPERATION_RESULT_TASK,
|
||||
|
@ -1,8 +1,10 @@
|
||||
{{>partial_header}}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;{{#useSwashbuckle}}
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;{{/useSwashbuckle}}
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
{{#useSwashbuckle}}
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
{{/useSwashbuckle}}
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using {{packageName}}.Attributes;
|
||||
|
@ -92,6 +92,7 @@ namespace {{packageName}}.Models
|
||||
(
|
||||
{{name}} == other.{{name}} ||
|
||||
{{name}} != null &&
|
||||
other.{{name}} != null &&
|
||||
{{name}}.SequenceEqual(other.{{name}})
|
||||
){{#hasMore}} && {{/hasMore}}{{/isContainer}}{{/vars}}{{^vars}}false{{/vars}};
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace {{packageName}}
|
||||
services
|
||||
.AddMvc()
|
||||
{{#compatibilityVersion}}
|
||||
.SetCompatibilityVersion (CompatibilityVersion.{{compatibilityVersion}})
|
||||
.SetCompatibilityVersion(CompatibilityVersion.{{compatibilityVersion}})
|
||||
{{/compatibilityVersion}}
|
||||
.AddJsonOptions(opts =>
|
||||
{
|
||||
@ -53,7 +53,8 @@ namespace {{packageName}}
|
||||
{
|
||||
CamelCaseText = true
|
||||
});
|
||||
});{{#useSwashbuckle}}
|
||||
});
|
||||
{{#useSwashbuckle}}
|
||||
|
||||
services
|
||||
.AddSwaggerGen(c =>
|
||||
@ -82,7 +83,8 @@ namespace {{packageName}}
|
||||
// Include DataAnnotation attributes on Controller Action parameters as Swagger validation rules (e.g required, pattern, ..)
|
||||
// Use [ValidateModelState] on Actions to actually validate it in C# as well!
|
||||
c.OperationFilter<GeneratePathParamsValidationFilter>();
|
||||
});{{/useSwashbuckle}}
|
||||
});
|
||||
{{/useSwashbuckle}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -109,7 +111,7 @@ namespace {{packageName}}
|
||||
// c.SwaggerEndpoint("/openapi-original.json", "{{#appName}}{{{appName}}}{{/appName}}{{^appName}}{{packageName}}{{/appName}} Original");
|
||||
}){{/useSwashbuckle}};
|
||||
|
||||
if (env.IsDevelopment())
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
@ -1,12 +1,17 @@
|
||||
{{>partial_header}}
|
||||
using System;
|
||||
using System.Collections.Generic;{{#operationResultTask}}
|
||||
using System.Collections.Generic;
|
||||
{{#operationResultTask}}
|
||||
using System.Threading.Tasks;
|
||||
{{/operationResultTask}}
|
||||
using Microsoft.AspNetCore.Mvc;{{#useSwashbuckle}}
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
{{#useSwashbuckle}}
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;{{/useSwashbuckle}}{{^isLibrary}}
|
||||
using Newtonsoft.Json;{{/isLibrary}}
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
{{/useSwashbuckle}}
|
||||
{{^isLibrary}}
|
||||
using Newtonsoft.Json;
|
||||
{{/isLibrary}}
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using {{packageName}}.Attributes;
|
||||
using {{modelPackage}};
|
||||
|
@ -15,7 +15,7 @@ namespace {{modelPackage}}
|
||||
/// {{description}}
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public {{#modelClassModifier}}{{modelClassModifier}} {{/modelClassModifier}} class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}}IEquatable<{{classname}}>
|
||||
public {{#modelClassModifier}}{{modelClassModifier}} {{/modelClassModifier}}class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}}IEquatable<{{classname}}>
|
||||
{ {{#vars}}{{#isEnum}}{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}{{>enumClass}}{{/items}}{{/items.isEnum}}
|
||||
/// <summary>
|
||||
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
|
||||
@ -92,6 +92,7 @@ namespace {{modelPackage}}
|
||||
(
|
||||
{{name}} == other.{{name}} ||
|
||||
{{name}} != null &&
|
||||
other.{{name}} != null &&
|
||||
{{name}}.SequenceEqual(other.{{name}})
|
||||
){{#hasMore}} && {{/hasMore}}{{/isContainer}}{{/vars}}{{^vars}}false{{/vars}};
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ Windows:
|
||||
```
|
||||
build.bat
|
||||
```
|
||||
|
||||
## Run in Docker
|
||||
|
||||
```
|
||||
|
@ -23,6 +23,7 @@ namespace Org.OpenAPITools.Controllers
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
public class PetApiController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -23,6 +23,7 @@ namespace Org.OpenAPITools.Controllers
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
public class StoreApiController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -23,6 +23,7 @@ namespace Org.OpenAPITools.Controllers
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
public class UserApiController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -158,11 +158,13 @@ namespace Org.OpenAPITools.Models
|
||||
(
|
||||
PhotoUrls == other.PhotoUrls ||
|
||||
PhotoUrls != null &&
|
||||
other.PhotoUrls != null &&
|
||||
PhotoUrls.SequenceEqual(other.PhotoUrls)
|
||||
) &&
|
||||
(
|
||||
Tags == other.Tags ||
|
||||
Tags != null &&
|
||||
other.Tags != null &&
|
||||
Tags.SequenceEqual(other.Tags)
|
||||
) &&
|
||||
(
|
||||
|
@ -112,8 +112,8 @@
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"type" : "string",
|
||||
"enum" : [ "available", "pending", "sold" ],
|
||||
"default" : "available"
|
||||
"default" : "available",
|
||||
"enum" : [ "available", "pending", "sold" ]
|
||||
}
|
||||
}
|
||||
} ],
|
||||
|
Loading…
Reference in New Issue
Block a user