forked from loafle/openapi-generator-original
throw exception for invalid framework (#7901)
This commit is contained in:
parent
81e0e8dfa8
commit
b1b64cb356
@ -31,6 +31,7 @@ import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
@ -547,7 +548,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
additionalProperties.put(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES, optionalEmitDefaultValuesFlag);
|
||||
}
|
||||
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.MODEL_PROPERTY_NAMING)) {
|
||||
setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING));
|
||||
}
|
||||
@ -561,13 +561,24 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
clientPackage = "Client";
|
||||
|
||||
String framework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.name);
|
||||
boolean strategyMatched = false;
|
||||
FrameworkStrategy strategy = defaultFramework;
|
||||
for (FrameworkStrategy frameworkStrategy : frameworkStrategies) {
|
||||
if (framework.equals(frameworkStrategy.name)) {
|
||||
strategy = frameworkStrategy;
|
||||
strategyMatched = true;
|
||||
}
|
||||
}
|
||||
|
||||
// throws exception if the input targetFramework is invalid
|
||||
if (strategyMatched == false) {
|
||||
throw new IllegalArgumentException("Invalid .NET framework version: " +
|
||||
framework + ". List of supported versions: " +
|
||||
frameworkStrategies.stream()
|
||||
.map(p -> p.name)
|
||||
.collect(Collectors.joining(", ")));
|
||||
}
|
||||
|
||||
strategy.configureAdditionalProperties(additionalProperties);
|
||||
|
||||
setTargetFrameworkNuget(strategy.getNugetFrameworkIdentifier());
|
||||
@ -710,7 +721,11 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
public void setTargetFramework(String dotnetFramework) {
|
||||
if (!frameworks.containsKey(dotnetFramework)) {
|
||||
LOGGER.warn("Invalid .NET framework version, defaulting to " + this.targetFramework);
|
||||
throw new IllegalArgumentException("Invalid .NET framework version: " +
|
||||
dotnetFramework + ". List of supported versions: " +
|
||||
frameworkStrategies.stream()
|
||||
.map(p -> p.name)
|
||||
.collect(Collectors.joining(", ")));
|
||||
} else {
|
||||
this.targetFramework = dotnetFramework;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user