From ff556609c758e6587965ff64126812b1f0ed0bdc Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 23 Apr 2019 03:03:15 +0800 Subject: [PATCH] Remove setting generateAliasAsModel in rust server generator (#2714) * remove setting generateAliasAsModel in rust server * update rust server samples * update doc --- bin/rust-server-petstore.sh | 1 + docs/generators/aspnetcore.md | 4 ++++ .../openapitools/codegen/languages/RustServerCodegen.java | 7 ++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/rust-server-petstore.sh b/bin/rust-server-petstore.sh index 2542d31b1238..7b577f525982 100755 --- a/bin/rust-server-petstore.sh +++ b/bin/rust-server-petstore.sh @@ -34,6 +34,7 @@ for spec_path in modules/openapi-generator/src/test/resources/*/rust-server/* ; --output samples/server/petstore/rust-server/output/$spec -DpackageName=$spec --additional-properties hideGenerationTimestamp=true + --generate-alias-as-model $@" java $JAVA_OPTS -jar $executable $args diff --git a/docs/generators/aspnetcore.md b/docs/generators/aspnetcore.md index fdb73387f3f7..64a0b8d9a3a9 100644 --- a/docs/generators/aspnetcore.md +++ b/docs/generators/aspnetcore.md @@ -23,7 +23,11 @@ sidebar_label: aspnetcore |useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false| |returnICollection|Return ICollection<T> instead of the concrete type.| |false| |useSwashbuckle|Uses the Swashbuckle.AspNetCore NuGet package for documentation.| |true| +|isLibrary|Is the build a library| |false| |classModifier|Class Modifier can be empty, abstract| || |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| +|operationResultTask|Set methods result to Task<>.| |false| +|modelClassModifier|Model Class Modifier can be nothing or partial| |partial| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java index 287bb4378dc3..a342dee6f41d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java @@ -67,9 +67,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig { public RustServerCodegen() { super(); - // Force generating models for wrapping types - ModelUtils.setGenerateAliasAsModel(true); - // Show the generation timestamp by default hideGenerationTimestamp = Boolean.FALSE; @@ -211,6 +208,10 @@ public RustServerCodegen() { public void processOpts() { super.processOpts(); + if (!Boolean.TRUE.equals(ModelUtils.isGenerateAliasAsModel())) { + LOGGER.warn("generateAliasAsModel is set to false, which means array/map will be generated as model instead and the resulting code may have issues. Please enable `generateAliasAsModel` to address the issue."); + } + setPackageName((String) additionalProperties.getOrDefault(CodegenConstants.PACKAGE_NAME, "openapi_client")); if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {