@@ -85,28 +85,32 @@ public CrystalClientCodegen() {
8585 SecurityFeature .BasicAuth ,
8686 SecurityFeature .BearerToken ,
8787 SecurityFeature .ApiKey ,
88- SecurityFeature .OAuth2_Implicit ))
88+ SecurityFeature .OAuth2_Implicit
89+ ))
8990 .excludeGlobalFeatures (
9091 GlobalFeature .XMLStructureDefinitions ,
9192 GlobalFeature .Callbacks ,
9293 GlobalFeature .LinkObjects ,
9394 GlobalFeature .ParameterStyling ,
9495 GlobalFeature .ParameterizedServer ,
95- GlobalFeature .MultiServer )
96+ GlobalFeature .MultiServer
97+ )
9698 .includeSchemaSupportFeatures (
97- SchemaSupportFeature .Polymorphism )
99+ SchemaSupportFeature .Polymorphism
100+ )
98101 .excludeParameterFeatures (
99- ParameterFeature .Cookie )
102+ ParameterFeature .Cookie
103+ )
100104 .includeClientModificationFeatures (
101105 ClientModificationFeature .BasePath ,
102- ClientModificationFeature .UserAgent ));
103-
104- generatorMetadata = GeneratorMetadata .newBuilder (generatorMetadata )
105- .stability (Stability .BETA )
106- .build ();
106+ ClientModificationFeature .UserAgent
107+ )
108+ );
107109
108110 supportsInheritance = true ;
109111
112+ generatorMetadata = GeneratorMetadata .newBuilder (generatorMetadata ).stability (Stability .BETA ).build ();
113+
110114 // clear import mapping (from default generator) as crystal does not use it
111115 // at the moment
112116 importMapping .clear ();
@@ -188,8 +192,7 @@ public CrystalClientCodegen() {
188192 primitiveTypes = new ArrayList <String >(typeMapping .values ());
189193
190194 // remove modelPackage and apiPackage added by default
191- cliOptions .removeIf (opt -> CodegenConstants .MODEL_PACKAGE .equals (opt .getOpt ()) ||
192- CodegenConstants .API_PACKAGE .equals (opt .getOpt ()));
195+ cliOptions .removeIf (opt -> CodegenConstants .MODEL_PACKAGE .equals (opt .getOpt ()) || CodegenConstants .API_PACKAGE .equals (opt .getOpt ()));
193196
194197 cliOptions .add (new CliOption (SHARD_NAME , "shard name (e.g. twitter_client" ).defaultValue ("openapi_client" ));
195198
@@ -207,8 +210,7 @@ public CrystalClientCodegen() {
207210
208211 cliOptions .add (new CliOption (SHARD_AUTHOR_EMAIL , "shard author email (only one is supported)." ));
209212
210- cliOptions .add (new CliOption (CodegenConstants .HIDE_GENERATION_TIMESTAMP ,
211- CodegenConstants .HIDE_GENERATION_TIMESTAMP_DESC ).defaultValue (Boolean .TRUE .toString ()));
213+ cliOptions .add (new CliOption (CodegenConstants .HIDE_GENERATION_TIMESTAMP , CodegenConstants .HIDE_GENERATION_TIMESTAMP_DESC ).defaultValue (Boolean .TRUE .toString ()));
212214
213215 cliOptions .add (new CliOption (PARAMS_ENCODER ,
214216 "params_encoder setting (e.g. Crest::NestedParamsEncoder, Crest::EnumeratedFlatParamsEncoder, Crest::ZeroEnumeratedFlatParamsEncoder" ).
@@ -220,8 +222,7 @@ public void processOpts() {
220222 super .processOpts ();
221223
222224 if (StringUtils .isEmpty (System .getenv ("CRYSTAL_POST_PROCESS_FILE" ))) {
223- LOGGER .info (
224- "Hint: Environment variable 'CRYSTAL_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export CRYSTAL_POST_PROCESS_FILE=\" /usr/local/bin/crystal tool format\" ' (Linux/Mac)" );
225+ LOGGER .info ("Hint: Environment variable 'CRYSTAL_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export CRYSTAL_POST_PROCESS_FILE=\" /usr/local/bin/crystal tool format\" ' (Linux/Mac)" );
225226 } else if (!this .isEnablePostProcessFile ()) {
226227 LOGGER .info ("Warning: Environment variable 'CRYSTAL_POST_PROCESS_FILE' is set but file post-processing is not enabled. To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)." );
227228 }
@@ -294,14 +295,12 @@ public void processOpts() {
294295 supportingFiles .add (new SupportingFile ("shard.mustache" , "" , "shard.yml" ));
295296
296297 // crystal spec files
297- supportingFiles .add (new SupportingFile ("spec_helper.mustache" , specFolder , "spec_helper.cr" )
298- .doNotOverwrite ());
298+ supportingFiles .add (new SupportingFile ("spec_helper.mustache" , specFolder , "spec_helper.cr" ).doNotOverwrite ());
299299
300300 // add lambda for mustache templates
301301 additionalProperties .put ("lambdaPrefixWithHash" , new PrefixWithHashLambda ());
302302 additionalProperties .put ("lambdaUppercase" , new UppercaseLambda ());
303303 additionalProperties .put ("lambdaTitlecase" , new TitlecaseLambda ());
304-
305304 }
306305
307306 @ Override
@@ -407,9 +406,9 @@ public String toModelName(final String name) {
407406
408407 // model name starts with number
409408 if (modelName .matches ("^\\ d.*" )) {
410- LOGGER .warn ("{} (model name starts with number) cannot be used as model name. Renamed to {}" , modelName ,
411- camelize ( "model_" + modelName ));
412- modelName = "model_" + modelName ; // e.g. 200Response => Model200Response (after camelize)
409+ LOGGER .warn ("{} (model name starts with number) cannot be used as model name. Renamed to {}" , modelName , camelize ( "model_" + modelName ));
410+ // e.g. 200Response => Model200Response (after camelize)
411+ modelName = "model_" + modelName ;
413412 }
414413
415414 // camelize the model name
@@ -548,8 +547,7 @@ public String toOperationId(String operationId) {
548547
549548 // operationId starts with a number
550549 if (operationId .matches ("^\\ d.*" )) {
551- LOGGER .warn ("{} (starting with a number) cannot be used as method name. Renamed to {}" , operationId ,
552- underscore (sanitizeName ("call_" + operationId )));
550+ LOGGER .warn ("{} (starting with a number) cannot be used as method name. Renamed to {}" , operationId , underscore (sanitizeName ("call_" + operationId )));
553551 operationId = "call_" + operationId ;
554552 }
555553
@@ -576,6 +574,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
576574 if (isSkipOperationExample ()) {
577575 return objs ;
578576 }
577+
579578 OperationMap operations = objs .getOperations ();
580579 HashMap <String , CodegenModel > modelMaps = ModelMap .toCodegenModelMap (allModels );
581580 HashMap <String , Integer > processedModelMaps = new HashMap <>();
@@ -607,8 +606,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
607606 return objs ;
608607 }
609608
610- private String constructExampleCode (CodegenParameter codegenParameter , HashMap <String , CodegenModel > modelMaps ,
611- HashMap <String , Integer > processedModelMap ) {
609+ private String constructExampleCode (CodegenParameter codegenParameter , HashMap <String , CodegenModel > modelMaps , HashMap <String , Integer > processedModelMap ) {
612610 if (codegenParameter .isArray ) { // array
613611 if (codegenParameter .items == null ) {
614612 return "[]" ;
@@ -675,8 +673,7 @@ private String constructExampleCode(CodegenParameter codegenParameter, HashMap<S
675673 }
676674 }
677675
678- private String constructExampleCode (CodegenProperty codegenProperty , HashMap <String , CodegenModel > modelMaps ,
679- HashMap <String , Integer > processedModelMap ) {
676+ private String constructExampleCode (CodegenProperty codegenProperty , HashMap <String , CodegenModel > modelMaps , HashMap <String , Integer > processedModelMap ) {
680677 if (codegenProperty .isArray ) { // array
681678 return "[" + constructExampleCode (codegenProperty .items , modelMaps , processedModelMap ) + "]" ;
682679 } else if (codegenProperty .isMap ) {
@@ -743,8 +740,7 @@ private String constructExampleCode(CodegenProperty codegenProperty, HashMap<Str
743740 }
744741 }
745742
746- private String constructExampleCode (CodegenModel codegenModel , HashMap <String , CodegenModel > modelMaps ,
747- HashMap <String , Integer > processedModelMap ) {
743+ private String constructExampleCode (CodegenModel codegenModel , HashMap <String , CodegenModel > modelMaps , HashMap <String , Integer > processedModelMap ) {
748744 // break infinite recursion. Return, in case a model is already processed in the
749745 // current context.
750746 String model = codegenModel .name ;
@@ -758,8 +754,7 @@ private String constructExampleCode(CodegenModel codegenModel, HashMap<String, C
758754 throw new RuntimeException ("Invalid count when constructing example: " + count );
759755 }
760756 } else if (codegenModel .isEnum ) {
761- List <Map <String , String >> enumVars = (List <Map <String , String >>) codegenModel .allowableValues
762- .get ("enumVars" );
757+ List <Map <String , String >> enumVars = (List <Map <String , String >>) codegenModel .allowableValues .get ("enumVars" );
763758 return moduleName + "::" + codegenModel .classname + "::" + enumVars .get (0 ).get ("name" );
764759 } else if (codegenModel .oneOf != null && !codegenModel .oneOf .isEmpty ()) {
765760 String subModel = (String ) codegenModel .oneOf .toArray ()[0 ];
0 commit comments