forked from loafle/openapi-generator-original
Merge branch 'master' of https://github.com/swagger-api/swagger-codegen
This commit is contained in:
@@ -54,4 +54,33 @@ public class ClientOpts {
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ClientOpts that = (ClientOpts) o;
|
||||
|
||||
if (uri != null ? !uri.equals(that.uri) : that.uri != null)
|
||||
return false;
|
||||
if (target != null ? !target.equals(that.target) : that.target != null)
|
||||
return false;
|
||||
if (auth != null ? !auth.equals(that.auth) : that.auth != null)
|
||||
return false;
|
||||
if (properties != null ? !properties.equals(that.properties) : that.properties != null)
|
||||
return false;
|
||||
return outputDirectory != null ? outputDirectory.equals(that.outputDirectory) : that.outputDirectory == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = uri != null ? uri.hashCode() : 0;
|
||||
result = 31 * result + (target != null ? target.hashCode() : 0);
|
||||
result = 31 * result + (auth != null ? auth.hashCode() : 0);
|
||||
result = 31 * result + (properties != null ? properties.hashCode() : 0);
|
||||
result = 31 * result + (outputDirectory != null ? outputDirectory.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import io.swagger.models.ExternalDocs;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CodegenModel {
|
||||
@@ -18,6 +17,8 @@ public class CodegenModel {
|
||||
public String discriminator;
|
||||
public String defaultValue;
|
||||
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
|
||||
public List<CodegenProperty> requiredVars = new ArrayList<CodegenProperty>(); // a list of required properties
|
||||
public List<CodegenProperty> optionalVars = new ArrayList<CodegenProperty>(); // a list of optional properties
|
||||
public List<CodegenProperty> allVars;
|
||||
public List<String> allowableValues;
|
||||
|
||||
@@ -37,4 +38,113 @@ public class CodegenModel {
|
||||
allVars = vars;
|
||||
allMandatory = mandatory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", name, classname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CodegenModel that = (CodegenModel) o;
|
||||
|
||||
if (parent != null ? !parent.equals(that.parent) : that.parent != null)
|
||||
return false;
|
||||
if (parentSchema != null ? !parentSchema.equals(that.parentSchema) : that.parentSchema != null)
|
||||
return false;
|
||||
if (interfaces != null ? !interfaces.equals(that.interfaces) : that.interfaces != null)
|
||||
return false;
|
||||
if (parentModel != null ? !parentModel.equals(that.parentModel) : that.parentModel != null)
|
||||
return false;
|
||||
if (interfaceModels != null ? !interfaceModels.equals(that.interfaceModels) : that.interfaceModels != null)
|
||||
return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||
return false;
|
||||
if (classname != null ? !classname.equals(that.classname) : that.classname != null)
|
||||
return false;
|
||||
if (description != null ? !description.equals(that.description) : that.description != null)
|
||||
return false;
|
||||
if (classVarName != null ? !classVarName.equals(that.classVarName) : that.classVarName != null)
|
||||
return false;
|
||||
if (modelJson != null ? !modelJson.equals(that.modelJson) : that.modelJson != null)
|
||||
return false;
|
||||
if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null)
|
||||
return false;
|
||||
if (classFilename != null ? !classFilename.equals(that.classFilename) : that.classFilename != null)
|
||||
return false;
|
||||
if (unescapedDescription != null ? !unescapedDescription.equals(that.unescapedDescription) : that.unescapedDescription != null)
|
||||
return false;
|
||||
if (discriminator != null ? !discriminator.equals(that.discriminator) : that.discriminator != null)
|
||||
return false;
|
||||
if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that.defaultValue != null)
|
||||
return false;
|
||||
if (vars != null ? !vars.equals(that.vars) : that.vars != null)
|
||||
return false;
|
||||
if (requiredVars != null ? !requiredVars.equals(that.requiredVars) : that.requiredVars != null)
|
||||
return false;
|
||||
if (optionalVars != null ? !optionalVars.equals(that.optionalVars) : that.optionalVars != null)
|
||||
return false;
|
||||
if (allVars != null ? !allVars.equals(that.allVars) : that.allVars != null)
|
||||
return false;
|
||||
if (allowableValues != null ? !allowableValues.equals(that.allowableValues) : that.allowableValues != null)
|
||||
return false;
|
||||
if (mandatory != null ? !mandatory.equals(that.mandatory) : that.mandatory != null)
|
||||
return false;
|
||||
if (allMandatory != null ? !allMandatory.equals(that.allMandatory) : that.allMandatory != null)
|
||||
return false;
|
||||
if (imports != null ? !imports.equals(that.imports) : that.imports != null)
|
||||
return false;
|
||||
if (hasVars != null ? !hasVars.equals(that.hasVars) : that.hasVars != null)
|
||||
return false;
|
||||
if (emptyVars != null ? !emptyVars.equals(that.emptyVars) : that.emptyVars != null)
|
||||
return false;
|
||||
if (hasMoreModels != null ? !hasMoreModels.equals(that.hasMoreModels) : that.hasMoreModels != null)
|
||||
return false;
|
||||
if (hasEnums != null ? !hasEnums.equals(that.hasEnums) : that.hasEnums != null)
|
||||
return false;
|
||||
if (isEnum != null ? !isEnum.equals(that.isEnum) : that.isEnum != null)
|
||||
return false;
|
||||
if (externalDocs != null ? !externalDocs.equals(that.externalDocs) : that.externalDocs != null)
|
||||
return false;
|
||||
return vendorExtensions != null ? vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = parent != null ? parent.hashCode() : 0;
|
||||
result = 31 * result + (parentSchema != null ? parentSchema.hashCode() : 0);
|
||||
result = 31 * result + (interfaces != null ? interfaces.hashCode() : 0);
|
||||
result = 31 * result + (parentModel != null ? parentModel.hashCode() : 0);
|
||||
result = 31 * result + (interfaceModels != null ? interfaceModels.hashCode() : 0);
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
result = 31 * result + (classname != null ? classname.hashCode() : 0);
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
result = 31 * result + (classVarName != null ? classVarName.hashCode() : 0);
|
||||
result = 31 * result + (modelJson != null ? modelJson.hashCode() : 0);
|
||||
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
|
||||
result = 31 * result + (classFilename != null ? classFilename.hashCode() : 0);
|
||||
result = 31 * result + (unescapedDescription != null ? unescapedDescription.hashCode() : 0);
|
||||
result = 31 * result + (discriminator != null ? discriminator.hashCode() : 0);
|
||||
result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
|
||||
result = 31 * result + (vars != null ? vars.hashCode() : 0);
|
||||
result = 31 * result + (requiredVars != null ? requiredVars.hashCode() : 0);
|
||||
result = 31 * result + (optionalVars != null ? optionalVars.hashCode() : 0);
|
||||
result = 31 * result + (allVars != null ? allVars.hashCode() : 0);
|
||||
result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0);
|
||||
result = 31 * result + (mandatory != null ? mandatory.hashCode() : 0);
|
||||
result = 31 * result + (allMandatory != null ? allMandatory.hashCode() : 0);
|
||||
result = 31 * result + (imports != null ? imports.hashCode() : 0);
|
||||
result = 31 * result + (hasVars != null ? hasVars.hashCode() : 0);
|
||||
result = 31 * result + (emptyVars != null ? emptyVars.hashCode() : 0);
|
||||
result = 31 * result + (hasMoreModels != null ? hasMoreModels.hashCode() : 0);
|
||||
result = 31 * result + (hasEnums != null ? hasEnums.hashCode() : 0);
|
||||
result = 31 * result + (isEnum != null ? isEnum.hashCode() : 0);
|
||||
result = 31 * result + (externalDocs != null ? externalDocs.hashCode() : 0);
|
||||
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,4 +88,157 @@ public class CodegenOperation {
|
||||
return nonempty(formParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", baseName, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CodegenOperation that = (CodegenOperation) o;
|
||||
|
||||
if (responseHeaders != null ? !responseHeaders.equals(that.responseHeaders) : that.responseHeaders != null)
|
||||
return false;
|
||||
if (hasAuthMethods != null ? !hasAuthMethods.equals(that.hasAuthMethods) : that.hasAuthMethods != null)
|
||||
return false;
|
||||
if (hasConsumes != null ? !hasConsumes.equals(that.hasConsumes) : that.hasConsumes != null)
|
||||
return false;
|
||||
if (hasProduces != null ? !hasProduces.equals(that.hasProduces) : that.hasProduces != null)
|
||||
return false;
|
||||
if (hasParams != null ? !hasParams.equals(that.hasParams) : that.hasParams != null)
|
||||
return false;
|
||||
if (hasOptionalParams != null ? !hasOptionalParams.equals(that.hasOptionalParams) : that.hasOptionalParams != null)
|
||||
return false;
|
||||
if (returnTypeIsPrimitive != null ? !returnTypeIsPrimitive.equals(that.returnTypeIsPrimitive) : that.returnTypeIsPrimitive != null)
|
||||
return false;
|
||||
if (returnSimpleType != null ? !returnSimpleType.equals(that.returnSimpleType) : that.returnSimpleType != null)
|
||||
return false;
|
||||
if (subresourceOperation != null ? !subresourceOperation.equals(that.subresourceOperation) : that.subresourceOperation != null)
|
||||
return false;
|
||||
if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null)
|
||||
return false;
|
||||
if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null)
|
||||
return false;
|
||||
if (isMultipart != null ? !isMultipart.equals(that.isMultipart) : that.isMultipart != null)
|
||||
return false;
|
||||
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
|
||||
return false;
|
||||
if (isResponseBinary != null ? !isResponseBinary.equals(that.isResponseBinary) : that.isResponseBinary != null)
|
||||
return false;
|
||||
if (hasReference != null ? !hasReference.equals(that.hasReference) : that.hasReference != null)
|
||||
return false;
|
||||
if (path != null ? !path.equals(that.path) : that.path != null)
|
||||
return false;
|
||||
if (operationId != null ? !operationId.equals(that.operationId) : that.operationId != null)
|
||||
return false;
|
||||
if (returnType != null ? !returnType.equals(that.returnType) : that.returnType != null)
|
||||
return false;
|
||||
if (httpMethod != null ? !httpMethod.equals(that.httpMethod) : that.httpMethod != null)
|
||||
return false;
|
||||
if (returnBaseType != null ? !returnBaseType.equals(that.returnBaseType) : that.returnBaseType != null)
|
||||
return false;
|
||||
if (returnContainer != null ? !returnContainer.equals(that.returnContainer) : that.returnContainer != null)
|
||||
return false;
|
||||
if (summary != null ? !summary.equals(that.summary) : that.summary != null)
|
||||
return false;
|
||||
if (unescapedNotes != null ? !unescapedNotes.equals(that.unescapedNotes) : that.unescapedNotes != null)
|
||||
return false;
|
||||
if (notes != null ? !notes.equals(that.notes) : that.notes != null)
|
||||
return false;
|
||||
if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null)
|
||||
return false;
|
||||
if (defaultResponse != null ? !defaultResponse.equals(that.defaultResponse) : that.defaultResponse != null)
|
||||
return false;
|
||||
if (discriminator != null ? !discriminator.equals(that.discriminator) : that.discriminator != null)
|
||||
return false;
|
||||
if (consumes != null ? !consumes.equals(that.consumes) : that.consumes != null)
|
||||
return false;
|
||||
if (produces != null ? !produces.equals(that.produces) : that.produces != null)
|
||||
return false;
|
||||
if (bodyParam != null ? !bodyParam.equals(that.bodyParam) : that.bodyParam != null)
|
||||
return false;
|
||||
if (allParams != null ? !allParams.equals(that.allParams) : that.allParams != null)
|
||||
return false;
|
||||
if (bodyParams != null ? !bodyParams.equals(that.bodyParams) : that.bodyParams != null)
|
||||
return false;
|
||||
if (pathParams != null ? !pathParams.equals(that.pathParams) : that.pathParams != null)
|
||||
return false;
|
||||
if (queryParams != null ? !queryParams.equals(that.queryParams) : that.queryParams != null)
|
||||
return false;
|
||||
if (headerParams != null ? !headerParams.equals(that.headerParams) : that.headerParams != null)
|
||||
return false;
|
||||
if (formParams != null ? !formParams.equals(that.formParams) : that.formParams != null)
|
||||
return false;
|
||||
if (authMethods != null ? !authMethods.equals(that.authMethods) : that.authMethods != null)
|
||||
return false;
|
||||
if (tags != null ? !tags.equals(that.tags) : that.tags != null)
|
||||
return false;
|
||||
if (responses != null ? !responses.equals(that.responses) : that.responses != null)
|
||||
return false;
|
||||
if (imports != null ? !imports.equals(that.imports) : that.imports != null)
|
||||
return false;
|
||||
if (examples != null ? !examples.equals(that.examples) : that.examples != null)
|
||||
return false;
|
||||
if (externalDocs != null ? !externalDocs.equals(that.externalDocs) : that.externalDocs != null)
|
||||
return false;
|
||||
if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null)
|
||||
return false;
|
||||
if (nickname != null ? !nickname.equals(that.nickname) : that.nickname != null)
|
||||
return false;
|
||||
return operationIdLowerCase != null ? operationIdLowerCase.equals(that.operationIdLowerCase) : that.operationIdLowerCase == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = responseHeaders != null ? responseHeaders.hashCode() : 0;
|
||||
result = 31 * result + (hasAuthMethods != null ? hasAuthMethods.hashCode() : 0);
|
||||
result = 31 * result + (hasConsumes != null ? hasConsumes.hashCode() : 0);
|
||||
result = 31 * result + (hasProduces != null ? hasProduces.hashCode() : 0);
|
||||
result = 31 * result + (hasParams != null ? hasParams.hashCode() : 0);
|
||||
result = 31 * result + (hasOptionalParams != null ? hasOptionalParams.hashCode() : 0);
|
||||
result = 31 * result + (returnTypeIsPrimitive != null ? returnTypeIsPrimitive.hashCode() : 0);
|
||||
result = 31 * result + (returnSimpleType != null ? returnSimpleType.hashCode() : 0);
|
||||
result = 31 * result + (subresourceOperation != null ? subresourceOperation.hashCode() : 0);
|
||||
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
|
||||
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
|
||||
result = 31 * result + (isMultipart != null ? isMultipart.hashCode() : 0);
|
||||
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
||||
result = 31 * result + (isResponseBinary != null ? isResponseBinary.hashCode() : 0);
|
||||
result = 31 * result + (hasReference != null ? hasReference.hashCode() : 0);
|
||||
result = 31 * result + (path != null ? path.hashCode() : 0);
|
||||
result = 31 * result + (operationId != null ? operationId.hashCode() : 0);
|
||||
result = 31 * result + (returnType != null ? returnType.hashCode() : 0);
|
||||
result = 31 * result + (httpMethod != null ? httpMethod.hashCode() : 0);
|
||||
result = 31 * result + (returnBaseType != null ? returnBaseType.hashCode() : 0);
|
||||
result = 31 * result + (returnContainer != null ? returnContainer.hashCode() : 0);
|
||||
result = 31 * result + (summary != null ? summary.hashCode() : 0);
|
||||
result = 31 * result + (unescapedNotes != null ? unescapedNotes.hashCode() : 0);
|
||||
result = 31 * result + (notes != null ? notes.hashCode() : 0);
|
||||
result = 31 * result + (baseName != null ? baseName.hashCode() : 0);
|
||||
result = 31 * result + (defaultResponse != null ? defaultResponse.hashCode() : 0);
|
||||
result = 31 * result + (discriminator != null ? discriminator.hashCode() : 0);
|
||||
result = 31 * result + (consumes != null ? consumes.hashCode() : 0);
|
||||
result = 31 * result + (produces != null ? produces.hashCode() : 0);
|
||||
result = 31 * result + (bodyParam != null ? bodyParam.hashCode() : 0);
|
||||
result = 31 * result + (allParams != null ? allParams.hashCode() : 0);
|
||||
result = 31 * result + (bodyParams != null ? bodyParams.hashCode() : 0);
|
||||
result = 31 * result + (pathParams != null ? pathParams.hashCode() : 0);
|
||||
result = 31 * result + (queryParams != null ? queryParams.hashCode() : 0);
|
||||
result = 31 * result + (headerParams != null ? headerParams.hashCode() : 0);
|
||||
result = 31 * result + (formParams != null ? formParams.hashCode() : 0);
|
||||
result = 31 * result + (authMethods != null ? authMethods.hashCode() : 0);
|
||||
result = 31 * result + (tags != null ? tags.hashCode() : 0);
|
||||
result = 31 * result + (responses != null ? responses.hashCode() : 0);
|
||||
result = 31 * result + (imports != null ? imports.hashCode() : 0);
|
||||
result = 31 * result + (examples != null ? examples.hashCode() : 0);
|
||||
result = 31 * result + (externalDocs != null ? externalDocs.hashCode() : 0);
|
||||
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
|
||||
result = 31 * result + (nickname != null ? nickname.hashCode() : 0);
|
||||
result = 31 * result + (operationIdLowerCase != null ? operationIdLowerCase.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class CodegenParameter {
|
||||
public Map<String, Object> allowableValues;
|
||||
public CodegenProperty items;
|
||||
public Map<String, Object> vendorExtensions;
|
||||
public Boolean hasValidation;
|
||||
|
||||
/**
|
||||
* Determines whether this parameter is mandatory. If the parameter is in "path",
|
||||
@@ -120,6 +121,7 @@ public class CodegenParameter {
|
||||
output.items = this.items;
|
||||
}
|
||||
output.vendorExtensions = this.vendorExtensions;
|
||||
output.hasValidation = this.hasValidation;
|
||||
output.isBinary = this.isBinary;
|
||||
output.isByteArray = this.isByteArray;
|
||||
output.isString = this.isString;
|
||||
@@ -135,5 +137,185 @@ public class CodegenParameter {
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", baseName, dataType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CodegenParameter that = (CodegenParameter) o;
|
||||
|
||||
if (isEnum != that.isEnum) return false;
|
||||
if (isFormParam != null ? !isFormParam.equals(that.isFormParam) : that.isFormParam != null)
|
||||
return false;
|
||||
if (isQueryParam != null ? !isQueryParam.equals(that.isQueryParam) : that.isQueryParam != null)
|
||||
return false;
|
||||
if (isPathParam != null ? !isPathParam.equals(that.isPathParam) : that.isPathParam != null)
|
||||
return false;
|
||||
if (isHeaderParam != null ? !isHeaderParam.equals(that.isHeaderParam) : that.isHeaderParam != null)
|
||||
return false;
|
||||
if (isCookieParam != null ? !isCookieParam.equals(that.isCookieParam) : that.isCookieParam != null)
|
||||
return false;
|
||||
if (isBodyParam != null ? !isBodyParam.equals(that.isBodyParam) : that.isBodyParam != null)
|
||||
return false;
|
||||
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
|
||||
return false;
|
||||
if (isContainer != null ? !isContainer.equals(that.isContainer) : that.isContainer != null)
|
||||
return false;
|
||||
if (secondaryParam != null ? !secondaryParam.equals(that.secondaryParam) : that.secondaryParam != null)
|
||||
return false;
|
||||
if (isCollectionFormatMulti != null ? !isCollectionFormatMulti.equals(that.isCollectionFormatMulti) : that.isCollectionFormatMulti != null)
|
||||
return false;
|
||||
if (isPrimitiveType != null ? !isPrimitiveType.equals(that.isPrimitiveType) : that.isPrimitiveType != null)
|
||||
return false;
|
||||
if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null)
|
||||
return false;
|
||||
if (paramName != null ? !paramName.equals(that.paramName) : that.paramName != null)
|
||||
return false;
|
||||
if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null)
|
||||
return false;
|
||||
if (datatypeWithEnum != null ? !datatypeWithEnum.equals(that.datatypeWithEnum) : that.datatypeWithEnum != null)
|
||||
return false;
|
||||
if (collectionFormat != null ? !collectionFormat.equals(that.collectionFormat) : that.collectionFormat != null)
|
||||
return false;
|
||||
if (description != null ? !description.equals(that.description) : that.description != null)
|
||||
return false;
|
||||
if (unescapedDescription != null ? !unescapedDescription.equals(that.unescapedDescription) : that.unescapedDescription != null)
|
||||
return false;
|
||||
if (baseType != null ? !baseType.equals(that.baseType) : that.baseType != null)
|
||||
return false;
|
||||
if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that.defaultValue != null)
|
||||
return false;
|
||||
if (example != null ? !example.equals(that.example) : that.example != null)
|
||||
return false;
|
||||
if (jsonSchema != null ? !jsonSchema.equals(that.jsonSchema) : that.jsonSchema != null)
|
||||
return false;
|
||||
if (isString != null ? !isString.equals(that.isString) : that.isString != null)
|
||||
return false;
|
||||
if (isInteger != null ? !isInteger.equals(that.isInteger) : that.isInteger != null)
|
||||
return false;
|
||||
if (isLong != null ? !isLong.equals(that.isLong) : that.isLong != null)
|
||||
return false;
|
||||
if (isFloat != null ? !isFloat.equals(that.isFloat) : that.isFloat != null)
|
||||
return false;
|
||||
if (isDouble != null ? !isDouble.equals(that.isDouble) : that.isDouble != null)
|
||||
return false;
|
||||
if (isByteArray != null ? !isByteArray.equals(that.isByteArray) : that.isByteArray != null)
|
||||
return false;
|
||||
if (isBinary != null ? !isBinary.equals(that.isBinary) : that.isBinary != null)
|
||||
return false;
|
||||
if (isBoolean != null ? !isBoolean.equals(that.isBoolean) : that.isBoolean != null)
|
||||
return false;
|
||||
if (isDate != null ? !isDate.equals(that.isDate) : that.isDate != null)
|
||||
return false;
|
||||
if (isDateTime != null ? !isDateTime.equals(that.isDateTime) : that.isDateTime != null)
|
||||
return false;
|
||||
if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null)
|
||||
return false;
|
||||
if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null)
|
||||
return false;
|
||||
if (isFile != null ? !isFile.equals(that.isFile) : that.isFile != null)
|
||||
return false;
|
||||
if (notFile != null ? !notFile.equals(that.notFile) : that.notFile != null)
|
||||
return false;
|
||||
if (_enum != null ? !_enum.equals(that._enum) : that._enum != null)
|
||||
return false;
|
||||
if (allowableValues != null ? !allowableValues.equals(that.allowableValues) : that.allowableValues != null)
|
||||
return false;
|
||||
if (items != null ? !items.equals(that.items) : that.items != null)
|
||||
return false;
|
||||
if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null)
|
||||
return false;
|
||||
if (hasValidation != null ? !hasValidation.equals(that.hasValidation) : that.hasValidation != null)
|
||||
return false;
|
||||
if (required != null ? !required.equals(that.required) : that.required != null)
|
||||
return false;
|
||||
if (maximum != null ? !maximum.equals(that.maximum) : that.maximum != null)
|
||||
return false;
|
||||
if (exclusiveMaximum != null ? !exclusiveMaximum.equals(that.exclusiveMaximum) : that.exclusiveMaximum != null)
|
||||
return false;
|
||||
if (minimum != null ? !minimum.equals(that.minimum) : that.minimum != null)
|
||||
return false;
|
||||
if (exclusiveMinimum != null ? !exclusiveMinimum.equals(that.exclusiveMinimum) : that.exclusiveMinimum != null)
|
||||
return false;
|
||||
if (maxLength != null ? !maxLength.equals(that.maxLength) : that.maxLength != null)
|
||||
return false;
|
||||
if (minLength != null ? !minLength.equals(that.minLength) : that.minLength != null)
|
||||
return false;
|
||||
if (pattern != null ? !pattern.equals(that.pattern) : that.pattern != null)
|
||||
return false;
|
||||
if (maxItems != null ? !maxItems.equals(that.maxItems) : that.maxItems != null)
|
||||
return false;
|
||||
if (minItems != null ? !minItems.equals(that.minItems) : that.minItems != null)
|
||||
return false;
|
||||
if (uniqueItems != null ? !uniqueItems.equals(that.uniqueItems) : that.uniqueItems != null)
|
||||
return false;
|
||||
return multipleOf != null ? multipleOf.equals(that.multipleOf) : that.multipleOf == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = isFormParam != null ? isFormParam.hashCode() : 0;
|
||||
result = 31 * result + (isQueryParam != null ? isQueryParam.hashCode() : 0);
|
||||
result = 31 * result + (isPathParam != null ? isPathParam.hashCode() : 0);
|
||||
result = 31 * result + (isHeaderParam != null ? isHeaderParam.hashCode() : 0);
|
||||
result = 31 * result + (isCookieParam != null ? isCookieParam.hashCode() : 0);
|
||||
result = 31 * result + (isBodyParam != null ? isBodyParam.hashCode() : 0);
|
||||
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
||||
result = 31 * result + (isContainer != null ? isContainer.hashCode() : 0);
|
||||
result = 31 * result + (secondaryParam != null ? secondaryParam.hashCode() : 0);
|
||||
result = 31 * result + (isCollectionFormatMulti != null ? isCollectionFormatMulti.hashCode() : 0);
|
||||
result = 31 * result + (isPrimitiveType != null ? isPrimitiveType.hashCode() : 0);
|
||||
result = 31 * result + (baseName != null ? baseName.hashCode() : 0);
|
||||
result = 31 * result + (paramName != null ? paramName.hashCode() : 0);
|
||||
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
|
||||
result = 31 * result + (datatypeWithEnum != null ? datatypeWithEnum.hashCode() : 0);
|
||||
result = 31 * result + (collectionFormat != null ? collectionFormat.hashCode() : 0);
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
result = 31 * result + (unescapedDescription != null ? unescapedDescription.hashCode() : 0);
|
||||
result = 31 * result + (baseType != null ? baseType.hashCode() : 0);
|
||||
result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
|
||||
result = 31 * result + (example != null ? example.hashCode() : 0);
|
||||
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0);
|
||||
result = 31 * result + (isString != null ? isString.hashCode() : 0);
|
||||
result = 31 * result + (isInteger != null ? isInteger.hashCode() : 0);
|
||||
result = 31 * result + (isLong != null ? isLong.hashCode() : 0);
|
||||
result = 31 * result + (isFloat != null ? isFloat.hashCode() : 0);
|
||||
result = 31 * result + (isDouble != null ? isDouble.hashCode() : 0);
|
||||
result = 31 * result + (isByteArray != null ? isByteArray.hashCode() : 0);
|
||||
result = 31 * result + (isBinary != null ? isBinary.hashCode() : 0);
|
||||
result = 31 * result + (isBoolean != null ? isBoolean.hashCode() : 0);
|
||||
result = 31 * result + (isDate != null ? isDate.hashCode() : 0);
|
||||
result = 31 * result + (isDateTime != null ? isDateTime.hashCode() : 0);
|
||||
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
|
||||
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
|
||||
result = 31 * result + (isFile != null ? isFile.hashCode() : 0);
|
||||
result = 31 * result + (notFile != null ? notFile.hashCode() : 0);
|
||||
result = 31 * result + (isEnum ? 1 : 0);
|
||||
result = 31 * result + (_enum != null ? _enum.hashCode() : 0);
|
||||
result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0);
|
||||
result = 31 * result + (items != null ? items.hashCode() : 0);
|
||||
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
|
||||
result = 31 * result + (hasValidation != null ? hasValidation.hashCode() : 0);
|
||||
result = 31 * result + (required != null ? required.hashCode() : 0);
|
||||
result = 31 * result + (maximum != null ? maximum.hashCode() : 0);
|
||||
result = 31 * result + (exclusiveMaximum != null ? exclusiveMaximum.hashCode() : 0);
|
||||
result = 31 * result + (minimum != null ? minimum.hashCode() : 0);
|
||||
result = 31 * result + (exclusiveMinimum != null ? exclusiveMinimum.hashCode() : 0);
|
||||
result = 31 * result + (maxLength != null ? maxLength.hashCode() : 0);
|
||||
result = 31 * result + (minLength != null ? minLength.hashCode() : 0);
|
||||
result = 31 * result + (pattern != null ? pattern.hashCode() : 0);
|
||||
result = 31 * result + (maxItems != null ? maxItems.hashCode() : 0);
|
||||
result = 31 * result + (minItems != null ? minItems.hashCode() : 0);
|
||||
result = 31 * result + (uniqueItems != null ? uniqueItems.hashCode() : 0);
|
||||
result = 31 * result + (multipleOf != null ? multipleOf.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,13 @@ public class CodegenProperty {
|
||||
public Map<String, Object> allowableValues;
|
||||
public CodegenProperty items;
|
||||
public Map<String, Object> vendorExtensions;
|
||||
public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", baseName, datatype);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
@@ -85,6 +92,7 @@ public class CodegenProperty {
|
||||
result = prime * result + ((setter == null) ? 0 : setter.hashCode());
|
||||
result = prime * result + ((unescapedDescription == null) ? 0 : unescapedDescription.hashCode());
|
||||
result = prime * result + ((vendorExtensions == null) ? 0 : vendorExtensions.hashCode());
|
||||
result = prime * result + ((hasValidation == null) ? 0 : hasValidation.hashCode());
|
||||
result = prime * result + ((isString == null) ? 0 : isString.hashCode());
|
||||
result = prime * result + ((isInteger == null) ? 0 : isInteger.hashCode());
|
||||
result = prime * result + ((isLong == null) ? 0 : isLong.hashCode());
|
||||
@@ -202,12 +210,19 @@ public class CodegenProperty {
|
||||
if (this.allowableValues != other.allowableValues && (this.allowableValues == null || !this.allowableValues.equals(other.allowableValues))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.vendorExtensions != other.vendorExtensions && (this.vendorExtensions == null || !this.vendorExtensions.equals(other.vendorExtensions))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.hasValidation != other.hasValidation && (this.hasValidation == null || !this.hasValidation.equals(other.hasValidation))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isString != other.isString && (this.isString == null || !this.isString.equals(other.isString))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isInteger != other.isInteger && (this.isInteger == null || !this.isInteger.equals(other.isInteger))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -22,4 +22,71 @@ public class CodegenResponse {
|
||||
public boolean isWildcard() {
|
||||
return "0".equals(code) || "default".equals(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", code, containerType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CodegenResponse that = (CodegenResponse) o;
|
||||
|
||||
if (headers != null ? !headers.equals(that.headers) : that.headers != null)
|
||||
return false;
|
||||
if (code != null ? !code.equals(that.code) : that.code != null)
|
||||
return false;
|
||||
if (message != null ? !message.equals(that.message) : that.message != null)
|
||||
return false;
|
||||
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
|
||||
return false;
|
||||
if (examples != null ? !examples.equals(that.examples) : that.examples != null)
|
||||
return false;
|
||||
if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null)
|
||||
return false;
|
||||
if (baseType != null ? !baseType.equals(that.baseType) : that.baseType != null)
|
||||
return false;
|
||||
if (containerType != null ? !containerType.equals(that.containerType) : that.containerType != null)
|
||||
return false;
|
||||
if (isDefault != null ? !isDefault.equals(that.isDefault) : that.isDefault != null)
|
||||
return false;
|
||||
if (simpleType != null ? !simpleType.equals(that.simpleType) : that.simpleType != null)
|
||||
return false;
|
||||
if (primitiveType != null ? !primitiveType.equals(that.primitiveType) : that.primitiveType != null)
|
||||
return false;
|
||||
if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null)
|
||||
return false;
|
||||
if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null)
|
||||
return false;
|
||||
if (isBinary != null ? !isBinary.equals(that.isBinary) : that.isBinary != null)
|
||||
return false;
|
||||
if (schema != null ? !schema.equals(that.schema) : that.schema != null)
|
||||
return false;
|
||||
return jsonSchema != null ? jsonSchema.equals(that.jsonSchema) : that.jsonSchema == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = headers != null ? headers.hashCode() : 0;
|
||||
result = 31 * result + (code != null ? code.hashCode() : 0);
|
||||
result = 31 * result + (message != null ? message.hashCode() : 0);
|
||||
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
||||
result = 31 * result + (examples != null ? examples.hashCode() : 0);
|
||||
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
|
||||
result = 31 * result + (baseType != null ? baseType.hashCode() : 0);
|
||||
result = 31 * result + (containerType != null ? containerType.hashCode() : 0);
|
||||
result = 31 * result + (isDefault != null ? isDefault.hashCode() : 0);
|
||||
result = 31 * result + (simpleType != null ? simpleType.hashCode() : 0);
|
||||
result = 31 * result + (primitiveType != null ? primitiveType.hashCode() : 0);
|
||||
result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0);
|
||||
result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0);
|
||||
result = 31 * result + (isBinary != null ? isBinary.hashCode() : 0);
|
||||
result = 31 * result + (schema != null ? schema.hashCode() : 0);
|
||||
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,62 @@ public class CodegenSecurity {
|
||||
// Oauth specific
|
||||
public String flow, authorizationUrl, tokenUrl;
|
||||
public List<Map<String, Object>> scopes;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CodegenSecurity that = (CodegenSecurity) o;
|
||||
|
||||
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||
return false;
|
||||
if (type != null ? !type.equals(that.type) : that.type != null)
|
||||
return false;
|
||||
if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null)
|
||||
return false;
|
||||
if (isBasic != null ? !isBasic.equals(that.isBasic) : that.isBasic != null)
|
||||
return false;
|
||||
if (isOAuth != null ? !isOAuth.equals(that.isOAuth) : that.isOAuth != null)
|
||||
return false;
|
||||
if (isApiKey != null ? !isApiKey.equals(that.isApiKey) : that.isApiKey != null)
|
||||
return false;
|
||||
if (keyParamName != null ? !keyParamName.equals(that.keyParamName) : that.keyParamName != null)
|
||||
return false;
|
||||
if (isKeyInQuery != null ? !isKeyInQuery.equals(that.isKeyInQuery) : that.isKeyInQuery != null)
|
||||
return false;
|
||||
if (isKeyInHeader != null ? !isKeyInHeader.equals(that.isKeyInHeader) : that.isKeyInHeader != null)
|
||||
return false;
|
||||
if (flow != null ? !flow.equals(that.flow) : that.flow != null)
|
||||
return false;
|
||||
if (authorizationUrl != null ? !authorizationUrl.equals(that.authorizationUrl) : that.authorizationUrl != null)
|
||||
return false;
|
||||
if (tokenUrl != null ? !tokenUrl.equals(that.tokenUrl) : that.tokenUrl != null)
|
||||
return false;
|
||||
return scopes != null ? scopes.equals(that.scopes) : that.scopes == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = name != null ? name.hashCode() : 0;
|
||||
result = 31 * result + (type != null ? type.hashCode() : 0);
|
||||
result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
|
||||
result = 31 * result + (isBasic != null ? isBasic.hashCode() : 0);
|
||||
result = 31 * result + (isOAuth != null ? isOAuth.hashCode() : 0);
|
||||
result = 31 * result + (isApiKey != null ? isApiKey.hashCode() : 0);
|
||||
result = 31 * result + (keyParamName != null ? keyParamName.hashCode() : 0);
|
||||
result = 31 * result + (isKeyInQuery != null ? isKeyInQuery.hashCode() : 0);
|
||||
result = 31 * result + (isKeyInHeader != null ? isKeyInHeader.hashCode() : 0);
|
||||
result = 31 * result + (flow != null ? flow.hashCode() : 0);
|
||||
result = 31 * result + (authorizationUrl != null ? authorizationUrl.hashCode() : 0);
|
||||
result = 31 * result + (tokenUrl != null ? tokenUrl.hashCode() : 0);
|
||||
result = 31 * result + (scopes != null ? scopes.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,6 +327,16 @@ public class DefaultCodegen {
|
||||
this.ensureUniqueParams = ensureUniqueParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)
|
||||
*
|
||||
* @param pattern the pattern (regular expression)
|
||||
* @return properly-escaped pattern
|
||||
*/
|
||||
public String toRegularExpression(String pattern) {
|
||||
return escapeText(pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the file name of the Api Test
|
||||
*
|
||||
@@ -1094,6 +1104,10 @@ public class DefaultCodegen {
|
||||
property.exclusiveMinimum = np.getExclusiveMinimum();
|
||||
property.exclusiveMaximum = np.getExclusiveMaximum();
|
||||
|
||||
// check if any validation rule defined
|
||||
if (property.minimum != null || property.maximum != null || property.exclusiveMinimum != null || property.exclusiveMaximum != null)
|
||||
property.hasValidation = true;
|
||||
|
||||
// legacy support
|
||||
Map<String, Object> allowableValues = new HashMap<String, Object>();
|
||||
if (np.getMinimum() != null) {
|
||||
@@ -1111,7 +1125,12 @@ public class DefaultCodegen {
|
||||
StringProperty sp = (StringProperty) p;
|
||||
property.maxLength = sp.getMaxLength();
|
||||
property.minLength = sp.getMinLength();
|
||||
property.pattern = sp.getPattern();
|
||||
property.pattern = toRegularExpression(sp.getPattern());
|
||||
|
||||
// check if any validation rule defined
|
||||
if (property.pattern != null || property.minLength != null || property.maxLength != null)
|
||||
property.hasValidation = true;
|
||||
|
||||
property.isString = true;
|
||||
if (sp.getEnum() != null) {
|
||||
List<String> _enum = sp.getEnum();
|
||||
@@ -1802,9 +1821,6 @@ public class DefaultCodegen {
|
||||
if (model.complexType != null) {
|
||||
imports.add(model.complexType);
|
||||
}
|
||||
p.maxLength = qp.getMaxLength();
|
||||
p.minLength = qp.getMinLength();
|
||||
p.pattern = qp.getPattern();
|
||||
|
||||
p.maximum = qp.getMaximum();
|
||||
p.exclusiveMaximum = qp.isExclusiveMaximum();
|
||||
@@ -1812,11 +1828,20 @@ public class DefaultCodegen {
|
||||
p.exclusiveMinimum = qp.isExclusiveMinimum();
|
||||
p.maxLength = qp.getMaxLength();
|
||||
p.minLength = qp.getMinLength();
|
||||
p.pattern = qp.getPattern();
|
||||
p.pattern = toRegularExpression(qp.getPattern());
|
||||
p.maxItems = qp.getMaxItems();
|
||||
p.minItems = qp.getMinItems();
|
||||
p.uniqueItems = qp.isUniqueItems();
|
||||
p.multipleOf = qp.getMultipleOf();
|
||||
|
||||
if (p.maximum != null || p.exclusiveMaximum != null ||
|
||||
p.minimum != null || p.exclusiveMinimum != null ||
|
||||
p.maxLength != null || p.minLength != null ||
|
||||
p.maxItems != null || p.minItems != null ||
|
||||
p.pattern != null) {
|
||||
p.hasValidation = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!(param instanceof BodyParameter)) {
|
||||
LOGGER.error("Cannot use Parameter " + param + " as Body Parameter");
|
||||
@@ -1889,7 +1914,7 @@ public class DefaultCodegen {
|
||||
// set the example value
|
||||
// if not specified in x-example, generate a default value
|
||||
if (p.vendorExtensions.containsKey("x-example")) {
|
||||
p.example = (String) p.vendorExtensions.get("x-example");
|
||||
p.example = Objects.toString(p.vendorExtensions.get("x-example"));
|
||||
} else if (Boolean.TRUE.equals(p.isString)) {
|
||||
p.example = p.paramName + "_example";
|
||||
} else if (Boolean.TRUE.equals(p.isBoolean)) {
|
||||
@@ -2307,6 +2332,12 @@ public class DefaultCodegen {
|
||||
addImport(m, cp.baseType);
|
||||
addImport(m, cp.complexType);
|
||||
vars.add(cp);
|
||||
|
||||
if (Boolean.TRUE.equals(cp.required)) { // if required, add to the list "requiredVars"
|
||||
m.requiredVars.add(cp);
|
||||
} else { // else add to the list "optionalVars" for optional property
|
||||
m.optionalVars.add(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2319,18 +2350,28 @@ public class DefaultCodegen {
|
||||
*/
|
||||
@SuppressWarnings("static-method")
|
||||
public String removeNonNameElementToCamelCase(String name) {
|
||||
String nonNameElementPattern = "[-_:;#]";
|
||||
name = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function<String, String>() { // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
return removeNonNameElementToCamelCase(name, "[-_:;#]");
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove characters that is not good to be included in method name from the input and camelize it
|
||||
*
|
||||
* @param name string to be camelize
|
||||
* @param nonNameElementPattern a regex pattern of the characters that is not good to be included in name
|
||||
* @return camelized string
|
||||
*/
|
||||
protected String removeNonNameElementToCamelCase(final String name, final String nonNameElementPattern) {
|
||||
String result = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function<String, String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String apply(String input) {
|
||||
return StringUtils.capitalize(input);
|
||||
}
|
||||
}), "");
|
||||
if (name.length() > 0) {
|
||||
name = name.substring(0, 1).toLowerCase() + name.substring(1);
|
||||
if (result.length() > 0) {
|
||||
result = result.substring(0, 1).toLowerCase() + result.substring(1);
|
||||
}
|
||||
return name;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,4 +21,27 @@ public class SupportingFile {
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SupportingFile that = (SupportingFile) o;
|
||||
|
||||
if (templateFile != null ? !templateFile.equals(that.templateFile) : that.templateFile != null)
|
||||
return false;
|
||||
if (folder != null ? !folder.equals(that.folder) : that.folder != null)
|
||||
return false;
|
||||
return destinationFilename != null ? destinationFilename.equals(that.destinationFilename) : that.destinationFilename == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = templateFile != null ? templateFile.hashCode() : 0;
|
||||
result = 31 * result + (folder != null ? folder.hashCode() : 0);
|
||||
result = 31 * result + (destinationFilename != null ? destinationFilename.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,15 @@ public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
// clear model and api doc template as AbstractJavaJAXRSServerCodegen
|
||||
// does not support auto-generated markdown doc at the moment
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
}
|
||||
|
||||
// ================
|
||||
// ABSTRACT METHODS
|
||||
// ================
|
||||
|
||||
@@ -51,7 +51,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
"case", "defer", "go", "map", "struct",
|
||||
"chan", "else", "goto", "package", "switch",
|
||||
"const", "fallthrough", "if", "range", "type",
|
||||
"continue", "for", "import", "return", "var", "error")
|
||||
"continue", "for", "import", "return", "var", "error", "ApiResponse")
|
||||
// Added "error" as it's used so frequently that it may as well be a keyword
|
||||
);
|
||||
|
||||
@@ -104,6 +104,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
importMapping = new HashMap<String, String>();
|
||||
importMapping.put("time.Time", "time");
|
||||
importMapping.put("*os.File", "os");
|
||||
importMapping.put("os", "io/ioutil");
|
||||
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).")
|
||||
@@ -144,6 +145,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.go"));
|
||||
supportingFiles.add(new SupportingFile("api_client.mustache", "", "api_client.go"));
|
||||
supportingFiles.add(new SupportingFile("api_response.mustache", "", "api_response.go"));
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
}
|
||||
|
||||
@@ -323,7 +325,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return swaggerType;
|
||||
}
|
||||
|
||||
return camelize(swaggerType, false);
|
||||
return toModelName(swaggerType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -374,6 +376,23 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
// recursivly add import for mapping one type to multipe imports
|
||||
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
|
||||
if (recursiveImports == null)
|
||||
return objs;
|
||||
|
||||
ListIterator<Map<String, String>> listIterator = imports.listIterator();
|
||||
while (listIterator.hasNext()) {
|
||||
String _import = listIterator.next().get("import");
|
||||
// if the import package happens to be found in the importMapping (key)
|
||||
// add the corresponding import package to the list
|
||||
if (importMapping.containsKey(_import)) {
|
||||
Map<String, String> newImportMap= new HashMap<String, String>();
|
||||
newImportMap.put("import", importMapping.get(_import));
|
||||
listIterator.add(newImportMap);
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@@ -388,6 +407,24 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (_import.startsWith(prefix))
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
// recursivly add import for mapping one type to multipe imports
|
||||
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
|
||||
if (recursiveImports == null)
|
||||
return objs;
|
||||
|
||||
ListIterator<Map<String, String>> listIterator = imports.listIterator();
|
||||
while (listIterator.hasNext()) {
|
||||
String _import = listIterator.next().get("import");
|
||||
// if the import package happens to be found in the importMapping (key)
|
||||
// add the corresponding import package to the list
|
||||
if (importMapping.containsKey(_import)) {
|
||||
Map<String, String> newImportMap= new HashMap<String, String>();
|
||||
newImportMap.put("import", importMapping.get(_import));
|
||||
listIterator.add(newImportMap);
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@@ -404,4 +441,4 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void setPackageVersion(String packageVersion) {
|
||||
this.packageVersion = packageVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.models.Operation;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class GroovyClientCodegen extends JavaClientCodegen {
|
||||
public static final String CONFIG_PACKAGE = "configPackage";
|
||||
protected String title = "Petstore Server";
|
||||
protected String configPackage = "";
|
||||
protected String templateFileName = "api.mustache";
|
||||
|
||||
public GroovyClientCodegen() {
|
||||
super();
|
||||
|
||||
sourceFolder = projectFolder + File.separator + "groovy";
|
||||
outputFolder = "generated-code/groovy";
|
||||
modelTemplateFiles.put("model.mustache", ".groovy");
|
||||
apiTemplateFiles.put(templateFileName, ".groovy");
|
||||
embeddedTemplateDir = templateDir = "Groovy";
|
||||
|
||||
apiPackage = "io.swagger.api";
|
||||
modelPackage = "io.swagger.model";
|
||||
configPackage = "io.swagger.configuration";
|
||||
invokerPackage = "io.swagger.api";
|
||||
artifactId = "swagger-spring-mvc-server";
|
||||
|
||||
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
|
||||
additionalProperties.put("title", title);
|
||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
additionalProperties.put(CONFIG_PACKAGE, configPackage);
|
||||
|
||||
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
|
||||
|
||||
supportedLibraries.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "groovy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Groovy API client (beta).";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
// clear model and api doc template as this codegen
|
||||
// does not support auto-generated markdown doc at the moment
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
|
||||
if (additionalProperties.containsKey(CONFIG_PACKAGE)) {
|
||||
this.setConfigPackage((String) additionalProperties.get(CONFIG_PACKAGE));
|
||||
}
|
||||
|
||||
supportingFiles.clear();
|
||||
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
|
||||
// TODO readme to be added later
|
||||
//supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("ApiUtils.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiUtils.groovy"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
name = sanitizeName(name);
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
public void setConfigPackage(String configPackage) {
|
||||
this.configPackage = configPackage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6");
|
||||
supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1");
|
||||
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)");
|
||||
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta4). Enable the RxJava adapter using '-DuseRxJava=true'.");
|
||||
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.1). Enable the RxJava adapter using '-DuseRxJava=true'. (RxJava 1.1.2)");
|
||||
|
||||
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||
library.setDefault(DEFAULT_LIBRARY);
|
||||
|
||||
@@ -70,6 +70,11 @@ public class JavaInflectorServerCodegen extends JavaClientCodegen {
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
// clear model and api doc template as this codegen
|
||||
// does not support auto-generated markdown doc at the moment
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
|
||||
supportingFiles.clear();
|
||||
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
|
||||
|
||||
@@ -20,6 +20,7 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
apiTemplateFiles.put("apiService.mustache", ".java");
|
||||
apiTemplateFiles.put("apiServiceImpl.mustache", ".java");
|
||||
apiTemplateFiles.put("apiServiceFactory.mustache", ".java");
|
||||
|
||||
apiPackage = "io.swagger.api";
|
||||
modelPackage = "io.swagger.model";
|
||||
|
||||
@@ -72,6 +73,11 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
// clear model and api doc template as this codegen
|
||||
// does not support auto-generated markdown doc at the moment
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
|
||||
if ( additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER) ) {
|
||||
implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,11 @@ public class JavaResteasyServerCodegen extends JavaClientCodegen implements Code
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
// clear model and api doc template as AbstractJavaJAXRSServerCodegen
|
||||
// does not support auto-generated markdown doc at the moment
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) {
|
||||
implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER);
|
||||
}
|
||||
@@ -342,4 +347,4 @@ public class JavaResteasyServerCodegen extends JavaClientCodegen implements Code
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,4 +314,10 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
return super.postProcessSupportingFileData(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String removeNonNameElementToCamelCase(String name) {
|
||||
return removeNonNameElementToCamelCase(name, "[-:;#]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,10 +58,12 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("DateTime", "datetime");
|
||||
typeMapping.put("object", "object");
|
||||
typeMapping.put("file", "file");
|
||||
//TODO binary should be mapped to byte array
|
||||
// TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "str");
|
||||
typeMapping.put("ByteArray", "str");
|
||||
// map uuid to string for the time being
|
||||
typeMapping.put("UUID", "str");
|
||||
|
||||
// from https://docs.python.org/release/2.5.4/ref/keywords.html
|
||||
setReservedWordsLowerCase(
|
||||
|
||||
@@ -111,7 +111,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
super.typeMapping = new HashMap<String, String>();
|
||||
|
||||
typeMapping.put("Date", "QDate");
|
||||
typeMapping.put("date", "QDate");
|
||||
typeMapping.put("DateTime", "QDateTime");
|
||||
typeMapping.put("string", "QString");
|
||||
typeMapping.put("integer", "qint32");
|
||||
|
||||
@@ -59,6 +59,11 @@ public class SpringMVCServerCodegen extends JavaClientCodegen {
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
// clear model and api doc template as this codegen
|
||||
// does not support auto-generated markdown doc at the moment
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
|
||||
if (additionalProperties.containsKey(CONFIG_PACKAGE)) {
|
||||
this.setConfigPackage((String) additionalProperties.get(CONFIG_PACKAGE));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user