2020
2121import io .swagger .v3 .oas .models .Operation ;
2222import io .swagger .v3 .oas .models .servers .Server ;
23+
2324import java .io .File ;
2425import java .util .Arrays ;
2526import java .util .EnumSet ;
2627import java .util .HashSet ;
2728import java .util .List ;
2829import java .util .Objects ;
30+
2931import org .apache .commons .lang3 .StringUtils ;
3032import org .openapitools .codegen .CliOption ;
3133import org .openapitools .codegen .CodegenConstants ;
@@ -57,49 +59,49 @@ public class PhpFlightServerCodegen extends AbstractPhpCodegen {
5759 // Type-hintable primitive types
5860 // ref: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
5961 protected HashSet <String > typeHintable = new HashSet <>(
60- Arrays .asList (
61- "array" ,
62- "bool" ,
63- "float" ,
64- "int" ,
65- "string"
66- )
62+ Arrays .asList (
63+ "array" ,
64+ "bool" ,
65+ "float" ,
66+ "int" ,
67+ "string"
68+ )
6769 );
6870
6971 public PhpFlightServerCodegen () {
7072 super ();
7173
7274 modifyFeatureSet (features -> features
73- .includeDocumentationFeatures (DocumentationFeature .Readme )
74- .wireFormatFeatures (EnumSet .of (WireFormatFeature .JSON ))
75- .securityFeatures (EnumSet .of (
76- SecurityFeature .BasicAuth ,
77- SecurityFeature .BearerToken ,
78- SecurityFeature .ApiKey ,
79- SecurityFeature .OAuth2_Implicit ))
80- .excludeDataTypeFeatures (
81- DataTypeFeature .MapOfCollectionOfEnum ,
82- DataTypeFeature .MapOfEnum ,
83- DataTypeFeature .MapOfCollectionOfModel ,
84- DataTypeFeature .MapOfModel )
85- .excludeParameterFeatures (
86- ParameterFeature .FormMultipart ,
87- ParameterFeature .FormUnencoded ,
88- ParameterFeature .Cookie )
89- .excludeGlobalFeatures (
90- GlobalFeature .XMLStructureDefinitions ,
91- GlobalFeature .Callbacks ,
92- GlobalFeature .LinkObjects ,
93- GlobalFeature .ParameterStyling
94- )
95- .excludeSchemaSupportFeatures (
96- SchemaSupportFeature .Polymorphism
97- )
75+ .includeDocumentationFeatures (DocumentationFeature .Readme )
76+ .wireFormatFeatures (EnumSet .of (WireFormatFeature .JSON ))
77+ .securityFeatures (EnumSet .of (
78+ SecurityFeature .BasicAuth ,
79+ SecurityFeature .BearerToken ,
80+ SecurityFeature .ApiKey ,
81+ SecurityFeature .OAuth2_Implicit ))
82+ .excludeDataTypeFeatures (
83+ DataTypeFeature .MapOfCollectionOfEnum ,
84+ DataTypeFeature .MapOfEnum ,
85+ DataTypeFeature .MapOfCollectionOfModel ,
86+ DataTypeFeature .MapOfModel )
87+ .excludeParameterFeatures (
88+ ParameterFeature .FormMultipart ,
89+ ParameterFeature .FormUnencoded ,
90+ ParameterFeature .Cookie )
91+ .excludeGlobalFeatures (
92+ GlobalFeature .XMLStructureDefinitions ,
93+ GlobalFeature .Callbacks ,
94+ GlobalFeature .LinkObjects ,
95+ GlobalFeature .ParameterStyling
96+ )
97+ .excludeSchemaSupportFeatures (
98+ SchemaSupportFeature .Polymorphism
99+ )
98100 );
99101
100102 generatorMetadata = GeneratorMetadata .newBuilder (generatorMetadata )
101- .stability (Stability .EXPERIMENTAL )
102- .build ();
103+ .stability (Stability .EXPERIMENTAL )
104+ .build ();
103105
104106 embeddedTemplateDir = templateDir = "php-flight" ;
105107
@@ -110,9 +112,9 @@ public PhpFlightServerCodegen() {
110112 srcBasePath = "" ;
111113
112114 defaultIncludes = new HashSet <>(
113- Arrays .asList (
114- "\\ DateTime"
115- )
115+ Arrays .asList (
116+ "\\ DateTime"
117+ )
116118 );
117119
118120 variableNamingConvention = "camelCase" ;
@@ -131,7 +133,7 @@ public PhpFlightServerCodegen() {
131133 embeddedTemplateDir = templateDir = "php-flight" ;
132134
133135 cliOptions .add (new CliOption (CodegenConstants .HIDE_GENERATION_TIMESTAMP , CodegenConstants .HIDE_GENERATION_TIMESTAMP_DESC )
134- .defaultValue (Boolean .TRUE .toString ()));
136+ .defaultValue (Boolean .TRUE .toString ()));
135137 cliOptions .stream ().filter (o -> Objects .equals (o .getOpt (), VARIABLE_NAMING_CONVENTION )).findFirst ().ifPresent (o -> o .defaultValue ("camelCase" ));
136138 }
137139
@@ -204,7 +206,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
204206 operation .vendorExtensions .put ("x-return-type" , returnType );
205207 operation .vendorExtensions .put ("x-return-type-is-void" , returnType .equals ("void" ));
206208 operation .vendorExtensions .put ("x-return-type-comment" ,
207- operation .responses .stream ().filter (r -> r .is2xx && r .dataType != null ).map (r -> this .getTypeHint (r .dataType , true , false )).filter (t -> !t .isEmpty ()).map (t -> t + "|null" ).findFirst ().orElse ("void" ));
209+ operation .responses .stream ().filter (r -> r .is2xx && r .dataType != null ).map (r -> this .getTypeHint (r .dataType , true , false )).filter (t -> !t .isEmpty ()).map (t -> t + "|null" ).findFirst ().orElse ("void" ));
208210 operation .vendorExtensions .put ("x-nonFormParams" , operation .allParams .stream ().filter (p -> !p .isFormParam ).toArray ());
209211
210212 operation .allParams .forEach (param -> {
@@ -314,9 +316,9 @@ public String toApiTestFilename(String name) {
314316
315317 @ Override
316318 public CodegenOperation fromOperation (String path ,
317- String httpMethod ,
318- Operation operation ,
319- List <Server > servers ) {
319+ String httpMethod ,
320+ Operation operation ,
321+ List <Server > servers ) {
320322 CodegenOperation op = super .fromOperation (path , httpMethod , operation , servers );
321323 op .path = encodePath (path );
322324 return op ;
0 commit comments