Skip to content

Commit 5f2f8e1

Browse files
DarkWingDuckWingfrantuma
authored andcommitted
Change DefaultGenerator private accessors to protected
1 parent e9bfc93 commit 5f2f8e1

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
2626
protected ClientOptInput opts;
2727
protected Swagger swagger;
2828
protected CodegenIgnoreProcessor ignoreProcessor;
29-
private Boolean generateApis = null;
30-
private Boolean generateModels = null;
31-
private Boolean generateSupportingFiles = null;
32-
private Boolean generateApiTests = null;
33-
private Boolean generateApiDocumentation = null;
34-
private Boolean generateModelTests = null;
35-
private Boolean generateModelDocumentation = null;
36-
private Boolean generateSwaggerMetadata = true;
37-
private String basePath;
38-
private String basePathWithoutHost;
39-
private String contextPath;
29+
protected Boolean generateApis = null;
30+
protected Boolean generateModels = null;
31+
protected Boolean generateSupportingFiles = null;
32+
protected Boolean generateApiTests = null;
33+
protected Boolean generateApiDocumentation = null;
34+
protected Boolean generateModelTests = null;
35+
protected Boolean generateModelDocumentation = null;
36+
protected Boolean generateSwaggerMetadata = true;
37+
protected String basePath;
38+
protected String basePathWithoutHost;
39+
protected String contextPath;
4040
private Map<String, String> generatorPropertyDefaults = new HashMap<>();
4141

4242
@Override
@@ -84,7 +84,7 @@ public void setGeneratorPropertyDefault(final String key, final String value) {
8484
this.generatorPropertyDefaults.put(key, value);
8585
}
8686

