diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 72eaec1cda00..96102e6981df 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -1110,7 +1110,7 @@ public void setParameterExampleValue(CodegenParameter codegenParameter) { * Return the example value of the parameter. * * @param codegenParameter Codegen parameter - * @param parameter Parameter + * @param parameter Parameter */ public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) { if (parameter.getExample() != null) { @@ -1120,7 +1120,7 @@ public void setParameterExampleValue(CodegenParameter codegenParameter, Paramete if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) { Example example = parameter.getExamples().values().iterator().next(); - if(example.getValue() != null) { + if (example.getValue() != null) { codegenParameter.example = example.getValue().toString(); return; } @@ -1139,7 +1139,7 @@ public void setParameterExampleValue(CodegenParameter codegenParameter, Paramete * Return the example value of the parameter. * * @param codegenParameter Codegen parameter - * @param requestBody Request body + * @param requestBody Request body */ public void setParameterExampleValue(CodegenParameter codegenParameter, RequestBody requestBody) { Content content = requestBody.getContent(); @@ -1157,7 +1157,7 @@ public void setParameterExampleValue(CodegenParameter codegenParameter, RequestB if (mediaType.getExamples() != null && !mediaType.getExamples().isEmpty()) { Example example = mediaType.getExamples().values().iterator().next(); - if(example.getValue() != null) { + if (example.getValue() != null) { codegenParameter.example = example.getValue().toString(); return; } @@ -1614,7 +1614,7 @@ public CodegenModel fromModel(String name, Schema schema, Map al m.isInteger = Boolean.TRUE; } } - if (ModelUtils.isStringSchema(schema)){ + if (ModelUtils.isStringSchema(schema)) { m.isString = Boolean.TRUE; } @@ -4373,15 +4373,32 @@ public CodegenParameter fromRequestBody(RequestBody body, Map sc if (schema.getAdditionalProperties() != null) {// http body is map LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue."); } else if (codegenProperty != null) { + String codegenModelName, codegenModelDescription; + + if (codegenModel != null) { + codegenModelName = codegenModel.classname; + codegenModelDescription = codegenModel.description; + } else { + LOGGER.warn("The following schema has undefined (null) baseType. " + + "It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " + + "A correct 'consumes' for form parameters should be " + + "'application/x-www-form-urlencoded' or 'multipart/form-data'"); + LOGGER.warn("schema: " + schema); + LOGGER.warn("codegenModel is null. Default to UNKNOWN_BASE_TYPE"); + codegenModelName = "UNKNOWN_BASE_TYPE"; + codegenModelDescription = "UNKNOWN_DESCRIPTION"; + } + if (StringUtils.isEmpty(bodyParameterName)) { - codegenParameter.baseName = codegenModel.classname; + codegenParameter.baseName = codegenModelName; } else { codegenParameter.baseName = bodyParameterName; } + codegenParameter.paramName = toParamName(codegenParameter.baseName); - codegenParameter.baseType = codegenModel.classname; - codegenParameter.dataType = getTypeDeclaration(codegenModel.classname); - codegenParameter.description = codegenModel.description; + codegenParameter.baseType = codegenModelName; + codegenParameter.dataType = getTypeDeclaration(codegenModelName); + codegenParameter.description = codegenModelDescription; imports.add(codegenParameter.baseType); if (codegenProperty.complexType != null) { @@ -4465,6 +4482,6 @@ public void generateYAMLSpecFile(Map objs) { } public boolean isDataTypeString(String dataType) { - return "String".equals(dataType); + return "String".equals(dataType); } } diff --git a/samples/client/petstore-security-test/php/.openapi-generator/VERSION b/samples/client/petstore-security-test/php/.openapi-generator/VERSION index 0628777500bd..dde25ef08e8c 100644 --- a/samples/client/petstore-security-test/php/.openapi-generator/VERSION +++ b/samples/client/petstore-security-test/php/.openapi-generator/VERSION @@ -1 +1 @@ -3.1.0-SNAPSHOT \ No newline at end of file +3.1.1-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/README.md b/samples/client/petstore-security-test/php/OpenAPIClient-php/README.md index e2de901f88fb..72e324853a6b 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/README.md +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/README.md @@ -61,7 +61,7 @@ $apiInstance = new OpenAPI\Client\Api\FakeApi( // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client() ); -$unknown_base_type = new \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE(); // object | +$unknown_base_type = new \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE(); // \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE | try { $apiInstance->testCodeInjectEndRnNR($unknown_base_type); @@ -74,7 +74,7 @@ try { ## Documentation for API Endpoints -All URIs are relative to *petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* +All URIs are relative to *http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/docs/Api/FakeApi.md b/samples/client/petstore-security-test/php/OpenAPIClient-php/docs/Api/FakeApi.md index 5a3f6e363f33..dae9ffabe9b8 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/docs/Api/FakeApi.md +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/docs/Api/FakeApi.md @@ -1,6 +1,6 @@ # OpenAPI\Client\FakeApi -All URIs are relative to *petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* +All URIs are relative to *http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* Method | HTTP request | Description ------------- | ------------- | ------------- @@ -22,7 +22,7 @@ $apiInstance = new OpenAPI\Client\Api\FakeApi( // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client() ); -$unknown_base_type = new \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE(); // object | +$unknown_base_type = new \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE(); // \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE | try { $apiInstance->testCodeInjectEndRnNR($unknown_base_type); @@ -36,7 +36,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **unknown_base_type** | [**object**](../Model/UNKNOWN_BASE_TYPE.md)| | [optional] + **unknown_base_type** | [**\OpenAPI\Client\Model\UNKNOWN_BASE_TYPE**](../Model/UNKNOWN_BASE_TYPE.md)| | [optional] ### Return type diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php index 7032e80950cd..4399e72af7b0 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.1.0-SNAPSHOT + * OpenAPI Generator version: 3.1.1-SNAPSHOT */ /** @@ -92,7 +92,7 @@ public function getConfig() * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param object $unknown_base_type unknown_base_type (optional) + * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type unknown_base_type (optional) * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException @@ -108,7 +108,7 @@ public function testCodeInjectEndRnNR($unknown_base_type = null) * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param object $unknown_base_type (optional) + * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException @@ -160,7 +160,7 @@ public function testCodeInjectEndRnNRWithHttpInfo($unknown_base_type = null) * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param object $unknown_base_type (optional) + * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface @@ -180,7 +180,7 @@ function ($response) { * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param object $unknown_base_type (optional) + * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface @@ -216,7 +216,7 @@ function ($exception) { /** * Create request for operation 'testCodeInjectEndRnNR' * - * @param object $unknown_base_type (optional) + * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php index 05fb9552d748..b880234a1dac 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.1.0-SNAPSHOT + * OpenAPI Generator version: 3.1.1-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php index 2d768effac8c..706eb1bf1aef 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.1.0-SNAPSHOT + * OpenAPI Generator version: 3.1.1-SNAPSHOT */ /** @@ -81,7 +81,7 @@ class Configuration * * @var string */ - protected $host = 'petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; + protected $host = 'http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; /** * User agent of the HTTP request, set to "OpenAPI-Generator/{version}/PHP" by default diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php index 1b89fb428455..3499cc7158d9 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.1.0-SNAPSHOT + * OpenAPI Generator version: 3.1.1-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php index 67e8631bb2f8..09b88fa94787 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.1.0-SNAPSHOT + * OpenAPI Generator version: 3.1.1-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php index 25fcb651d0bc..4893a9af19e6 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.1.0-SNAPSHOT + * OpenAPI Generator version: 3.1.1-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php index cf0e7a9de8e1..c346ebf35767 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.1.0-SNAPSHOT + * OpenAPI Generator version: 3.1.1-SNAPSHOT */ /**