Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements to the php-dt generator #10159

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ The following generators are available:
* [k6 (beta)](generators/k6.md)
* [kotlin](generators/kotlin.md)
* [lua (beta)](generators/lua.md)
* [micronaut-client](generators/micronaut-client.md)
* [nim (beta)](generators/nim.md)
* [objc](generators/objc.md)
* [ocaml](generators/ocaml.md)
* [perl](generators/perl.md)
* [php](generators/php.md)
* [php-dt](generators/php-dt.md)
* [php-dt (beta)](generators/php-dt.md)
* [powershell (beta)](generators/powershell.md)
* [python (experimental)](generators/python.md)
* [python-legacy](generators/python-legacy.md)
Expand Down
1 change: 1 addition & 0 deletions docs/generators/php-dt.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl

<ul class="column-ul">
<li>DateTime</li>
<li>array</li>
<li>bool</li>
<li>boolean</li>
<li>byte</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.responses.ApiResponses;
import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -63,7 +68,7 @@ public String getName() {

@Override
public String getHelp() {
return "Generates PHP client relying on Data Transfer ( https://github.com/Articus/DataTransfer ) and compliant with PSR-7, PSR-11, PSR-17 and PSR-18.";
return "Generates a PHP client relying on Data Transfer ( https://github.com/Articus/DataTransfer ) and compliant with PSR-7, PSR-11, PSR-17 and PSR-18.";
}

public PhpDataTransferClientCodegen() {
Expand All @@ -83,6 +88,10 @@ public PhpDataTransferClientCodegen() {
)
);

generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
.build();

//no point to use double - http://php.net/manual/en/language.types.float.php , especially because of PHP 7+ float type declaration
typeMapping.put("double", "float");

Expand Down Expand Up @@ -359,7 +368,7 @@ protected void generateContainerSchemas(OpenAPI openAPI) {
* Generate additional model definitions for containers in specified schema
*
* @param openAPI OpenAPI object
* @param schema OAS schema to process
* @param schema OAS schema to process
*/
protected void generateContainerSchemas(OpenAPI openAPI, Schema schema) {
if (schema != null) {
Expand All @@ -371,7 +380,7 @@ protected void generateContainerSchemas(OpenAPI openAPI, Schema schema) {
//Recursively process all schemas of object properties
Map<String, Schema> properties = schema.getProperties();
if (properties != null) {
for (String propertyName: properties.keySet()) {
for (String propertyName : properties.keySet()) {
generateContainerSchemas(openAPI, properties.get(propertyName));
}
}
Expand Down Expand Up @@ -415,7 +424,7 @@ protected void quoteMediaTypes(OpenAPI openAPI) {
PathItem path = paths.get(pathname);
List<Operation> operations = path.readOperations();
if (operations != null) {
for (Operation operation: operations) {
for (Operation operation : operations) {
RequestBody requestBody = ModelUtils.getReferencedRequestBody(openAPI, operation.getRequestBody());
if (requestBody != null) {
requestBody.setContent(copyWithQuotedMediaTypes(requestBody.getContent()));
Expand All @@ -435,7 +444,7 @@ protected Content copyWithQuotedMediaTypes(Content content) {
Content result = null;
if (content != null) {
result = new Content();
for (String mediaType: content.keySet()) {
for (String mediaType : content.keySet()) {
result.addMediaType("'" + mediaType + "'", content.get(mediaType));
}
}
Expand Down