@@ -26,17 +26,17 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
26
26
protected ClientOptInput opts ;
27
27
protected Swagger swagger ;
28
28
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 ;
40
40
private Map <String , String > generatorPropertyDefaults = new HashMap <>();
41
41
42
42
@ Override
@@ -84,7 +84,7 @@ public void setGeneratorPropertyDefault(final String key, final String value) {
84
84
this .generatorPropertyDefaults .put (key , value );
85
85
}
86
86
87
- private Boolean getGeneratorPropertyDefaultSwitch (final String key , final Boolean defaultValue ) {
87
+ protected Boolean getGeneratorPropertyDefaultSwitch (final String key , final Boolean defaultValue ) {
88
88
String result = null ;
89
89
if (this .generatorPropertyDefaults .containsKey (key )) {
90
90
result = this .generatorPropertyDefaults .get (key );
@@ -95,7 +95,7 @@ private Boolean getGeneratorPropertyDefaultSwitch(final String key, final Boolea
95
95
return defaultValue ;
96
96
}
97
97
98
- private String getScheme () {
98
+ protected String getScheme () {
99
99
String scheme ;
100
100
if (swagger .getSchemes () != null && swagger .getSchemes ().size () > 0 ) {
101
101
scheme = config .escapeText (swagger .getSchemes ().get (0 ).toValue ());
@@ -122,7 +122,7 @@ private String getHost() {
122
122
return hostBuilder .toString ();
123
123
}
124
124
125
- private void configureGeneratorProperties () {
125
+ protected void configureGeneratorProperties () {
126
126
// allows generating only models by specifying a CSV of models to generate, or empty for all
127
127
// NOTE: Boolean.TRUE is required below rather than `true` because of JVM boxing constraints and type inference.
128
128
generateApis = System .getProperty (CodegenConstants .APIS ) != null ? Boolean .TRUE : getGeneratorPropertyDefaultSwitch (CodegenConstants .APIS , null );
@@ -184,7 +184,7 @@ private void configureGeneratorProperties() {
184
184
185
185
}
186
186
187
- private void configureSwaggerInfo () {
187
+ protected void configureSwaggerInfo () {
188
188
Info info = swagger .getInfo ();
189
189
if (info == null ) {
190
190
return ;
@@ -244,7 +244,7 @@ private void configureSwaggerInfo() {
244
244
}
245
245
}
246
246
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 {
248
248
// to generate model test files
249
249
for (String templateName : config .modelTestTemplateFiles ().keySet ()) {
250
250
String suffix = config .modelTestTemplateFiles ().get (templateName );
@@ -261,7 +261,7 @@ private void generateModelTests(List<File> files, Map<String, Object> models, St
261
261
}
262
262
}
263
263
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 {
265
265
for (String templateName : config .modelDocTemplateFiles ().keySet ()) {
266
266
String suffix = config .modelDocTemplateFiles ().get (templateName );
267
267
String filename = config .modelDocFileFolder () + File .separator + config .toModelDocFilename (modelName ) + suffix ;
@@ -276,7 +276,7 @@ private void generateModelDocumentation(List<File> files, Map<String, Object> mo
276
276
}
277
277
}
278
278
279
- private void generateModels (List <File > files , List <Object > allModels ) {
279
+ protected void generateModels (List <File > files , List <Object > allModels ) {
280
280
281
281
if (!generateModels ) {
282
282
return ;
@@ -432,7 +432,7 @@ private Model getParent(Model model) {
432
432
433
433
}
434
434
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 ) {
436
436
if (!generateApis ) {
437
437
return ;
438
438
}
@@ -554,7 +554,7 @@ public int compare(CodegenOperation one, CodegenOperation another) {
554
554
555
555
}
556
556
557
- private void generateSupportingFiles (List <File > files , Map <String , Object > bundle ) {
557
+ protected void generateSupportingFiles (List <File > files , Map <String , Object > bundle ) {
558
558
if (!generateSupportingFiles ) {
559
559
return ;
560
560
}
@@ -687,7 +687,7 @@ public Reader getTemplate(String name) {
687
687
688
688
}
689
689
690
- private Map <String , Object > buildSupportFileBundle (List <Object > allOperations , List <Object > allModels ) {
690
+ protected Map <String , Object > buildSupportFileBundle (List <Object > allOperations , List <Object > allModels ) {
691
691
692
692
Map <String , Object > bundle = new HashMap <String , Object >();
693
693
bundle .putAll (config .additionalProperties ());
@@ -760,8 +760,7 @@ public List<File> generate() {
760
760
return files ;
761
761
}
762
762
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 {
765
764
String adjustedOutputFilename = outputFilename .replaceAll ("//" , "/" ).replace ('/' , File .separatorChar );
766
765
if (ignoreProcessor .allowsFile (new File (adjustedOutputFilename ))) {
767
766
String templateFile = getFullTemplateFile (config , templateName );
@@ -786,7 +785,7 @@ public Reader getTemplate(String name) {
786
785
return null ;
787
786
}
788
787
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 ) {
790
789
if (mimeTypeList == null || mimeTypeList .isEmpty ()) {
791
790
return ;
792
791
}
@@ -824,7 +823,7 @@ public Map<String, List<CodegenOperation>> processPaths(Map<String, Path> paths)
824
823
return ops ;
825
824
}
826
825
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 ) {
828
827
if (operation == null ) {
829
828
return ;
830
829
}
@@ -943,12 +942,12 @@ private void processOperation(String resourcePath, String httpMethod, Operation
943
942
944
943
}
945
944
946
- private static String generateParameterId (Parameter parameter ) {
945
+ protected static String generateParameterId (Parameter parameter ) {
947
946
return parameter .getName () + ":" + parameter .getIn ();
948
947
}
949
948
950
949
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 ) {
952
951
Map <String , Object > operations = new HashMap <String , Object >();
953
952
Map <String , Object > objs = new HashMap <String , Object >();
954
953
objs .put ("classname" , config .toApiName (tag ));
@@ -1011,7 +1010,7 @@ private Map<String, Object> processOperations(CodegenConfig config, String tag,
1011
1010
}
1012
1011
1013
1012
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 ) {
1015
1014
Map <String , Object > objs = new HashMap <String , Object >();
1016
1015
objs .put ("package" , config .modelPackage ());
1017
1016
List <Object > models = new ArrayList <Object >();
0 commit comments