From e7ac57d312dcb20d581ae76c7ec9ed1e96387dcb Mon Sep 17 00:00:00 2001 From: Urganot Date: Mon, 6 Jan 2025 15:03:05 +0100 Subject: [PATCH] [ASPNETCORE] Add support for central package version management #20192 (#20403) * Fixed default value for usePackageVersions * Regenerated docs --- .../codegen/languages/AspNetServerCodegen.java | 13 +++++++++++-- .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 10 +++++----- .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 12 ++++++------ .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 12 ++++++------ .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 10 +++++----- .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 6 +++--- .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 12 ++++++------ .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 10 +++++----- .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 12 ++++++------ .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 12 ++++++------ .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 10 +++++----- .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 6 +++--- .../src/Org.OpenAPITools/Org.OpenAPITools.csproj | 12 ++++++------ 13 files changed, 73 insertions(+), 64 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java index 38e282b3d953..119609b49844 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java @@ -98,6 +98,7 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen { private boolean useNewtonsoft = true; private boolean useDefaultRouting = true; private String newtonsoftVersion = "3.0.0"; + private CliOption centralizedPackageVersionManagement = new CliOption(CENTRALIZED_PACKAGE_VERSION_MANAGEMENT, "Option to control the usage of centralized package version management. https://devblogs.microsoft.com/nuget/introducing-central-package-management/#disabling-central-package-management"); public AspNetServerCodegen() { super(); @@ -310,7 +311,10 @@ public AspNetServerCodegen() { modelClassModifier.setOptValue(modelClassModifier.getDefault()); addOption(modelClassModifier.getOpt(), modelClassModifier.getDescription(), modelClassModifier.getOptValue()); - CliOption centralizedPackageVersionManagement = new CliOption(CENTRALIZED_PACKAGE_VERSION_MANAGEMENT, "Option to control the usage of centralized package version management. https://devblogs.microsoft.com/nuget/introducing-central-package-management/#disabling-central-package-management"); + addCentralizedPackageManagementOption(); + } + + private void addCentralizedPackageManagementOption(){ Map centralizedPackageVersionManagementOptions = new HashMap<>(); centralizedPackageVersionManagementOptions.put(DEFAULT, "Property in project won't be used"); centralizedPackageVersionManagementOptions.put(ENABLE, "Centralized package version management will be used"); @@ -481,8 +485,13 @@ public void processOpts() { this.setTypeMapping(); + setCentralizedPackageManagementOption(); + } + + private void setCentralizedPackageManagementOption() { + additionalProperties.put(USE_PACKAGE_VERSIONS, true); + if (additionalProperties.containsKey(CENTRALIZED_PACKAGE_VERSION_MANAGEMENT)) { - additionalProperties.put(USE_PACKAGE_VERSIONS, true); switch ((String) additionalProperties.get(CENTRALIZED_PACKAGE_VERSION_MANAGEMENT)) { case DEFAULT: additionalProperties.remove(CENTRALIZED_PACKAGE_VERSION_MANAGEMENT); diff --git a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 100c2ac95f36..8a936d1da128 100644 --- a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -14,11 +14,11 @@ ..\.. - - - - - + + + + + diff --git a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 0544ffdba1df..b480b28f87de 100644 --- a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -15,12 +15,12 @@ ..\.. - - - - - - + + + + + + diff --git a/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 61231083658e..2ba4d6e2350f 100644 --- a/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -14,12 +14,12 @@ ..\.. - - - - - - + + + + + + diff --git a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 5e8abdb64cb8..91d9ff31e8d8 100644 --- a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -15,11 +15,11 @@ - - - - - + + + + + diff --git a/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj index cb7e7482aa91..5ca13c5666f1 100644 --- a/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -16,9 +16,9 @@ - - - + + + diff --git a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 61231083658e..2ba4d6e2350f 100644 --- a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -14,12 +14,12 @@ ..\.. - - - - - - + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 3acd08d05691..385d63c5c075 100644 --- a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -14,11 +14,11 @@ ..\.. - - - - - + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 3e040bdb2c99..71ec968fd115 100644 --- a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -15,12 +15,12 @@ ..\.. - - - - - - + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 109c55c84dca..7e9a98c00b5f 100644 --- a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -14,12 +14,12 @@ ..\.. - - - - - - + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj index a458ac60272b..47b3aca5b117 100644 --- a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -15,11 +15,11 @@ - - - - - + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 75f93692c6e3..bfcc40c13dd8 100644 --- a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -16,9 +16,9 @@ - - - + + + diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 109c55c84dca..7e9a98c00b5f 100644 --- a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -14,12 +14,12 @@ ..\.. - - - - - - + + + + + +