Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to make proxy service interface public #659

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public static JavaSettings getInstance()
host.getBooleanValue("generate-sync-async-clients", false),
host.getStringValue("sync-methods", "essential"),
host.getBooleanValue("client-logger", false),
host.getBooleanValue("required-fields-as-ctor-args"));
host.getBooleanValue("required-fields-as-ctor-args", false),
host.getBooleanValue("service-interface-as-public", false));
}
return _instance;
}
Expand All @@ -108,6 +109,7 @@ public static JavaSettings getInstance()
@param implementationSubpackage The sub-package that the Service and Method Group client implementation classes will be put into.
@param modelsSubpackage The sub-package that Enums, Exceptions, and Model types will be put into.
@param requiredParameterClientMethods Whether or not Service and Method Group client method overloads that omit optional parameters will be created.
@param serviceInterfaceAsPublic If set to true, proxy method service interface will be marked as public.
*/
private JavaSettings(boolean azure,
boolean fluent,
Expand All @@ -132,7 +134,8 @@ private JavaSettings(boolean azure,
boolean generateSyncAsyncClients,
String syncMethods,
boolean clientLogger,
boolean requiredFieldsAsConstructorArgs)
boolean requiredFieldsAsConstructorArgs,
boolean serviceInterfaceAsPublic)
{
this.azure = azure;
this.fluent = fluent;
Expand All @@ -158,8 +161,10 @@ private JavaSettings(boolean azure,
this.syncMethods = SyncMethodsGeneration.fromValue(syncMethods);
this.clientLogger = clientLogger;
this.requiredFieldsAsConstructorArgs = requiredFieldsAsConstructorArgs;
this.serviceInterfaceAsPublic = serviceInterfaceAsPublic;
}


private boolean azure;
public final boolean isAzure()
{
Expand Down Expand Up @@ -322,7 +327,11 @@ public boolean isRequiredFieldsAsConstructorArgs() {
return requiredFieldsAsConstructorArgs;
}

public enum SyncMethodsGeneration {
private boolean serviceInterfaceAsPublic;
public boolean isServiceInterfaceAsPublic() {
return serviceInterfaceAsPublic;
}
public enum SyncMethodsGeneration {
ALL,
ESSENTIAL,
NONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ public final void write(Proxy restAPI, JavaClass classBlock) {
});
classBlock.annotation(String.format("Host(\"%1$s\")", restAPI.getBaseURL()));
classBlock.annotation(String.format("ServiceInterface(name = \"%1$s\")", serviceInterfaceWithLengthLimit(restAPI.getClientTypeName())));
classBlock.interfaceBlock(JavaVisibility.Private, restAPI.getName(), interfaceBlock ->

JavaVisibility visibility = JavaVisibility.Private;
if (settings.isServiceInterfaceAsPublic()) {
visibility = JavaVisibility.Public;
}

classBlock.interfaceBlock(visibility, restAPI.getName(), interfaceBlock ->
{
for (ProxyMethod restAPIMethod : restAPI.getMethods()) {
if (restAPIMethod.getRequestContentType().equals("multipart/form-data") || restAPIMethod.getRequestContentType().equals("application/x-www-form-urlencoded")) {
Expand Down