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

@@ -1032,7 +1032,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
@@ -1042,7 +1042,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
@@ -1073,8 +1073,8 @@ public class PetApi {
localVarFormParams.put("additionalMetadata", additionalMetadata);
}
if (file != null) {
localVarFormParams.put("file", file);
if (_file != null) {
localVarFormParams.put("file", _file);
}
final String[] localVarAccepts = {
@@ -1098,7 +1098,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) {
@@ -1106,7 +1106,7 @@ public class PetApi {
}
okhttp3.Call localVarCall = uploadFileCall(petId, additionalMetadata, file, _callback);
okhttp3.Call localVarCall = uploadFileCall(petId, additionalMetadata, _file, _callback);
return localVarCall;
}
@@ -1116,7 +1116,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
@@ -1125,8 +1125,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();
}
@@ -1135,7 +1135,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
@@ -1144,8 +1144,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);
}
@@ -1155,7 +1155,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
@@ -1165,9 +1165,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;
import android.os.Parcelable;
import android.os.Parcel;
@@ -35,47 +36,47 @@ import android.os.Parcel;
public class FileSchemaTestClass implements Parcelable {
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;
@@ -88,12 +89,12 @@ public class FileSchemaTestClass implements Parcelable {
@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;
}
@@ -107,20 +108,20 @@ public class FileSchemaTestClass implements Parcelable {
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();
@@ -139,13 +140,13 @@ public class FileSchemaTestClass implements Parcelable {
public void writeToParcel(Parcel out, int flags) {
out.writeValue(file);
out.writeValue(_file);
out.writeValue(files);
}
FileSchemaTestClass(Parcel in) {
file = (java.io.File)in.readValue(java.io.File.class.getClassLoader());
files = (List<java.io.File>)in.readValue(java.io.File.class.getClassLoader());
_file = (ModelFile)in.readValue(ModelFile.class.getClassLoader());
files = (List<ModelFile>)in.readValue(ModelFile.class.getClassLoader());
}
public int describeContents() {