Avoid using import mapping in model generation (#11217)

* remove import mapping logic in model generation, better handle of file, list

* add new files for file, list

* fix some tests

* update tests, doc

* skip file as reserved word in feign client

* add new files

* remove file from reserved word list in spring generator
This commit is contained in:
William Cheng
2022-01-16 23:57:53 +08:00
committed by GitHub
parent 3f4e7d8263
commit 33bce99b8e
382 changed files with 7655 additions and 1348 deletions

View File

@@ -38,6 +38,8 @@ docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md
docs/Model200Response.md
docs/ModelApiResponse.md
docs/ModelFile.md
docs/ModelList.md
docs/ModelReturn.md
docs/Name.md
docs/NumberOnly.md
@@ -124,6 +126,8 @@ src/main/java/org/openapitools/client/model/MapTest.java
src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
src/main/java/org/openapitools/client/model/Model200Response.java
src/main/java/org/openapitools/client/model/ModelApiResponse.java
src/main/java/org/openapitools/client/model/ModelFile.java
src/main/java/org/openapitools/client/model/ModelList.java
src/main/java/org/openapitools/client/model/ModelReturn.java
src/main/java/org/openapitools/client/model/Name.java
src/main/java/org/openapitools/client/model/NumberOnly.java

View File

@@ -186,6 +186,8 @@ Class | Method | HTTP request | Description
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [Model200Response](docs/Model200Response.md)
- [ModelApiResponse](docs/ModelApiResponse.md)
- [ModelFile](docs/ModelFile.md)
- [ModelList](docs/ModelList.md)
- [ModelReturn](docs/ModelReturn.md)
- [Name](docs/Name.md)
- [NumberOnly](docs/NumberOnly.md)

View File

@@ -7,8 +7,8 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**file** | [**java.io.File**](java.io.File.md) | | [optional]
**files** | [**List<java.io.File>**](java.io.File.md) | | [optional]
**_file** | [**ModelFile**](ModelFile.md) | | [optional]
**files** | [**List<ModelFile>**](ModelFile.md) | | [optional]

View File

@@ -491,7 +491,7 @@ null (empty response body)
<a name="uploadFile"></a>
# **uploadFile**
> ModelApiResponse uploadFile(petId, additionalMetadata, file)
> ModelApiResponse uploadFile(petId, additionalMetadata, _file)
uploads an image
@@ -517,9 +517,9 @@ public class Example {
PetApi apiInstance = new PetApi(defaultClient);
Long petId = 56L; // Long | ID of pet to update
String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server
File file = new File("/path/to/file"); // File | file to upload
File _file = new File("/path/to/file"); // File | file to upload
try {
ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, file);
ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, _file);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#uploadFile");
@@ -538,7 +538,7 @@ Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **Long**| ID of pet to update |
**additionalMetadata** | **String**| Additional data to pass to server | [optional]
**file** | **File**| file to upload | [optional]
**_file** | **File**| file to upload | [optional]
### Return type

View File

@@ -1082,7 +1082,7 @@ public class PetApi {
* Build call for uploadFile
* @param petId ID of pet to update (required)
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @param _file file to upload (optional)
* @param _callback Callback for upload/download progress
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
@@ -1092,7 +1092,7 @@ public class PetApi {
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
</table>
*/
public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File file, final ApiCallback _callback) throws ApiException {
public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File _file, final ApiCallback _callback) throws ApiException {
String basePath = null;
// Operation Servers
@@ -1129,8 +1129,8 @@ public class PetApi {
localVarFormParams.put("additionalMetadata", additionalMetadata);
}
if (file != null) {
localVarFormParams.put("file", file);
if (_file != null) {
localVarFormParams.put("file", _file);
}
localVarPath = localVarApiClient.fillParametersFromOperation(operation, paramMap, localVarPath, localVarQueryParams, localVarCollectionQueryParams, localVarHeaderParams, localVarCookieParams);
@@ -1156,7 +1156,7 @@ public class PetApi {
}
@SuppressWarnings("rawtypes")
private okhttp3.Call uploadFileValidateBeforeCall(Long petId, String additionalMetadata, File file, final ApiCallback _callback) throws ApiException {
private okhttp3.Call uploadFileValidateBeforeCall(Long petId, String additionalMetadata, File _file, final ApiCallback _callback) throws ApiException {
// verify the required parameter 'petId' is set
if (petId == null) {
@@ -1164,7 +1164,7 @@ public class PetApi {
}
okhttp3.Call localVarCall = uploadFileCall(petId, additionalMetadata, file, _callback);
okhttp3.Call localVarCall = uploadFileCall(petId, additionalMetadata, _file, _callback);
return localVarCall;
}
@@ -1174,7 +1174,7 @@ public class PetApi {
*
* @param petId ID of pet to update (required)
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @param _file file to upload (optional)
* @return ModelApiResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
@@ -1183,8 +1183,8 @@ public class PetApi {
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
</table>
*/
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws ApiException {
ApiResponse<ModelApiResponse> localVarResp = uploadFileWithHttpInfo(petId, additionalMetadata, file);
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File _file) throws ApiException {
ApiResponse<ModelApiResponse> localVarResp = uploadFileWithHttpInfo(petId, additionalMetadata, _file);
return localVarResp.getData();
}
@@ -1193,7 +1193,7 @@ public class PetApi {
*
* @param petId ID of pet to update (required)
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @param _file file to upload (optional)
* @return ApiResponse&lt;ModelApiResponse&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
@@ -1202,8 +1202,8 @@ public class PetApi {
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
</table>
*/
public ApiResponse<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException {
okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, file, null);
public ApiResponse<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File _file) throws ApiException {
okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, _file, null);
Type localVarReturnType = new TypeToken<ModelApiResponse>(){}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
@@ -1213,7 +1213,7 @@ public class PetApi {
*
* @param petId ID of pet to update (required)
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @param _file file to upload (optional)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
@@ -1223,9 +1223,9 @@ public class PetApi {
<tr><td> 200 </td><td> successful operation </td><td> - </td></tr>
</table>
*/
public okhttp3.Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback<ModelApiResponse> _callback) throws ApiException {
public okhttp3.Call uploadFileAsync(Long petId, String additionalMetadata, File _file, final ApiCallback<ModelApiResponse> _callback) throws ApiException {
okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, file, _callback);
okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, _file, _callback);
Type localVarReturnType = new TypeToken<ModelApiResponse>(){}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;

View File

@@ -25,6 +25,7 @@ import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.openapitools.client.model.ModelFile;
/**
* FileSchemaTestClass
@@ -33,47 +34,47 @@ import java.util.List;
public class FileSchemaTestClass {
public static final String SERIALIZED_NAME_FILE = "file";
@SerializedName(SERIALIZED_NAME_FILE)
private java.io.File file;
private ModelFile _file;
public static final String SERIALIZED_NAME_FILES = "files";
@SerializedName(SERIALIZED_NAME_FILES)
private List<java.io.File> files = null;
private List<ModelFile> files = null;
public FileSchemaTestClass() {
}
public FileSchemaTestClass file(java.io.File file) {
public FileSchemaTestClass _file(ModelFile _file) {
this.file = file;
this._file = _file;
return this;
}
/**
* Get file
* @return file
* Get _file
* @return _file
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
public java.io.File getFile() {
return file;
public ModelFile getFile() {
return _file;
}
public void setFile(java.io.File file) {
this.file = file;
public void setFile(ModelFile _file) {
this._file = _file;
}
public FileSchemaTestClass files(List<java.io.File> files) {
public FileSchemaTestClass files(List<ModelFile> files) {
this.files = files;
return this;
}
public FileSchemaTestClass addFilesItem(java.io.File filesItem) {
public FileSchemaTestClass addFilesItem(ModelFile filesItem) {
if (this.files == null) {
this.files = new ArrayList<java.io.File>();
this.files = new ArrayList<ModelFile>();
}
this.files.add(filesItem);
return this;
@@ -86,12 +87,12 @@ public class FileSchemaTestClass {
@javax.annotation.Nullable
@ApiModelProperty(value = "")
public List<java.io.File> getFiles() {
public List<ModelFile> getFiles() {
return files;
}
public void setFiles(List<java.io.File> files) {
public void setFiles(List<ModelFile> files) {
this.files = files;
}
@@ -105,20 +106,20 @@ public class FileSchemaTestClass {
return false;
}
FileSchemaTestClass fileSchemaTestClass = (FileSchemaTestClass) o;
return Objects.equals(this.file, fileSchemaTestClass.file) &&
return Objects.equals(this._file, fileSchemaTestClass._file) &&
Objects.equals(this.files, fileSchemaTestClass.files);
}
@Override
public int hashCode() {
return Objects.hash(file, files);
return Objects.hash(_file, files);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class FileSchemaTestClass {\n");
sb.append(" file: ").append(toIndentedString(file)).append("\n");
sb.append(" _file: ").append(toIndentedString(_file)).append("\n");
sb.append(" files: ").append(toIndentedString(files)).append("\n");
sb.append("}");
return sb.toString();