Merge remote-tracking branch 'origin/master' into csharp_default_paths

This commit is contained in:
Jim Schubert
2016-05-01 20:16:47 -04:00
280 changed files with 5592 additions and 3673 deletions

View File

@@ -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;
}
}

View File

@@ -1,7 +1,6 @@
package io.swagger.codegen;
import io.swagger.models.ExternalDocs;
import java.util.*;
public class CodegenModel {
@@ -39,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;
}
}

View File

@@ -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;
}
}

View File

@@ -137,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;
}
}

View File

@@ -44,6 +44,12 @@ public class CodegenProperty {
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()
{

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -97,10 +97,10 @@ public class DefaultCodegen {
@SuppressWarnings({ "static-method", "unchecked" })
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
if (supportsInheritance) {
// Index all CodegenModels by name.
// Index all CodegenModels by model name.
Map<String, CodegenModel> allModels = new HashMap<String, CodegenModel>();
for (Entry<String, Object> entry : objs.entrySet()) {
String modelName = entry.getKey();
String modelName = toModelName(entry.getKey());
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
for (Map<String, Object> mo : models) {
@@ -328,12 +328,12 @@ public class DefaultCodegen {
}
/**
* Return the JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)
* 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 toJSONSchemaPattern(String pattern) {
public String toRegularExpression(String pattern) {
return escapeText(pattern);
}
@@ -986,7 +986,7 @@ public class DefaultCodegen {
m.interfaces.add(interfaceRef);
addImport(m, interfaceRef);
if (allDefinitions != null) {
final Model interfaceModel = allDefinitions.get(interfaceRef);
final Model interfaceModel = allDefinitions.get(_interface.getSimpleRef());
if (supportsInheritance) {
addProperties(allProperties, allRequired, interfaceModel, allDefinitions);
} else {
@@ -1043,7 +1043,7 @@ public class DefaultCodegen {
required.addAll(mi.getRequired());
}
} else if (model instanceof RefModel) {
String interfaceRef = toModelName(((RefModel) model).getSimpleRef());
String interfaceRef = ((RefModel) model).getSimpleRef();
Model interfaceModel = allDefinitions.get(interfaceRef);
addProperties(properties, required, interfaceModel, allDefinitions);
} else if (model instanceof ComposedModel) {
@@ -1125,7 +1125,7 @@ public class DefaultCodegen {
StringProperty sp = (StringProperty) p;
property.maxLength = sp.getMaxLength();
property.minLength = sp.getMinLength();
property.pattern = toJSONSchemaPattern(sp.getPattern());
property.pattern = toRegularExpression(sp.getPattern());
// check if any validation rule defined
if (property.pattern != null || property.minLength != null || property.maxLength != null)
@@ -1828,7 +1828,7 @@ public class DefaultCodegen {
p.exclusiveMinimum = qp.isExclusiveMinimum();
p.maxLength = qp.getMaxLength();
p.minLength = qp.getMinLength();
p.pattern = toJSONSchemaPattern(qp.getPattern());
p.pattern = toRegularExpression(qp.getPattern());
p.maxItems = qp.getMaxItems();
p.minItems = qp.getMinItems();
p.uniqueItems = qp.isUniqueItems();

View File

@@ -264,6 +264,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
String suffix = config.modelTemplateFiles().get(templateName);
String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix;
if (!config.shouldOverwrite(filename)) {
LOGGER.info("Skipped overwriting " + filename);
continue;
}
String templateFile = getFullTemplateFile(config, templateName);
@@ -286,6 +287,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
String suffix = config.modelTestTemplateFiles().get(templateName);
String filename = config.modelTestFileFolder() + File.separator + config.toModelTestFilename(name) + suffix;
if (!config.shouldOverwrite(filename)) {
LOGGER.info("Skipped overwriting " + filename);
continue;
}
String templateFile = getFullTemplateFile(config, templateName);
@@ -308,6 +310,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
String suffix = config.modelDocTemplateFiles().get(templateName);
String filename = config.modelDocFileFolder() + File.separator + config.toModelDocFilename(name) + suffix;
if (!config.shouldOverwrite(filename)) {
LOGGER.info("Skipped overwriting " + filename);
continue;
}
String templateFile = getFullTemplateFile(config, templateName);
@@ -393,6 +396,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
for (String templateName : config.apiTemplateFiles().keySet()) {
String filename = config.apiFilename(templateName, tag);
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
LOGGER.info("Skipped overwriting " + filename);
continue;
}
@@ -416,6 +420,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
for (String templateName : config.apiTestTemplateFiles().keySet()) {
String filename = config.apiTestFilename(templateName, tag);
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
LOGGER.info("Skipped overwriting " + filename);
continue;
}
@@ -439,6 +444,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
for (String templateName : config.apiDocTemplateFiles().keySet()) {
String filename = config.apiDocFilename(templateName, tag);
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
LOGGER.info("Skipped overwriting " + filename);
continue;
}
@@ -521,6 +527,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
}
String outputFilename = outputFolder + File.separator + support.destinationFilename;
if (!config.shouldOverwrite(outputFilename)) {
LOGGER.info("Skipped overwriting " + outputFilename);
continue;
}

View File

@@ -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;
}
}

View File

@@ -60,8 +60,8 @@ public class CodegenConfigurator {
private Map<String, String> additionalProperties = new HashMap<String, String>();
private Map<String, String> importMappings = new HashMap<String, String>();
private Set<String> languageSpecificPrimitives = new HashSet<String>();
private String gitUserId="YOUR_GIT_USR_ID";
private String gitRepoId="YOUR_GIT_REPO_ID";
private String gitUserId="GIT_USER_ID";
private String gitRepoId="GIT_REPO_ID";
private String releaseNote="Minor update";
private String httpUserAgent;

View File

@@ -375,6 +375,15 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
if (_import.startsWith(apiPackage()))
iterator.remove();
}
// if the return type is not primitive, import encoding/json
for (CodegenOperation operation : operations) {
if(operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
Map<String, String> customImport = new HashMap<String, String>();
customImport.put("import", "encoding/json");
imports.add(customImport);
break; //just need to import once
}
}
// recursivly add import for mapping one type to multipe imports
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");

View File

@@ -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);

View File

@@ -12,9 +12,12 @@ import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.SupportingFile;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.models.ArrayModel;
import io.swagger.models.ComposedModel;
import io.swagger.models.Info;
import io.swagger.models.License;
import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.Operation;
import io.swagger.models.Swagger;
import io.swagger.models.properties.ArrayProperty;
@@ -63,6 +66,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
protected String projectVersion;
protected String projectLicenseName;
protected String invokerPackage;
protected String sourceFolder = "src";
protected String localVariablePrefix = "";
protected boolean usePromises;
@@ -137,6 +141,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC).defaultValue("src"));
cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC));
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(new CliOption(PROJECT_NAME,
@@ -203,6 +208,9 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
}
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
}
if (additionalProperties.containsKey(USE_PROMISES)) {
setUsePromises(Boolean.parseBoolean((String)additionalProperties.get(USE_PROMISES)));
}
@@ -265,6 +273,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
additionalProperties.put(PROJECT_DESCRIPTION, escapeText(projectDescription));
additionalProperties.put(PROJECT_VERSION, projectVersion);
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
additionalProperties.put(CodegenConstants.LOCAL_VARIABLE_PREFIX, localVariablePrefix);
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder);
@@ -278,8 +287,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
additionalProperties.put("modelDocPath", modelDocPath);
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("index.mustache", sourceFolder, "index.js"));
supportingFiles.add(new SupportingFile("ApiClient.mustache", sourceFolder, "ApiClient.js"));
supportingFiles.add(new SupportingFile("index.mustache", createPath(sourceFolder, invokerPackage), "index.js"));
supportingFiles.add(new SupportingFile("ApiClient.mustache", createPath(sourceFolder, invokerPackage), "ApiClient.js"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
}
@@ -289,14 +298,41 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return "_" + name;
}
/**
* Concatenates an array of path segments into a path string.
* @param segments The path segments to concatenate. A segment may contain either of the file separator characters '\' or '/'.
* A segment is ignored if it is <code>null</code>, empty or &quot;.&quot;.
* @return A path string using the correct platform-specific file separator character.
*/
private String createPath(String... segments) {
StringBuilder buf = new StringBuilder();
for (String segment : segments) {
if (!StringUtils.isEmpty(segment) && !segment.equals(".")) {
if (buf.length() != 0)
buf.append(File.separatorChar);
buf.append(segment);
}
}
for (int i = 0; i < buf.length(); i++) {
char c = buf.charAt(i);
if ((c == '/' || c == '\\') && c != File.separatorChar)
buf.setCharAt(i, File.separatorChar);
}
return buf.toString();
}
@Override
public String apiFileFolder() {
return outputFolder + '/' + sourceFolder + '/' + apiPackage().replace('.', '/');
return createPath(outputFolder, sourceFolder, invokerPackage, apiPackage());
}
@Override
public String modelFileFolder() {
return outputFolder + '/' + sourceFolder + '/' + modelPackage().replace('.', '/');
return createPath(outputFolder, sourceFolder, invokerPackage, modelPackage());
}
public void setInvokerPackage(String invokerPackage) {
this.invokerPackage = invokerPackage;
}
public void setSourceFolder(String sourceFolder) {
@@ -345,12 +381,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public String apiDocFileFolder() {
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
return createPath(outputFolder, apiDocPath);
}
@Override
public String modelDocFileFolder() {
return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar);
return createPath(outputFolder, modelDocPath);
}
@Override
@@ -654,10 +690,23 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions);
if (allDefinitions != null && codegenModel != null && codegenModel.parent != null && codegenModel.hasEnums) {
final Model parentModel = allDefinitions.get(toModelName(codegenModel.parent));
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel, allDefinitions);
codegenModel = JavascriptClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
}
if (model instanceof ArrayModel) {
ArrayModel am = (ArrayModel) model;
if (am.getItems() != null) {
codegenModel.vendorExtensions.put("x-isArray", true);
codegenModel.vendorExtensions.put("x-itemType", getSwaggerType(am.getItems()));
}
} else if (model instanceof ModelImpl) {
ModelImpl mm = (ModelImpl)model;
if (mm.getAdditionalProperties() != null) {
codegenModel.vendorExtensions.put("x-isMap", true);
codegenModel.vendorExtensions.put("x-itemType", getSwaggerType(mm.getAdditionalProperties()));
}
}
return codegenModel;
}
@@ -674,7 +723,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
}
private String getModelledType(String dataType) {
return "module:" + (StringUtils.isEmpty(modelPackage) ? "" : (modelPackage + "/")) + dataType;
return "module:" + (StringUtils.isEmpty(invokerPackage) ? "" : (invokerPackage + "/"))
+ (StringUtils.isEmpty(modelPackage) ? "" : (modelPackage + "/")) + dataType;
}
private String getJSDocTypeWithBraces(CodegenModel cm, CodegenProperty cp) {

View File

@@ -20,6 +20,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
protected String packageVersion;
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
private String testFolder;
public PythonClientCodegen() {
super();
@@ -27,12 +29,19 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
modelPackage = "models";
apiPackage = "api";
outputFolder = "generated-code" + File.separatorChar + "python";
modelTemplateFiles.put("model.mustache", ".py");
apiTemplateFiles.put("api.mustache", ".py");
modelTestTemplateFiles.put("model_test.mustache", ".py");
apiTestTemplateFiles.put("api_test.mustache", ".py");
embeddedTemplateDir = templateDir = "python";
modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");
testFolder = "test";
languageSpecificPrimitives.clear();
languageSpecificPrimitives.add("int");
@@ -58,10 +67,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(
@@ -124,6 +135,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
supportingFiles.add(new SupportingFile("__init__package.mustache", swaggerFolder, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__model.mustache", modelPackage, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__api.mustache", apiPackage, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
}
@@ -182,6 +194,16 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
public String modelFileFolder() {
return outputFolder + File.separatorChar + modelPackage().replace('.', File.separatorChar);
}
@Override
public String apiTestFileFolder() {
return outputFolder + File.separatorChar + testFolder;
}
@Override
public String modelTestFileFolder() {
return outputFolder + File.separatorChar + testFolder;
}
@Override
public String getTypeDeclaration(Property p) {
@@ -308,6 +330,11 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
// PhoneNumber => phone_number
return underscore(dropDots(name));
}
@Override
public String toModelTestFilename(String name) {
return "test_" + toModelFilename(name);
};
@Override
public String toApiFilename(String name) {
@@ -317,6 +344,11 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
// e.g. PhoneNumberApi.rb => phone_number_api.rb
return underscore(name) + "_api";
}
@Override
public String toApiTestFilename(String name) {
return "test_" + toApiFilename(name);
}
@Override
public String toApiName(String name) {

View File

@@ -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");

View File

@@ -642,4 +642,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
public void setGemAuthorEmail(String gemAuthorEmail) {
this.gemAuthorEmail = gemAuthorEmail;
}
@Override
public boolean shouldOverwrite(String filename) {
// skip spec file as the file might have been updated with new test cases
return super.shouldOverwrite(filename) && !filename.endsWith("_spec.rb");
}
}

View File

@@ -30,7 +30,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
outputFolder = "generated-code/typescript-angular";
modelTemplateFiles.put("model.mustache", ".ts");
apiTemplateFiles.put("api.mustache", ".ts");
embeddedTemplateDir = templateDir = "TypeScript-Angular";
embeddedTemplateDir = templateDir = "typescript-angular";
apiPackage = "API.Client";
modelPackage = "API.Client";
}

View File

@@ -1,8 +1,82 @@
package io.swagger.codegen.languages;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.SupportingFile;
import io.swagger.models.properties.BooleanProperty;
public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class);
private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm");
public static final String NPM_NAME = "npmName";
public static final String NPM_VERSION = "npmVersion";
public static final String NPM_REPOSITORY = "npmRepository";
public static final String SNAPSHOT = "snapshot";
protected String npmName = null;
protected String npmVersion = "1.0.0";
protected String npmRepository = null;
public TypeScriptNodeClientCodegen() {
super();
outputFolder = "generated-code/typescript-node";
embeddedTemplateDir = templateDir = "typescript-node";
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package"));
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package"));
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
}
@Override
public void processOpts() {
super.processOpts();
supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
LOGGER.warn("check additionals: " + additionalProperties.get(NPM_NAME));
if(additionalProperties.containsKey(NPM_NAME)) {
addNpmPackageGeneration();
}
}
private void addNpmPackageGeneration() {
if(additionalProperties.containsKey(NPM_NAME)) {
this.setNpmName(additionalProperties.get(NPM_NAME).toString());
}
if (additionalProperties.containsKey(NPM_VERSION)) {
this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString());
}
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
}
additionalProperties.put(NPM_VERSION, npmVersion);
if (additionalProperties.containsKey(NPM_REPOSITORY)) {
this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString());
}
//Files for building our lib
supportingFiles.add(new SupportingFile("package.mustache", getPackageRootDirectory(), "package.json"));
supportingFiles.add(new SupportingFile("typings.mustache", getPackageRootDirectory(), "typings.json"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", getPackageRootDirectory(), "tsconfig.json"));
}
private String getPackageRootDirectory() {
String indexPackage = modelPackage.substring(0, Math.max(0, modelPackage.lastIndexOf('.')));
return indexPackage.replace('.', File.separatorChar);
}
@Override
public String getName() {
@@ -14,18 +88,24 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
return "Generates a TypeScript nodejs client library.";
}
@Override
public void processOpts() {
super.processOpts();
supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
}
public TypeScriptNodeClientCodegen() {
super();
outputFolder = "generated-code/typescript-node";
embeddedTemplateDir = templateDir = "TypeScript-node";
public void setNpmName(String npmName) {
this.npmName = npmName;
}
public void setNpmVersion(String npmVersion) {
this.npmVersion = npmVersion;
}
public String getNpmVersion() {
return npmVersion;
}
public String getNpmRepository() {
return npmRepository;
}
public void setNpmRepository(String npmRepository) {
this.npmRepository = npmRepository;
}
}