11/*
2+ * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
3+ *
24 * Licensed under the Apache License, Version 2.0 (the "License");
35 * you may not use this file except in compliance with the License.
46 * You may obtain a copy of the License at
@@ -66,7 +68,7 @@ public ScalaHttp4sServerCodegen() {
6668 supportsMultipleInheritance = true ;
6769 supportsInheritance = true ;
6870 supportsMixins = true ;
69- addOneOfInterfaceImports =true ;
71+ addOneOfInterfaceImports = true ;
7072
7173
7274 setReservedWordsLowerCase (
@@ -141,7 +143,6 @@ public ScalaHttp4sServerCodegen() {
141143 additionalProperties .put ("licenseUrl" , "http://apache.org/licenses/LICENSE-2.0.html" );
142144
143145
144-
145146 languageSpecificPrimitives = new HashSet <>(
146147 Arrays .asList (
147148 "String" ,
@@ -197,6 +198,7 @@ public ScalaHttp4sServerCodegen() {
197198 }
198199
199200 private final static Map <String , String > locationStatusToResponse = new HashMap <>();
201+
200202 static {
201203 locationStatusToResponse .put ("300" , "MultipleChoices" );
202204 locationStatusToResponse .put ("301" , "MovedPermanently" );
@@ -207,16 +209,19 @@ public ScalaHttp4sServerCodegen() {
207209 }
208210
209211 private final static Map <String , String > wwwAuthStatusToResponse = new HashMap <>();
212+
210213 static {
211214 wwwAuthStatusToResponse .put ("401" , "Unauthorized" );
212215 }
213216
214217 private final static Map <String , String > allowStatusToResponse = new HashMap <>();
218+
215219 static {
216220 allowStatusToResponse .put ("405" , "MethodNotAllowed" );
217221 }
218222
219223 private final static Map <String , String > proxyAuthStatusToResponse = new HashMap <>();
224+
220225 static {
221226 proxyAuthStatusToResponse .put ("407" , "ProxyAuthenticationRequired" );
222227 }
@@ -314,7 +319,7 @@ public void processOpts() {
314319
315320 apiTemplateFiles .put ("api.mustache" , ".scala" );
316321
317- if (!additionalProperties .containsKey (EXCLUDE_SBT ) && !Boolean .parseBoolean ((String )additionalProperties .get (EXCLUDE_SBT ))) {
322+ if (!additionalProperties .containsKey (EXCLUDE_SBT ) && !Boolean .parseBoolean ((String ) additionalProperties .get (EXCLUDE_SBT ))) {
318323 supportingFiles .add (new SupportingFile ("build.sbt" , "" , "build.sbt" ));
319324 supportingFiles .add (new SupportingFile ("build.properties" , "project" , "build.properties" ));
320325 }
@@ -328,18 +333,18 @@ public Map<String, String> inlineSchemaOption() {
328333
329334 @ Override
330335 public boolean isEnablePostProcessFile () {
331- return true ;
336+ return true ;
332337 }
333338
334339 @ Override
335340 public void postProcessFile (File file , String fileType ) {
336- System . out . println ("postprocess " + file .toString ());
341+ LOGGER . debug ("postprocess " + file .toString ());
337342 super .postProcessFile (file , fileType );
338343 }
339344
340345 @ Override
341346 public Map <String , ModelsMap > postProcessAllModels (Map <String , ModelsMap > objs ) {
342- Map <String , ModelsMap > modelsMap = super .postProcessAllModels (objs );
347+ Map <String , ModelsMap > modelsMap = super .postProcessAllModels (objs );
343348
344349 for (ModelsMap mm : modelsMap .values ()) {
345350 for (ModelMap model : mm .getModels ()) {
@@ -367,7 +372,7 @@ public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs)
367372
368373 // add refined constraints
369374
370- for (CodegenProperty prop : cModel .vars ) {
375+ for (CodegenProperty prop : cModel .vars ) {
371376 Set <String > imports = new TreeSet <>();
372377
373378 prop .getVendorExtensions ().putAll (refineProp (prop , imports ));
@@ -389,8 +394,8 @@ private Map<String, Object> makeRefiined(Set<String> imports, String dataType, A
389394
390395 vendorExtensions .put ("x-type" , "Refined[" + dataType + ", " + refinedRgt + "]" );
391396 vendorExtensions .put ("x-refined-lft" , dataType );
392- vendorExtensions .put ("x-refined-rgt" , refinedRgt );
393- vendorExtensions .put ("x-refined" , true );
397+ vendorExtensions .put ("x-refined-rgt" , refinedRgt );
398+ vendorExtensions .put ("x-refined" , true );
394399 } else {
395400 vendorExtensions .put ("x-type" , dataType );
396401 }
@@ -407,8 +412,8 @@ private Map<String, Object> refineProp(IJsonSchemaValidationProperties prop, Set
407412 ArrayList <String > refined = new ArrayList <>();
408413
409414 if (prop .getMinLength () != null ) {
410- refined .add ("MinSize[" + prop .getMinLength () + "]" );
411- imports .add ("MinSize" );
415+ refined .add ("MinSize[" + prop .getMinLength () + "]" );
416+ imports .add ("MinSize" );
412417 }
413418 if (prop .getMaxLength () != null ) {
414419 refined .add ("MaxSize[" + prop .getMaxLength () + "]" );
@@ -485,7 +490,7 @@ public Map<String, Object> postProcessSupportingFileData(Map<String, Object> obj
485490
486491 List <ModelMap > models = (List <ModelMap >) bundle .get ("models" );
487492 TreeSet <String > allImports = new TreeSet <>();
488- for (ModelMap mm : models ) {
493+ for (ModelMap mm : models ) {
489494 for (String nextImport : mm .getModel ().imports ) {
490495 String mapping = importMapping ().get (nextImport );
491496 if (mapping != null && !defaultIncludes ().contains (mapping )) {
@@ -504,9 +509,9 @@ public Map<String, Object> postProcessSupportingFileData(Map<String, Object> obj
504509
505510 ApiInfoMap apiInfoMap = (ApiInfoMap ) bundle .get ("apiInfo" );
506511 Map <String , List <String >> authToOperationMap = new TreeMap <>();
507- for (OperationsMap op : apiInfoMap .getApis ()) {
512+ for (OperationsMap op : apiInfoMap .getApis ()) {
508513 List <HashMap <String , Object >> opsByAuth = (List <HashMap <String , Object >>) op .get ("operationsByAuth" );
509- for (HashMap <String , Object > auth : opsByAuth ) {
514+ for (HashMap <String , Object > auth : opsByAuth ) {
510515 String autName = (String ) auth .get ("auth" );
511516 String classname = (String ) op .get ("classname" );
512517 List <String > classnames = authToOperationMap .computeIfAbsent (autName , k -> new ArrayList <>());
@@ -549,7 +554,7 @@ public String escapeReservedWord(String name) {
549554
550555 @ Override
551556 public String apiFileFolder () {
552- return outputFolder + File .separator + apiFileFolderRelative () ;
557+ return outputFolder + File .separator + apiFileFolderRelative ();
553558 }
554559
555560 private String apiFileFolderRelative () {
@@ -599,7 +604,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objsI, List<M
599604 }
600605
601606 // decide wat methods do we need in responses:
602- for (CodegenResponse resp : op .responses ) {
607+ for (CodegenResponse resp : op .responses ) {
603608 if (resp .code .equals ("0" ))
604609 resp .code = "200" ; // 200 by default
605610
@@ -649,11 +654,11 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objsI, List<M
649654 }
650655
651656 if (op .authMethods != null ) {
652- for (CodegenSecurity cs : op .authMethods ) {
657+ for (CodegenSecurity cs : op .authMethods ) {
653658 allAuth .add (cs .name );
654659 }
655660 List <Map <String , Object >> authDup = new ArrayList <>();
656- for (CodegenSecurity authMeth : op .authMethods ) {
661+ for (CodegenSecurity authMeth : op .authMethods ) {
657662 Map <String , Object > vals = new HashMap <>();
658663 vals .put ("authName" , authMeth .name );
659664 vals .put ("operation" , op );
@@ -781,7 +786,7 @@ private void generateScalaPath(CodegenOperation op) {
781786 op .imports .addAll (imports );
782787 }
783788
784- private String cpToPathParameter (CodegenParameter cp , Set <String > imports , Map <String , Object > vendorExtensions ) {
789+ private String cpToPathParameter (CodegenParameter cp , Set <String > imports , Map <String , Object > vendorExtensions ) {
785790 // don't support containers and arrays yet, reset to string
786791 if (cp .isContainer || cp .isArray ) {
787792 cp .setDataType ("String" );
@@ -809,20 +814,20 @@ private void generateQueryParameters(CodegenOperation op) {
809814 String queryString = "" ;
810815
811816 for (CodegenParameter cp : op .queryParams ) {
812- if (queryString .isEmpty ()) {
813- queryString = queryString + " :? " ;
814- } else {
815- queryString = queryString + " +& " ;
816- }
817+ if (queryString .isEmpty ()) {
818+ queryString = queryString + " :? " ;
819+ } else {
820+ queryString = queryString + " +& " ;
821+ }
817822
818- queryString = queryString + cpToQueryParameter (cp , imports , cp .vendorExtensions );
823+ queryString = queryString + cpToQueryParameter (cp , imports , cp .vendorExtensions );
819824 }
820825
821826 op .vendorExtensions .put ("x-codegen-query" , queryString );
822827 op .imports .addAll (imports );
823828 }
824829
825- private String cpToQueryParameter (CodegenParameter cp , Set <String > imports , Map <String , Object > vendorExtensions ) {
830+ private String cpToQueryParameter (CodegenParameter cp , Set <String > imports , Map <String , Object > vendorExtensions ) {
826831 // don't support containers and arrays yet, reset to string
827832 if (cp .isContainer && !cp .isArray ) {
828833 cp .setDataType ("String" );
@@ -848,5 +853,7 @@ public void postProcess() {
848853 }
849854
850855 @ Override
851- public GeneratorLanguage generatorLanguage () { return GeneratorLanguage .SCALA ; }
856+ public GeneratorLanguage generatorLanguage () {
857+ return GeneratorLanguage .SCALA ;
858+ }
852859}
0 commit comments