mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 14:40:53 +00:00
allowing user to set client package (#13785)
This commit is contained in:
parent
a68c36e932
commit
c0c31e89b7
@ -84,10 +84,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
private static FrameworkStrategy defaultFramework = FrameworkStrategy.NETSTANDARD_2_0;
|
private static FrameworkStrategy defaultFramework = FrameworkStrategy.NETSTANDARD_2_0;
|
||||||
protected final Map<String, String> frameworks;
|
protected final Map<String, String> frameworks;
|
||||||
protected String packageGuid = "{" + java.util.UUID.randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
protected String packageGuid = "{" + java.util.UUID.randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
||||||
protected String clientPackage = "Org.OpenAPITools.Client";
|
protected String clientPackage = "Client";
|
||||||
protected String authFolder = "Auth";
|
protected String authFolder = "Auth";
|
||||||
protected String apiDocPath = "docs/";
|
protected String apiDocPath = "docs" + File.separator;
|
||||||
protected String modelDocPath = "docs/";
|
protected String modelDocPath = "docs" + File.separator;
|
||||||
|
|
||||||
// Defines TargetFrameworkVersion in csproj files
|
// Defines TargetFrameworkVersion in csproj files
|
||||||
protected String targetFramework = defaultFramework.name;
|
protected String targetFramework = defaultFramework.name;
|
||||||
@ -547,6 +547,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
postProcessPattern(property.pattern, property.vendorExtensions);
|
postProcessPattern(property.pattern, property.vendorExtensions);
|
||||||
postProcessEmitDefaultValue(property.vendorExtensions);
|
postProcessEmitDefaultValue(property.vendorExtensions);
|
||||||
|
|
||||||
|
// remove once https://github.com/OpenAPITools/openapi-generator/pull/13681 is merged
|
||||||
if (GENERICHOST.equals(getLibrary())) {
|
if (GENERICHOST.equals(getLibrary())) {
|
||||||
// all c# libraries should want this, but avoid breaking changes for now
|
// all c# libraries should want this, but avoid breaking changes for now
|
||||||
// a class cannot contain a property with the same name
|
// a class cannot contain a property with the same name
|
||||||
@ -664,8 +665,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
setModelPackage("Model");
|
setModelPackage("Model");
|
||||||
}
|
}
|
||||||
|
|
||||||
clientPackage = "Client";
|
|
||||||
|
|
||||||
if (GENERICHOST.equals(getLibrary())) {
|
if (GENERICHOST.equals(getLibrary())) {
|
||||||
setLibrary(GENERICHOST);
|
setLibrary(GENERICHOST);
|
||||||
additionalProperties.put("useGenericHost", true);
|
additionalProperties.put("useGenericHost", true);
|
||||||
@ -679,7 +678,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
additionalProperties.put("useHttpClient", true);
|
additionalProperties.put("useHttpClient", true);
|
||||||
needsUriBuilder = true;
|
needsUriBuilder = true;
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only restsharp, httpclient are supported.");
|
throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only restsharp, httpclient, and generichost are supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String inputFramework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.name);
|
String inputFramework = (String) additionalProperties.getOrDefault(CodegenConstants.DOTNET_FRAMEWORK, defaultFramework.name);
|
||||||
@ -742,7 +741,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
final AtomicReference<Boolean> excludeTests = new AtomicReference<>();
|
final AtomicReference<Boolean> excludeTests = new AtomicReference<>();
|
||||||
syncBooleanProperty(additionalProperties, CodegenConstants.EXCLUDE_TESTS, excludeTests::set, false);
|
syncBooleanProperty(additionalProperties, CodegenConstants.EXCLUDE_TESTS, excludeTests::set, false);
|
||||||
|
|
||||||
syncStringProperty(additionalProperties, "clientPackage", (s) -> { }, clientPackage);
|
syncStringProperty(additionalProperties, "clientPackage", this::setClientPackage, clientPackage);
|
||||||
|
|
||||||
syncStringProperty(additionalProperties, CodegenConstants.API_PACKAGE, this::setApiPackage, apiPackage);
|
syncStringProperty(additionalProperties, CodegenConstants.API_PACKAGE, this::setApiPackage, apiPackage);
|
||||||
syncStringProperty(additionalProperties, CodegenConstants.MODEL_PACKAGE, this::setModelPackage, modelPackage);
|
syncStringProperty(additionalProperties, CodegenConstants.MODEL_PACKAGE, this::setModelPackage, modelPackage);
|
||||||
@ -809,6 +808,10 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
addTestInstructions();
|
addTestInstructions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setClientPackage(String clientPackage) {
|
||||||
|
this.clientPackage = clientPackage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodegenOperation fromOperation(String path,
|
public CodegenOperation fromOperation(String path,
|
||||||
String httpMethod,
|
String httpMethod,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user