Skip to content

[BUG][CLI][GENERATOR] NullPointer when not setting outputDir #3448

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

Closed
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 @@ -33,6 +33,20 @@
public class WorkflowSettings {

private static final Logger LOGGER = LoggerFactory.getLogger(WorkflowSettings.class);
public static final String DEFAULT_INPUT_SPEC = null;
public static final String DEFAULT_OUTPUT_DIR = ".";
public static final boolean DEFAULT_VERBOSE = false;
public static final boolean DEFAULT_SKIP_OVERWRITE = false;
public static final boolean DEFAULT_REMOVE_OPERATION_ID_PREFIX = false;
public static final boolean DEFAULT_LOG_TO_STDERR = false;
public static final boolean DEFAULT_VALIDATE_SPEC = true;
public static final boolean DEFAULT_ENABLE_POST_PROCESS_FILE = false;
public static final boolean DEFAULT_ENABLE_MINIMAL_UPDATE = false;
public static final boolean DEFAULT_STRICT_SPEC_BEHAVIOR = true;
public static final String DEFAULT_TEMPLATE_DIR = null;
public static final String DEFAULT_TEMPLATING_ENGINE_NAME = null;
public static final String DEFAULT_IGNORE_FILE_OVERRIDE = null;
public static final ImmutableMap<String, String> DEFAULT_SYSTEM_PROPERTIES = ImmutableMap.copyOf(new HashMap<>());

private String inputSpec;
private String outputDir;
Expand All @@ -50,44 +64,94 @@ public class WorkflowSettings {
private ImmutableMap<String, String> systemProperties;

private WorkflowSettings(Builder builder) {
setDefaults();
inputSpec = builder.inputSpec;
outputDir = builder.outputDir;
verbose = builder.verbose;
skipOverwrite = builder.skipOverwrite;
removeOperationIdPrefix = builder.removeOperationIdPrefix;
logToStderr = builder.logToStderr;
validateSpec = builder.validateSpec;
enablePostProcessFile = builder.enablePostProcessFile;
enableMinimalUpdate = builder.enableMinimalUpdate;
strictSpecBehavior = builder.strictSpecBehavior;
templateDir = builder.templateDir;
templatingEngineName = builder.templatingEngineName;
ignoreFileOverride = builder.ignoreFileOverride;
systemProperties = ImmutableMap.copyOf(builder.systemProperties);
this();
if (builder.inputSpec == null) {
this.inputSpec = DEFAULT_INPUT_SPEC;
} else {
this.inputSpec = builder.inputSpec;
}
if (builder.outputDir == null) {
this.outputDir = DEFAULT_OUTPUT_DIR;
} else {
this.outputDir = builder.outputDir;
}
if (builder.verbose == null) {
this.verbose = DEFAULT_VERBOSE;
} else {
this.verbose = builder.verbose;
}
if (builder.skipOverwrite == null) {
this.skipOverwrite = DEFAULT_SKIP_OVERWRITE;
} else {
this.skipOverwrite = builder.skipOverwrite;
}
if (builder.removeOperationIdPrefix == null) {
this.removeOperationIdPrefix = DEFAULT_REMOVE_OPERATION_ID_PREFIX;
} else {
this.removeOperationIdPrefix = builder.removeOperationIdPrefix;
}
if (builder.logToStderr == null) {
this.logToStderr = DEFAULT_LOG_TO_STDERR;
} else {
this.logToStderr = builder.logToStderr;
}
if (builder.validateSpec == null) {
this.validateSpec = DEFAULT_VALIDATE_SPEC;
} else {
this.validateSpec = builder.validateSpec;
}
if (builder.enablePostProcessFile == null) {
this.enablePostProcessFile = DEFAULT_ENABLE_POST_PROCESS_FILE;
} else {
this.enablePostProcessFile = builder.enablePostProcessFile;
}
if (builder.enableMinimalUpdate == null) {
this.enableMinimalUpdate = DEFAULT_ENABLE_MINIMAL_UPDATE;
} else {
this.enableMinimalUpdate = builder.enableMinimalUpdate;
}
if (builder.strictSpecBehavior == null) {
this.strictSpecBehavior = DEFAULT_STRICT_SPEC_BEHAVIOR;
} else {
this.strictSpecBehavior = builder.strictSpecBehavior;
}
if (builder.templateDir == null) {
this.templateDir = DEFAULT_TEMPLATE_DIR;
} else {
this.templateDir = builder.templateDir;
}
if (builder.templatingEngineName == null) {
this.templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
} else {
this.templatingEngineName = builder.templatingEngineName;
}
if (builder.ignoreFileOverride == null) {
this.ignoreFileOverride = DEFAULT_IGNORE_FILE_OVERRIDE;
} else {
this.ignoreFileOverride = builder.ignoreFileOverride;
}
if (builder.systemProperties == null) {
this.systemProperties = DEFAULT_SYSTEM_PROPERTIES;
} else {
this.systemProperties = ImmutableMap.copyOf(builder.systemProperties);
}

}

/**
* Instantiates a new workflow settings.
*/
@SuppressWarnings("unused")
public WorkflowSettings() {
setDefaults();
systemProperties = ImmutableMap.of();
}

private void setDefaults(){
validateSpec = true;
strictSpecBehavior = true;
outputDir = ".";
}

public static Builder newBuilder() {
return new Builder();
}

public static Builder newBuilder(WorkflowSettings copy) {
Builder builder = new Builder();
Builder builder = newBuilder();
builder.inputSpec = copy.getInputSpec();
builder.outputDir = copy.getOutputDir();
builder.verbose = copy.isVerbose();
Expand Down Expand Up @@ -258,23 +322,40 @@ public Map<String, String> getSystemProperties() {
public static final class Builder {
private String inputSpec;
private String outputDir;
private boolean verbose;
private boolean skipOverwrite;
private boolean removeOperationIdPrefix;
private boolean logToStderr;
private boolean validateSpec;
private boolean enablePostProcessFile;
private boolean enableMinimalUpdate;
private boolean strictSpecBehavior;
private Boolean verbose;
private Boolean skipOverwrite;
private Boolean removeOperationIdPrefix;
private Boolean logToStderr;
private Boolean validateSpec;
private Boolean enablePostProcessFile;
private Boolean enableMinimalUpdate;
private Boolean strictSpecBehavior;
private String templateDir;
private String templatingEngineName;
private String ignoreFileOverride;
private Map<String, String> systemProperties;

private Builder() {
setDefaults();
systemProperties = new HashMap<>();
}

private void setDefaults(){
this.inputSpec = WorkflowSettings.DEFAULT_INPUT_SPEC;
this.outputDir = WorkflowSettings.DEFAULT_OUTPUT_DIR;
this.verbose = WorkflowSettings.DEFAULT_VERBOSE;
this.skipOverwrite = WorkflowSettings.DEFAULT_SKIP_OVERWRITE;
this.removeOperationIdPrefix = WorkflowSettings.DEFAULT_REMOVE_OPERATION_ID_PREFIX;
this.logToStderr = WorkflowSettings.DEFAULT_LOG_TO_STDERR;
this.validateSpec = WorkflowSettings.DEFAULT_VALIDATE_SPEC;
this.enablePostProcessFile = WorkflowSettings.DEFAULT_ENABLE_POST_PROCESS_FILE;
this.enableMinimalUpdate = WorkflowSettings.DEFAULT_ENABLE_MINIMAL_UPDATE;
this.strictSpecBehavior = WorkflowSettings.DEFAULT_STRICT_SPEC_BEHAVIOR;
this.templateDir = WorkflowSettings.DEFAULT_TEMPLATE_DIR;
this.templatingEngineName = WorkflowSettings.DEFAULT_TEMPLATING_ENGINE_NAME;
this.ignoreFileOverride = WorkflowSettings.DEFAULT_IGNORE_FILE_OVERRIDE;
}

/**
* Sets the {@code inputSpec} and returns a reference to this Builder so that the methods can be chained together.
*
Expand Down
10 changes: 5 additions & 5 deletions samples/client/petstore/ruby/lib/petstore/api/pet_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def delete_pet_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -290,7 +290,7 @@ def get_pet_by_id_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -414,7 +414,7 @@ def update_pet_with_form_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -480,7 +480,7 @@ def upload_file_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file"
end
# resource path
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -552,7 +552,7 @@ def upload_file_with_required_file_with_http_info(pet_id, required_file, opts =
fail ArgumentError, "Missing the required parameter 'required_file' when calling PetApi.upload_file_with_required_file"
end
# resource path
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/api/store_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def delete_order_with_http_info(order_id, opts = {})
fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order"
end
# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s).gsub('%2F', '/'))
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -167,7 +167,7 @@ def get_order_by_id_with_http_info(order_id, opts = {})
end

# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s).gsub('%2F', '/'))
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/ruby/lib/petstore/api/user_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def delete_user_with_http_info(username, opts = {})
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -277,7 +277,7 @@ def get_user_by_name_with_http_info(username, opts = {})
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -465,7 +465,7 @@ def update_user_with_http_info(username, body, opts = {})
fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.update_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def delete_pet_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -290,7 +290,7 @@ def get_pet_by_id_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -414,7 +414,7 @@ def update_pet_with_form_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -480,7 +480,7 @@ def upload_file_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file"
end
# resource path
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -552,7 +552,7 @@ def upload_file_with_required_file_with_http_info(pet_id, required_file, opts =
fail ArgumentError, "Missing the required parameter 'required_file' when calling PetApi.upload_file_with_required_file"
end
# resource path
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def delete_order_with_http_info(order_id, opts = {})
fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order"
end
# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s).gsub('%2F', '/'))
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -167,7 +167,7 @@ def get_order_by_id_with_http_info(order_id, opts = {})
end

# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s).gsub('%2F', '/'))
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def delete_user_with_http_info(username, opts = {})
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -283,7 +283,7 @@ def get_user_by_name_with_http_info(username, opts = {})
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -471,7 +471,7 @@ def update_user_with_http_info(username, user, opts = {})
fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.update_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
Loading