87-
private Boolean getGeneratorPropertyDefaultSwitch(final String key, final Boolean defaultValue) {
87+
protected Boolean getGeneratorPropertyDefaultSwitch(final String key, final Boolean defaultValue) {
8888
String result = null;
8989
if (this.generatorPropertyDefaults.containsKey(key)) {
9090
result = this.generatorPropertyDefaults.get(key);
@@ -95,7 +95,7 @@ private Boolean getGeneratorPropertyDefaultSwitch(final String key, final Boolea
9595
return defaultValue;
9696
}
9797

98-
private String getScheme() {
98+
protected String getScheme() {
9999
String scheme;
100100
if (swagger.getSchemes() != null && swagger.getSchemes().size() > 0) {
101101
scheme = config.escapeText(swagger.getSchemes().get(0).toValue());
@@ -122,7 +122,7 @@ private String getHost() {
122122
return hostBuilder.toString();
123123
}
124124

125-
private void configureGeneratorProperties() {
125+
protected void configureGeneratorProperties() {
126126
// allows generating only models by specifying a CSV of models to generate, or empty for all
127127
// NOTE: Boolean.TRUE is required below rather than `true` because of JVM boxing constraints and type inference.
128128
generateApis = System.getProperty(CodegenConstants.APIS) != null ? Boolean.TRUE : getGeneratorPropertyDefaultSwitch(CodegenConstants.APIS, null);
@@ -184,7 +184,7 @@ private void configureGeneratorProperties() {
184184

185185
}
186186

187-
private void configureSwaggerInfo() {
187+
protected void configureSwaggerInfo() {
188188
Info info = swagger.getInfo();
189189
if (info == null) {
190190
return;
@@ -244,7 +244,7 @@ private void configureSwaggerInfo() {
244244
}
245245
}
246246

247-
private void generateModelTests(List<File> files, Map<String, Object> models, String modelName) throws IOException {
247+
protected void generateModelTests(List<File> files, Map<String, Object> models, String modelName) throws IOException {
248248
// to generate model test files
249249
for (String templateName : config.modelTestTemplateFiles().keySet()) {
250250
String suffix = config.modelTestTemplateFiles().get(templateName);
@@ -261,7 +261,7 @@ private void generateModelTests(List<File> files, Map<String, Object> models, St
261261
}
262262
}
263263

264-
private void generateModelDocumentation(List<File> files, Map<String, Object> models, String modelName) throws IOException {
264+
protected void generateModelDocumentation(List<File> files, Map<String, Object> models, String modelName) throws IOException {
265265
for (String templateName : config.modelDocTemplateFiles().keySet()) {
266266
String suffix = config.modelDocTemplateFiles().get(templateName);
267267
String filename = config.modelDocFileFolder() + File.separator + config.toModelDocFilename(modelName) + suffix;
@@ -276,7 +276,7 @@ private void generateModelDocumentation(List<File> files, Map<String, Object> mo
276276
}
277277
}
278278

279-
private void generateModels(List<File> files, List<Object> allModels) {
279+
protected void generateModels(List<File> files, List<Object> allModels) {
280280

281281
if (!generateModels) {
282282
return;
@@ -432,7 +432,7 @@ private Model getParent(Model model) {
432432

433433
}
434434

435-
private void generateApis(List<File> files, List<Object> allOperations, List<Object> allModels) {
435+
protected void generateApis(List<File> files, List<Object> allOperations, List<Object> allModels) {
436436
if (!generateApis) {
437437
return;
438438
}
@@ -554,7 +554,7 @@ public int compare(CodegenOperation one, CodegenOperation another) {
554554

555555
}
556556

557-
private void generateSupportingFiles(List<File> files, Map<String, Object> bundle) {
557+
protected void generateSupportingFiles(List<File> files, Map<String, Object> bundle) {
558558
if (!generateSupportingFiles) {
559559
return;
560560
}
@@ -687,7 +687,7 @@ public Reader getTemplate(String name) {
687687

688688
}
689689

690-
private Map<String, Object> buildSupportFileBundle(List<Object> allOperations, List<Object> allModels) {
690+
protected Map<String, Object> buildSupportFileBundle(List<Object> allOperations, List<Object> allModels) {
691691

692692
Map<String, Object> bundle = new HashMap<String, Object>();
693693
bundle.putAll(config.additionalProperties());
@@ -760,8 +760,7 @@ public List<File> generate() {
760760
return files;
761761
}
762762

763-
764-
private File processTemplateToFile(Map<String, Object> templateData, String templateName, String outputFilename) throws IOException {
763+
protected File processTemplateToFile(Map<String, Object> templateData, String templateName, String outputFilename) throws IOException {
765764
String adjustedOutputFilename = outputFilename.replaceAll("//", "/").replace('/', File.separatorChar);
766765
if (ignoreProcessor.allowsFile(new File(adjustedOutputFilename))) {
767766
String templateFile = getFullTemplateFile(config, templateName);
@@ -786,7 +785,7 @@ public Reader getTemplate(String name) {
786785
return null;
787786
}
788787

789-
private static void processMimeTypes(List<String> mimeTypeList, Map<String, Object> operation, String source) {
788+
protected static void processMimeTypes(List<String> mimeTypeList, Map<String, Object> operation, String source) {
790789
if (mimeTypeList == null || mimeTypeList.isEmpty()) {
791790
return;
792791
}
@@ -824,7 +823,7 @@ public Map<String, List<CodegenOperation>> processPaths(Map<String, Path> paths)
824823
return ops;
825824
}
826825

827-
private void processOperation(String resourcePath, String httpMethod, Operation operation, Map<String, List<CodegenOperation>> operations, Path path) {
826+
protected void processOperation(String resourcePath, String httpMethod, Operation operation, Map<String, List<CodegenOperation>> operations, Path path) {
828827
if (operation == null) {
829828
return;
830829
}
@@ -943,12 +942,12 @@ private void processOperation(String resourcePath, String httpMethod, Operation
943942

944943
}
945944

946-
private static String generateParameterId(Parameter parameter) {
945+
protected static String generateParameterId(Parameter parameter) {
947946
return parameter.getName() + ":" + parameter.getIn();
948947
}
949948

950949

951-
private Map<String, Object> processOperations(CodegenConfig config, String tag, List<CodegenOperation> ops, List<Object> allModels) {
950+
protected Map<String, Object> processOperations(CodegenConfig config, String tag, List<CodegenOperation> ops, List<Object> allModels) {
952951
Map<String, Object> operations = new HashMap<String, Object>();
953952
Map<String, Object> objs = new HashMap<String, Object>();
954953
objs.put("classname", config.toApiName(tag));
@@ -1011,7 +1010,7 @@ private Map<String, Object> processOperations(CodegenConfig config, String tag,
10111010
}
10121011

10131012

1014-
private Map<String, Object> processModels(CodegenConfig config, Map<String, Model> definitions, Map<String, Model> allDefinitions) {
1013+
protected Map<String, Object> processModels(CodegenConfig config, Map<String, Model> definitions, Map<String, Model> allDefinitions) {
10151014
Map<String, Object> objs = new HashMap<String, Object>();
10161015
objs.put("package", config.modelPackage());
10171016
List<Object> models = new ArrayList<Object>();

0 commit comments

Comments
 (0)