Skip to content

Commit 1bb4d42

Browse files
authored
update readme, format code (php flight) (#18492)
* update readme, format code (php flight) * add flight to the list * update samples
1 parent d7b808e commit 1bb4d42

File tree

3 files changed

+48
-44
lines changed

3 files changed

+48
-44
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
8585
| | Languages/Frameworks |
8686
| -------------------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
8787
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **N4JS**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient, pekko), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (9.x - 17.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo**, **Zapier** |
88-
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), [Cask](https://github.com/com-lihaoyi/cask), Scalatra) |
88+
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** ([Flight](https://docs.flightphp.com/), Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), [Cask](https://github.com/com-lihaoyi/cask), Scalatra) |
8989
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
9090
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
9191
| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Postman Collection**, **Protocol Buffer**, **WSDL** |
@@ -1092,6 +1092,7 @@ Here is a list of template creators:
10921092
* Kotlin (Vertx): @Wooyme
10931093
* Kotlin (JAX-RS): @anttileppa
10941094
* NodeJS Express: @YishTish
1095+
* PHP Flight: @daniel-sc
10951096
* PHP Laravel: @renepardon
10961097
* PHP Lumen: @abcsun
10971098
* PHP Mezzio (with Path Handler): @Articus

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpFlightServerCodegen.java

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020

2121
import io.swagger.v3.oas.models.Operation;
2222
import io.swagger.v3.oas.models.servers.Server;
23+
2324
import java.io.File;
2425
import java.util.Arrays;
2526
import java.util.EnumSet;
2627
import java.util.HashSet;
2728
import java.util.List;
2829
import java.util.Objects;
30+
2931
import org.apache.commons.lang3.StringUtils;
3032
import org.openapitools.codegen.CliOption;
3133
import 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

Comments
 (0)