20
20
21
21
import io .swagger .v3 .oas .models .Operation ;
22
22
import io .swagger .v3 .oas .models .servers .Server ;
23
+
23
24
import java .io .File ;
24
25
import java .util .Arrays ;
25
26
import java .util .EnumSet ;
26
27
import java .util .HashSet ;
27
28
import java .util .List ;
28
29
import java .util .Objects ;
30
+
29
31
import org .apache .commons .lang3 .StringUtils ;
30
32
import org .openapitools .codegen .CliOption ;
31
33
import org .openapitools .codegen .CodegenConstants ;
@@ -57,49 +59,49 @@ public class PhpFlightServerCodegen extends AbstractPhpCodegen {
57
59
// Type-hintable primitive types
58
60
// ref: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
59
61
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
+ )
67
69
);
68
70
69
71
public PhpFlightServerCodegen () {
70
72
super ();
71
73
72
74
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
+ )
98
100
);
99
101
100
102
generatorMetadata = GeneratorMetadata .newBuilder (generatorMetadata )
101
- .stability (Stability .EXPERIMENTAL )
102
- .build ();
103
+ .stability (Stability .EXPERIMENTAL )
104
+ .build ();
103
105
104
106
embeddedTemplateDir = templateDir = "php-flight" ;
105
107
@@ -110,9 +112,9 @@ public PhpFlightServerCodegen() {
110
112
srcBasePath = "" ;
111
113
112
114
defaultIncludes = new HashSet <>(
113
- Arrays .asList (
114
- "\\ DateTime"
115
- )
115
+ Arrays .asList (
116
+ "\\ DateTime"
117
+ )
116
118
);
117
119
118
120
variableNamingConvention = "camelCase" ;
@@ -131,7 +133,7 @@ public PhpFlightServerCodegen() {
131
133
embeddedTemplateDir = templateDir = "php-flight" ;
132
134
133
135
cliOptions .add (new CliOption (CodegenConstants .HIDE_GENERATION_TIMESTAMP , CodegenConstants .HIDE_GENERATION_TIMESTAMP_DESC )
134
- .defaultValue (Boolean .TRUE .toString ()));
136
+ .defaultValue (Boolean .TRUE .toString ()));
135
137
cliOptions .stream ().filter (o -> Objects .equals (o .getOpt (), VARIABLE_NAMING_CONVENTION )).findFirst ().ifPresent (o -> o .defaultValue ("camelCase" ));
136
138
}
137
139
@@ -204,7 +206,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
204
206
operation .vendorExtensions .put ("x-return-type" , returnType );
205
207
operation .vendorExtensions .put ("x-return-type-is-void" , returnType .equals ("void" ));
206
208
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" ));
208
210
operation .vendorExtensions .put ("x-nonFormParams" , operation .allParams .stream ().filter (p -> !p .isFormParam ).toArray ());
209
211
210
212
operation .allParams .forEach (param -> {
@@ -314,9 +316,9 @@ public String toApiTestFilename(String name) {
314
316
315
317
@ Override
316
318
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 ) {
320
322
CodegenOperation op = super .fromOperation (path , httpMethod , operation , servers );
321
323
op .path = encodePath (path );
322
324
return op ;
0 commit comments