diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOpts.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOpts.java index 9c4d41f7bfd..1087de5786d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOpts.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOpts.java @@ -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; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java index a7866e5675a..945388b2588 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java @@ -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 vars = new ArrayList(); + public List requiredVars = new ArrayList(); // a list of required properties + public List optionalVars = new ArrayList(); // a list of optional properties public List allVars; public List 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; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java index 2485e657de2..48858a0d504 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java @@ -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; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java index e74b95cf2c1..a69f7197181 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java @@ -20,6 +20,7 @@ public class CodegenParameter { public Map allowableValues; public CodegenProperty items; public Map 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; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java index a7045738cc3..d58a1a81b1d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java @@ -42,6 +42,13 @@ public class CodegenProperty { public Map allowableValues; public CodegenProperty items; public Map 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; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java index e20735b1418..746f65cea38 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java @@ -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; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenSecurity.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenSecurity.java index 10118206383..2e33242c370 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenSecurity.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenSecurity.java @@ -13,4 +13,62 @@ public class CodegenSecurity { // Oauth specific public String flow, authorizationUrl, tokenUrl; public List> 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; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 92041101afc..11400996733 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -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 allowableValues = new HashMap(); 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 _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() { // 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() { @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; } /** diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/SupportingFile.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/SupportingFile.java index 976376bae68..e5fb6a27da6 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/SupportingFile.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/SupportingFile.java @@ -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; + } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java index 4069dded643..99fab6e5444 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java @@ -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 // ================ diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java index 93144cf7afc..ef0ea2e5142 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java @@ -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(); 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> recursiveImports = (List>) objs.get("imports"); + if (recursiveImports == null) + return objs; + + ListIterator> 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 newImportMap= new HashMap(); + 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> recursiveImports = (List>) objs.get("imports"); + if (recursiveImports == null) + return objs; + + ListIterator> 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 newImportMap= new HashMap(); + 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; } -} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java new file mode 100644 index 00000000000..2812d2a301b --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java @@ -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; + } + +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 9fe2b6fc370..2bd79dbf015 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -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); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java index 24f7fddc524..0cf59e5faa7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java @@ -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")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java index 3b3a6dbc280..52f3eb8d844 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java @@ -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); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java index 060c96c317e..5f715a43621 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java @@ -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; } -} \ No newline at end of file +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java index bf1cdcbb900..002496005e1 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java @@ -314,4 +314,10 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig } return super.postProcessSupportingFileData(objs); } + + @Override + public String removeNonNameElementToCamelCase(String name) { + return removeNonNameElementToCamelCase(name, "[-:;#]"); + } + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index a1e3d6f9356..7cb4dc703db 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -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( diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java index ff75d795656..aa32eb4e510 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java @@ -111,7 +111,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig { super.typeMapping = new HashMap(); - typeMapping.put("Date", "QDate"); + typeMapping.put("date", "QDate"); typeMapping.put("DateTime", "QDateTime"); typeMapping.put("string", "QString"); typeMapping.put("integer", "qint32"); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java index 1dd66c6400d..41d17a3e807 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java @@ -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)); } diff --git a/modules/swagger-codegen/src/main/resources/Groovy/api.mustache b/modules/swagger-codegen/src/main/resources/Groovy/api.mustache index 0d60fa2a96f..c952718b6ec 100644 --- a/modules/swagger-codegen/src/main/resources/Groovy/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Groovy/api.mustache @@ -1,14 +1,9 @@ package {{package}}; - - - - import groovyx.net.http.* import static groovyx.net.http.ContentType.* import static groovyx.net.http.Method.* import {{invokerPackage}}.ApiUtils -//------------- {{#imports}}import {{import}} {{/imports}} @@ -21,36 +16,37 @@ class {{classname}} { String basePath = "{{basePath}}" String versionPath = "/api/v1" + {{#operation}} + def {{operationId}} ({{#allParams}} {{{dataType}}} {{paramName}},{{/allParams}} Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "{{path}}" - {{#operation}} - def {{nickname}} ({{#allParams}} {{{dataType}}} {{paramName}},{{/allParams}} Closure onSuccess, Closure onFailure) { - // create path and map variables - String resourcePath = "{{path}}" + // query params + def queryParams = [:] + def headerParams = [:] + + {{#allParams}} + {{#required}} + // verify required params are set + if ({{paramName}} == null) { + throw new RuntimeException("missing required params {{paramName}}") + } + {{/required}} + {{/allParams}} + {{#queryParams}}if (!"null".equals(String.valueOf({{paramName}}))) + queryParams.put("{{paramName}}", String.valueOf({{paramName}})) + {{/queryParams}} - // query params - def queryParams = [:] - def headerParams = [:] + {{#headerParams}} + headerParams.put("{{paramName}}", {{paramName}}) + {{/headerParams}} - {{#allParams}} - // verify required params are set - if({{/allParams}}{{#required}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/required}}{{#allParams}}) { - throw new RuntimeException("missing required params") - } - {{/allParams}} - - {{#queryParams}}if(!"null".equals(String.valueOf({{paramName}}))) - queryParams.put("{{paramName}}", String.valueOf({{paramName}})) - {{/queryParams}} - - {{#headerParams}}headerParams.put("{{paramName}}", {{paramName}}) - {{/headerParams}} - - invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "{{httpMethod}}", "{{returnContainer}}", {{#returnBaseType}}{{{returnBaseType}}}.class {{/returnBaseType}}{{^returnBaseType}}null {{/returnBaseType}}) - - } - {{/operation}} + + } + {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache index 49edec87133..238f5e6e09f 100644 --- a/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache @@ -17,15 +17,26 @@ buildscript { } repositories { - mavenCentral() - mavenLocal() - mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone']) - maven { url "http://$artifactory:8080/artifactory/repo" } + mavenCentral() + mavenLocal() + mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone']) + maven { url "http://$artifactory:8080/artifactory/repo" } +} + +ext { + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" } dependencies { - groovy "org.codehaus.groovy:groovy-all:2.0.5" - compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.6' + compile 'org.codehaus.groovy:groovy-all:2.4.6' + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" + compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1' } task wrapper(type: Wrapper) { gradleVersion = '1.6' } diff --git a/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache index 7dfb69db418..9920a371e5d 100644 --- a/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - swagger_annotations_version = "1.5.0" - jackson_version = "2.4.2" - jersey_version = "1.18" - jodatime_version = "2.3" + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" + jersey_version = "1.19.1" + jodatime_version = "2.9.3" junit_version = "4.12" } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache index f644a9deda6..35d06f01019 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache @@ -94,11 +94,12 @@ if(hasProperty('target') && target == 'android') { } ext { - swagger_annotations_version = "1.5.0" - jackson_version = "2.6.3" - feign_version = "8.1.1" - jodatime_version = "2.5" + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" + feign_version = "8.16.0" + jodatime_version = "2.9.3" junit_version = "4.12" + oltu_version = "1.0.1" } dependencies { @@ -111,6 +112,7 @@ dependencies { compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" compile "joda-time:joda-time:$jodatime_version" + compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" compile "com.brsanthu:migbase64:2.2" testCompile "junit:junit:$junit_version" } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache index 5ff827ff40c..03323a65a03 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 @@ -180,11 +180,11 @@ 1.5.8 - 8.1.1 - 2.6.3 - 2.5 + 8.16.0 + 2.7.0 + 2.9.3 4.12 1.0.0 - 1.0.0 + 1.0.1 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache index c533c34558d..aa0e6da3fb0 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - swagger_annotations_version = "1.5.0" - jackson_version = "2.4.2" - jersey_version = "2.22" - jodatime_version = "2.3" + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" + jersey_version = "2.22.2" + jodatime_version = "2.9.3" junit_version = "4.12" } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache index 13fab8b0ed2..472bbf9b9b8 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 @@ -195,9 +195,9 @@ 1.5.8 - 2.22 - 2.4.2 - 2.3 + 2.22.2 + 2.7.0 + 2.9.3 1.0.0 4.12 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache index d033d9a1c68..4e7b0d1c395 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache @@ -94,9 +94,9 @@ if(hasProperty('target') && target == 'android') { } dependencies { - compile 'io.swagger:swagger-annotations:1.5.0' - compile 'com.squareup.okhttp:okhttp:2.7.2' - compile 'com.squareup.okhttp:logging-interceptor:2.7.2' - compile 'com.google.code.gson:gson:2.3.1' + compile 'io.swagger:swagger-annotations:1.5.8' + compile 'com.squareup.okhttp:okhttp:2.7.5' + compile 'com.squareup.okhttp:logging-interceptor:2.7.5' + compile 'com.google.code.gson:gson:2.6.2' testCompile 'junit:junit:4.12' } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache index 50e843248fb..bee8e03fa0e 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache @@ -9,10 +9,10 @@ lazy val root = (project in file(".")). publishArtifact in (Compile, packageDoc) := false, resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( - "io.swagger" % "swagger-annotations" % "1.5.0", - "com.squareup.okhttp" % "okhttp" % "2.7.2", - "com.squareup.okhttp" % "logging-interceptor" % "2.7.2", - "com.google.code.gson" % "gson" % "2.3.1", - "junit" % "junit" % "4.8.1" % "test" + "io.swagger" % "swagger-annotations" % "1.5.8", + "com.squareup.okhttp" % "okhttp" % "2.7.5", + "com.squareup.okhttp" % "logging-interceptor" % "2.7.5", + "com.google.code.gson" % "gson" % "2.6.2", + "junit" % "junit" % "4.12.0" % "test" ) ) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache index bbcbeca4367..7f08e5afb58 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 @@ -160,8 +160,8 @@ 1.5.8 - 2.7.2 - 2.3.1 + 2.7.5 + 2.6.2 1.0.0 4.12 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache index 19b741034e7..6be9ba586f3 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - okhttp_version = "2.3.0" - oltu_version = "1.0.0" + okhttp_version = "2.7.5" + oltu_version = "1.0.1" retrofit_version = "1.9.0" - swagger_annotations_version = "1.5.0" + swagger_annotations_version = "1.5.8" junit_version = "4.12" } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache index 2370cf4a211..9a917f19caf 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 @@ -139,8 +139,8 @@ 1.5.8 1.9.0 - 2.4.0 - 1.0.0 + 2.7.5 + 1.0.1 1.0.0 4.12 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache index 1bced5a0452..e56e682cfcd 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache @@ -94,13 +94,12 @@ if(hasProperty('target') && target == 'android') { } ext { - oltu_version = "1.0.0" - retrofit_version = "2.0.0-beta4" - gson_version = "2.4" - swagger_annotations_version = "1.5.0" + oltu_version = "1.0.1" + retrofit_version = "2.0.2" + swagger_annotations_version = "1.5.8" junit_version = "4.12" {{#useRxJava}} - rx_java_version = "1.0.16" + rx_java_version = "1.1.3" {{/useRxJava}} {{^useRxJava}}{{/useRxJava}} } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache index a76fb3b9547..30f6a71d285 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache @@ -100,8 +100,7 @@ maven-compiler-plugin 2.3.2 - - 1.7 + 1.7 1.7 @@ -113,6 +112,11 @@ swagger-annotations ${swagger-core-version} + + com.squareup.retrofit2 + converter-gson + ${retrofit-version} + com.squareup.retrofit2 retrofit @@ -123,11 +127,6 @@ converter-scalars ${retrofit-version} - - com.squareup.retrofit2 - converter-gson - ${retrofit-version} - org.apache.oltu.oauth2 org.apache.oltu.oauth2.client @@ -154,9 +153,10 @@ 1.5.8 - 2.0.0-beta4{{#useRxJava}} - 1.0.16{{/useRxJava}} - 1.0.0 + 2.0.2 + {{#useRxJava}}1.1.3{{/useRxJava}} + 3.2.0 + 1.0.1 1.0.0 4.12 diff --git a/modules/swagger-codegen/src/main/resources/Java/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/pom.mustache index 425b525cc55..8521b54bad0 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pom.mustache @@ -97,8 +97,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 @@ -172,9 +172,9 @@ UTF-8 1.5.8 - 1.18 - 2.4.2 - 2.3 + 1.19.1 + 2.7.0 + 2.9.3 1.0.0 4.12 diff --git a/modules/swagger-codegen/src/main/resources/Javascript-Closure-Angular/api.mustache b/modules/swagger-codegen/src/main/resources/Javascript-Closure-Angular/api.mustache index 957add6753e..35604bf73df 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript-Closure-Angular/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript-Closure-Angular/api.mustache @@ -47,8 +47,8 @@ goog.require('{{import}}'); /** @private {!angular.$http} */ this.http_ = $http; - /** @private {!Object} */ - this.httpParamSerializer_ = $injector.get('$httpParamSerializer'); + /** @package {!Object} */ + this.httpParamSerializer = $injector.get('$httpParamSerializer'); } {{package}}.{{classname}}.$inject = ['$http', '$httpParamSerializer', '$injector']; {{#operation}} @@ -69,7 +69,7 @@ goog.require('{{import}}'); var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); {{#hasFormParams}} /** @type {!Object} */ var formParams = {}; @@ -108,7 +108,7 @@ goog.require('{{import}}'); json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}}, {{#bodyParam}}data: {{^required}}opt_{{/required}}{{paramName}}, {{/bodyParam}} - {{#hasFormParams}}data: this.httpParamSerializer_(formParams), + {{#hasFormParams}}data: this.httpParamSerializer(formParams), {{/hasFormParams}} params: queryParameters, headers: headerParams @@ -118,7 +118,7 @@ goog.require('{{import}}'); httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } {{/operation}} {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 21a75b23d5c..22823c95626 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -6,6 +6,7 @@ io.swagger.codegen.languages.DartClientCodegen io.swagger.codegen.languages.FlashClientCodegen io.swagger.codegen.languages.FlaskConnexionCodegen io.swagger.codegen.languages.GoClientCodegen +io.swagger.codegen.languages.GroovyClientCodegen io.swagger.codegen.languages.JavaClientCodegen io.swagger.codegen.languages.JavaJerseyServerCodegen io.swagger.codegen.languages.JavaCXFServerCodegen @@ -41,4 +42,4 @@ io.swagger.codegen.languages.AkkaScalaClientCodegen io.swagger.codegen.languages.CsharpDotNet2ClientCodegen io.swagger.codegen.languages.ClojureClientCodegen io.swagger.codegen.languages.HaskellServantCodegen -io.swagger.codegen.languages.LumenServerCodegen \ No newline at end of file +io.swagger.codegen.languages.LumenServerCodegen diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 35ed984929d..6e540d3f876 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -6,7 +6,6 @@ import ( "fmt" "encoding/json" "errors" - "github.com/dghubble/sling" {{#imports}} "{{import}}" {{/imports}} ) @@ -38,130 +37,115 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{ {{#allParams}} * @param {{paramName}} {{description}} {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ -func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { - {{#allParams}} - {{#required}} - // verify the required parameter '{{paramName}}' is set - if &{{paramName}} == nil { - return {{#returnType}}*new({{{returnType}}}), {{/returnType}}errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") - } - {{/required}} - {{/allParams}} - _sling := sling.New().{{httpMethod}}(a.Configuration.BasePath) +func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}APIResponse, error) { - {{#authMethods}}// authentication ({{name}}) required - {{#isApiKey}}{{#isKeyInHeader}} - // set key with prefix in header - _sling.Set("{{keyParamName}}", a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")) - {{/isKeyInHeader}}{{#isKeyInQuery}} - // set key with prefix in querystring - {{#hasKeyParamName}} type KeyQueryParams struct { - {{keyParamName}} string `url:"{{keyParamName}},omitempty"` - } - _sling = _sling.QueryStruct(&KeyQueryParams{ {{keyParamName}}: a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") }) - {{/hasKeyParamName}} - {{/isKeyInQuery}}{{/isApiKey}} - {{#isBasic}} - // http basic authentication required - if a.Configuration.Username != "" || a.Configuration.Password != ""{ - _sling.Set("Authorization", "Basic " + a.Configuration.GetBasicAuthEncodedString()) - } - {{/isBasic}} - {{#isOAuth}} - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } - {{/isOAuth}} - {{/authMethods}} - - // create path and map variables - path := "{{basePathWithoutHost}}{{path}}" -{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) + var httpMethod = "{{httpMethod}}" + // create path and map variables + path := a.Configuration.BasePath + "{{path}}" +{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) {{/pathParams}} - _sling = _sling.Path(path) + {{#allParams}} + {{#required}} + // verify the required parameter '{{paramName}}' is set + if &{{paramName}} == nil { + return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") + } + {{/required}} + {{/allParams}} - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - -{{#hasQueryParams}} type QueryParams struct { - {{#queryParams}}{{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` - {{/queryParams}} -} - _sling = _sling.QueryStruct(&QueryParams{ {{#queryParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/queryParams}} }) -{{/hasQueryParams}} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - // to determine the Content-Type header - localVarHttpContentTypes := []string { - {{#consumes}} - "{{mediaType}}", - {{/consumes}} - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } + {{#authMethods}}// authentication ({{name}}) required + {{#isApiKey}}{{#isKeyInHeader}} + // set key with prefix in header + headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}") + {{/isKeyInHeader}}{{#isKeyInQuery}} + // set key with prefix in querystring + {{#hasKeyParamName}} + queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}") + {{/hasKeyParamName}} + {{/isKeyInQuery}}{{/isApiKey}} + {{#isBasic}} + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + {{/isBasic}} + {{#isOAuth}} + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + {{/isOAuth}} + {{/authMethods}} - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - {{#produces}} - "{{mediaType}}", - {{/produces}} - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + {{#hasQueryParams}} + {{#queryParams}} + queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}}) + {{/queryParams}} + {{/hasQueryParams}} + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + {{#consumes}} + "{{mediaType}}", + {{/consumes}} + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + {{#produces}} + "{{mediaType}}", + {{/produces}} + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } {{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}" - _sling = _sling.Set("{{baseName}}", {{paramName}}) + headerParams["{{baseName}}"] = {{paramName}} {{/headerParams}}{{/hasHeaderParams}} -{{#hasFormParams}} type FormParams struct { -{{#formParams}} {{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` +{{#hasFormParams}} +{{#formParams}} + {{#isFile}}fbs, _ := ioutil.ReadAll(file) + fileBytes = fbs + fileName = file.Name() + {{/isFile}} +{{^isFile}}formParams["{{paramName}}"] = {{paramName}} + {{/isFile}} {{/formParams}} - } - _sling = _sling.BodyForm(&FormParams{ {{#formParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/formParams}} }) -{{/hasFormParams}} -{{#hasBodyParam}}{{#bodyParams}}// body params - _sling = _sling.BodyJSON({{paramName}}) +{{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} // body params + postBody = &{{paramName}} {{/bodyParams}}{{/hasBodyParam}} {{#returnType}} var successPayload = new({{returnType}}){{/returnType}} + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive({{#returnType}}successPayload{{/returnType}}{{^returnType}}nil{{/returnType}}, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil { + return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err } +{{#returnType}} - return {{#returnType}}*successPayload, {{/returnType}}err + err = json.Unmarshal(httpResponse.Body(), &successPayload) +{{/returnType}} + + return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err } {{/operation}} {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index 06470ba06d6..a88445656d7 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -2,13 +2,18 @@ package {{packageName}} import ( "strings" + "github.com/go-resty/resty" + "fmt" + "reflect" + "bytes" + "path/filepath" ) -type ApiClient struct { +type APIClient struct { } -func (c *ApiClient) SelectHeaderContentType(contentTypes []string) string { +func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { if (len(contentTypes) == 0){ return "" } @@ -19,7 +24,7 @@ func (c *ApiClient) SelectHeaderContentType(contentTypes []string) string { return contentTypes[0] // use the first content type specified in 'consumes' } -func (c *ApiClient) SelectHeaderAccept(accepts []string) string { +func (c *APIClient) SelectHeaderAccept(accepts []string) string { if (len(accepts) == 0){ return "" } @@ -38,4 +43,81 @@ func contains(source []string, containvalue string) bool { } } return false -} \ No newline at end of file +} + + +func (c *APIClient) CallAPI(path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileName string, + fileBytes []byte) (*resty.Response, error) { + + //set debug flag + configuration := NewConfiguration() + resty.SetDebug(configuration.GetDebug()) + + request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) + + switch strings.ToUpper(method) { + case "GET": + response, err := request.Get(path) + return response, err + case "POST": + response, err := request.Post(path) + return response, err + case "PUT": + response, err := request.Put(path) + return response, err + case "PATCH": + response, err := request.Patch(path) + return response, err + case "DELETE": + response, err := request.Delete(path) + return response, err + } + + return nil, fmt.Errorf("invalid method %v", method) +} + +func (c *APIClient) ParameterToString(obj interface{}) string { + if reflect.TypeOf(obj).String() == "[]string" { + return strings.Join(obj.([]string), ",") + } else { + return obj.(string) + } +} + +func prepareRequest(postBody interface{}, + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileName string, + fileBytes []byte) *resty.Request { + + request := resty.R() + + request.SetBody(postBody) + + // add header parameter, if any + if len(headerParams) > 0 { + request.SetHeaders(headerParams) + } + + // add query parameter, if any + if len(queryParams) > 0 { + request.SetQueryParams(queryParams) + } + + // add form parameter, if any + if len(formParams) > 0 { + request.SetFormData(formParams) + } + + if len(fileBytes) > 0 && fileName != "" { + _, fileNm := filepath.Split(fileName) + request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) + } + return request +} diff --git a/modules/swagger-codegen/src/main/resources/go/api_response.mustache b/modules/swagger-codegen/src/main/resources/go/api_response.mustache new file mode 100644 index 00000000000..9f81de76d62 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go/api_response.mustache @@ -0,0 +1,24 @@ +package {{packageName}} + +import ( + "net/http" +) + + +type APIResponse struct { + *http.Response + + Message string `json:"message,omitempty"` +} + +func NewAPIResponse(r *http.Response) *APIResponse { + response := &APIResponse{Response: r} + + return response +} + +func NewAPIResponseWithError(errorMessage string) *APIResponse { + response := &APIResponse{Message: errorMessage} + + return response +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/go/configuration.mustache b/modules/swagger-codegen/src/main/resources/go/configuration.mustache index 154ceb9ffc6..d971bf0373b 100644 --- a/modules/swagger-codegen/src/main/resources/go/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/go/configuration.mustache @@ -7,9 +7,9 @@ import ( type Configuration struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` - ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"` - ApiKey map[string] string `json:"apiKey,omitempty"` - Debug bool `json:"debug,omitempty"` + APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"` + APIKey map[string] string `json:"APIKey,omitempty"` + debug bool `json:"debug,omitempty"` DebugFile string `json:"debugFile,omitempty"` OAuthToken string `json:"oAuthToken,omitempty"` Timeout int `json:"timeout,omitempty"` @@ -19,17 +19,17 @@ type Configuration struct { AccessToken string `json:"accessToken,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` - ApiClient ApiClient `json:"apiClient,omitempty"` + APIClient APIClient `json:"APIClient,omitempty"` } func NewConfiguration() *Configuration { return &Configuration{ BasePath: "{{basePath}}", UserName: "", - Debug: false, + debug: false, DefaultHeader: make(map[string]string), - ApiKey: make(map[string]string), - ApiKeyPrefix: make(map[string]string), + APIKey: make(map[string]string), + APIKeyPrefix: make(map[string]string), UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/go{{/httpUserAgent}}", } } @@ -42,10 +42,18 @@ func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value } -func (c *Configuration) GetApiKeyWithPrefix(apiKeyIdentifier string) string { - if c.ApiKeyPrefix[apiKeyIdentifier] != ""{ - return c.ApiKeyPrefix[apiKeyIdentifier] + " " + c.ApiKey[apiKeyIdentifier] +func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { + if c.APIKeyPrefix[APIKeyIdentifier] != ""{ + return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] } - return c.ApiKey[apiKeyIdentifier] + return c.APIKey[APIKeyIdentifier] +} + +func (c *Configuration) SetDebug(enable bool){ + c.debug = enable +} + +func (c *Configuration) GetDebug() bool { + return c.debug } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache index 142e14a9e80..18b756f78b0 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache @@ -2,6 +2,10 @@ NSString *const {{classPrefix}}ResponseObjectErrorKey = @"{{classPrefix}}ResponseObject"; +NSString *const {{classPrefix}}DeserializationErrorDomainKey = @"{{classPrefix}}DeserializationErrorDomainKey"; + +NSInteger const {{classPrefix}}TypeMismatchErrorCode = 143553; + static long requestId = 0; static bool offlineState = false; static NSMutableSet * queuedRequests = nil; @@ -288,13 +292,7 @@ static void (^reachabilityChangeBlock)(int); #pragma mark - Deserialize methods -- (id) deserialize:(id) data class:(NSString *) class { - NSRegularExpression *regexp = nil; - NSTextCheckingResult *match = nil; - NSMutableArray *resultArray = nil; - NSMutableDictionary *resultDict = nil; - NSString *innerType = nil; - +- (id) deserialize:(id) data class:(NSString *) class error:(NSError **) error { // return nil if data is nil or class is nil if (!data || !class) { return nil; @@ -310,6 +308,12 @@ static void (^reachabilityChangeBlock)(int); return data; } + NSRegularExpression *regexp = nil; + NSTextCheckingResult *match = nil; + NSMutableArray *resultArray = nil; + NSMutableDictionary *resultDict = nil; + NSString *innerType = nil; + // list of models NSString *arrayOfModelsPat = @"NSArray<(.+)>"; regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfModelsPat @@ -321,14 +325,25 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { + if(![data isKindOfClass: [NSArray class]]) { + if(error) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : NSLocalizedString(@"Received response is not an array", nil)}; + *error = [NSError errorWithDomain:{{classPrefix}}DeserializationErrorDomainKey code:{{classPrefix}}TypeMismatchErrorCode userInfo:userInfo]; + } + return nil; + } NSArray *dataArray = data; innerType = [class substringWithRange:[match rangeAtIndex:1]]; resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [resultArray addObject:[self deserialize:obj class:innerType]]; + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else { + * stop = YES; } - ]; + }]; return resultArray; } @@ -348,7 +363,12 @@ static void (^reachabilityChangeBlock)(int); resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [resultArray addObject:[self deserialize:obj class:innerType]]; + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else { + * stop = YES; + } }]; return resultArray; @@ -369,7 +389,12 @@ static void (^reachabilityChangeBlock)(int); resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]]; [data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - [resultDict setValue:[self deserialize:obj class:valueType] forKey:key]; + id dicObj = [self deserialize:obj class:valueType error:error]; + if(dicObj) { + [resultDict setValue:dicObj forKey:key]; + } else { + * stop = YES; + } }]; return resultDict; @@ -407,7 +432,7 @@ static void (^reachabilityChangeBlock)(int); // model Class ModelClass = NSClassFromString(class); if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) { - return [[ModelClass alloc] initWithDictionary:data error:nil]; + return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error]; } return nil; @@ -635,7 +660,12 @@ static void (^reachabilityChangeBlock)(int); } else { [self operationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { - completionBlock([self deserialize:data class:responseType], error); + NSError * serializationError; + id response = [self deserialize:data class:responseType error:&serializationError]; + if(!response && !error){ + error = serializationError; + } + completionBlock(response, error); }]; } return requestId; diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache index a039e7e168e..1cf3db5e523 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache @@ -25,6 +25,16 @@ */ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; +/** + * A key for deserialization ErrorDomain + */ +extern NSString *const {{classPrefix}}DeserializationErrorDomainKey; + +/** + * Code for deserialization type mismatch error + */ +extern NSInteger const {{classPrefix}}TypeMismatchErrorCode; + /** * Log debug message macro */ @@ -171,8 +181,9 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; * * @param data The data will be deserialized. * @param class The type of objective-c object. + * @param error The error */ -- (id) deserialize:(id) data class:(NSString *) class; +- (id) deserialize:(id) data class:(NSString *) class error:(NSError**)error; /** * Logs request and response diff --git a/modules/swagger-codegen/src/main/resources/ruby/README.mustache b/modules/swagger-codegen/src/main/resources/ruby/README.mustache index 7f54eef9e69..f4bafd9b0ea 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/README.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/README.mustache @@ -31,6 +31,7 @@ Then either install the gem locally: ```shell gem install ./{{{gemName}}}-{{{gemVersion}}}.gem ``` +(for development, run `gem install --dev ./{{{gemName}}}-{{{gemVersion}}}.gem` to install the development dependencies) or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). diff --git a/modules/swagger-codegen/src/main/resources/ruby/api.mustache b/modules/swagger-codegen/src/main/resources/ruby/api.mustache index 594a813de72..20b6d4593e3 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api.mustache @@ -33,19 +33,59 @@ module {{moduleName}} {{/required}}{{/allParams}} # @return [Array<({{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}, Fixnum, Hash)>] {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}, response status code and response headers def {{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: {{classname}}#{{operationId}} ..." + @api_client.config.logger.debug "Calling API: {{classname}}.{{operationId}} ..." end - {{#allParams}}{{#required}} + {{#allParams}} + {{#required}} # verify the required parameter '{{paramName}}' is set - fail "Missing the required parameter '{{paramName}}' when calling {{operationId}}" if {{{paramName}}}.nil?{{#isEnum}} + fail ArgumentError, "Missing the required parameter '{{paramName}}' when calling {{classname}}.{{operationId}}" if {{{paramName}}}.nil? + {{#isEnum}} + # verify enum value unless [{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}].include?({{{paramName}}}) - fail "invalid value for '{{{paramName}}}', must be one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}" - end{{/isEnum}} - {{/required}}{{^required}}{{#isEnum}} - if opts[:'{{{paramName}}}'] && ![{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}].include?(opts[:'{{{paramName}}}']) - fail 'invalid value for "{{{paramName}}}", must be one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}' + fail ArgumentError, "invalid value for '{{{paramName}}}', must be one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}" end - {{/isEnum}}{{/required}}{{/allParams}} + {{/isEnum}} + {{/required}} + {{^required}} + {{#isEnum}} + if opts[:'{{{paramName}}}'] && ![{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}].include?(opts[:'{{{paramName}}}']) + fail ArgumentError, 'invalid value for "{{{paramName}}}", must be one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}' + end + {{/isEnum}} + {{/required}} + {{#hasValidation}} + {{#minLength}} + if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length > {{{maxLength}}} + fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be smaller than or equal to {{{maxLength}}}.' + end + + {{/minLength}} + {{#maxLength}} + if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length < {{{minLength}}} + fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be great than or equal to {{{minLength}}}.' + end + + {{/maxLength}} + {{#maximum}} + if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} > {{{maximum}}} + fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{{maximum}}}.' + end + + {{/maximum}} + {{#minimum}} + if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} < {{{minimum}}} + fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must be greater than or equal to {{{minimum}}}.' + end + + {{/minimum}} + {{#pattern}} + if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} !~ Regexp.new({{{pattern}}}) + fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}.' + end + + {{/pattern}} + {{/hasValidation}} + {{/allParams}} # resource path local_var_path = "{{path}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}} diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index 5b7b617481f..14f26898d2b 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -38,26 +38,183 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} {{#vars}} - if attributes[:'{{{baseName}}}'] - {{#isContainer}}if (value = attributes[:'{{{baseName}}}']).is_a?(Array) + if attributes.has_key?(:'{{{baseName}}}') + {{#isContainer}} + if (value = attributes[:'{{{baseName}}}']).is_a?(Array) self.{{{name}}} = value - end{{/isContainer}}{{^isContainer}}self.{{{name}}} = attributes[:'{{{baseName}}}']{{/isContainer}}{{#defaultValue}} + end + {{/isContainer}} + {{^isContainer}} + self.{{{name}}} = attributes[:'{{{baseName}}}'] + {{/isContainer}} + {{#defaultValue}} else - self.{{{name}}} = {{{defaultValue}}}{{/defaultValue}} + self.{{{name}}} = {{{defaultValue}}} + {{/defaultValue}} end + {{/vars}} end -{{#vars}}{{#isEnum}} + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + {{#isEnum}} + allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] + if @{{{name}}} && !allowed_values.include?({{{name}}}) + invalid_properties.push("invalid value for '{{{name}}}', must be one of #{allowed_values}.") + end + + {{/isEnum}} + {{#hasValidation}} + if @{{{name}}}.nil? + fail ArgumentError, "{{{name}}} cannot be nil" + end + + {{#minLength}} + if @{{{name}}}.to_s.length > {{{maxLength}}} + invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.") + end + + {{/minLength}} + {{#maxLength}} + if @{{{name}}}.to_s.length < {{{minLength}}} + invalid_properties.push("invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}.") + end + + {{/maxLength}} + {{#maximum}} + if @{{{name}}} > {{{maximum}}} + invalid_properties.push("invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}.") + end + + {{/maximum}} + {{#minimum}} + if @{{{name}}} < {{{minimum}}} + invalid_properties.push("invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}.") + end + + {{/minimum}} + {{#pattern}} + if @{{{name}}} !~ Regexp.new({{{pattern}}}) + invalid_properties.push("invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}.") + end + + {{/pattern}} + {{/hasValidation}} + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + {{#vars}} + {{#required}} + if @{{{name}}}.nil? + return false + end + + {{/required}} + {{#isEnum}} + allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] + if @{{{name}}} && !allowed_values.include?(@{{{name}}}) + return false + end + {{/isEnum}} + {{#hasValidation}} + {{#minLength}} + if @{{{name}}}.to_s.length > {{{maxLength}}} + return false + end + + {{/minLength}} + {{#maxLength}} + if @{{{name}}}.to_s.length < {{{minLength}}} + return false + end + + {{/maxLength}} + {{#maximum}} + if @{{{name}}} > {{{maximum}}} + return false + end + + {{/maximum}} + {{#minimum}} + if @{{{name}}} < {{{minimum}}} + return false + end + + {{/minimum}} + {{#pattern}} + if @{{{name}}} !~ Regexp.new({{{pattern}}}) + return false + end + + {{/pattern}} + {{/hasValidation}} + {{/vars}} + end + + {{#vars}} + {{#isEnum}} # Custom attribute writer method checking allowed values (enum). # @param [Object] {{{name}}} Object to be assigned def {{{name}}}=({{{name}}}) allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] if {{{name}}} && !allowed_values.include?({{{name}}}) - fail "invalid value for '{{{name}}}', must be one of #{allowed_values}" + fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}." end @{{{name}}} = {{{name}}} end -{{/isEnum}}{{/vars}} + + {{/isEnum}} + {{^isEnum}} + {{#hasValidation}} + # Custom attribute writer method with validation + # @param [Object] {{{name}}} Value to be assigned + def {{{name}}}=({{{name}}}) + if {{{name}}}.nil? + fail ArgumentError, "{{{name}}} cannot be nil" + end + + {{#minLength}} + if {{{name}}}.to_s.length > {{{maxLength}}} + fail ArgumentError, "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}." + end + + {{/minLength}} + {{#maxLength}} + if {{{name}}}.to_s.length < {{{minLength}}} + fail ArgumentError, "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}." + end + + {{/maxLength}} + {{#maximum}} + if {{{name}}} > {{{maximum}}} + fail ArgumentError, "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}." + end + + {{/maximum}} + {{#minimum}} + if {{{name}}} < {{{minimum}}} + fail ArgumentError, "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}." + end + + {{/minimum}} + {{#pattern}} + if @{{{name}}} !~ Regexp.new({{{pattern}}}) + fail ArgumentError, "invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}." + end + + {{/pattern}} + @{{{name}}} = {{{name}}} + end + + {{/hasValidation}} + {{/isEnum}} + {{/vars}} # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) diff --git a/modules/swagger-codegen/src/main/resources/swift/Models.mustache b/modules/swagger-codegen/src/main/resources/swift/Models.mustache index 795fdd3d5e7..378c83525f1 100644 --- a/modules/swagger-codegen/src/main/resources/swift/Models.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/Models.mustache @@ -137,9 +137,22 @@ class Decoders { // Decoder for {{{classname}}} Decoders.addDecoder(clazz: {{{classname}}}.self) { (source: AnyObject) -> {{{classname}}} in let sourceDictionary = source as! [NSObject:AnyObject] + {{#unwrapRequired}} + let instance = {{classname}}({{#requiredVars}}{{^-first}}, {{/-first}}{{#isEnum}}{{name}}: {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? "")! {{/isEnum}}{{^isEnum}}{{name}}: Decoders.decode(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]!){{/isEnum}}{{/requiredVars}}) + {{#optionalVars}} + {{#isEnum}} + instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? "") + {{/isEnum}} + {{^isEnum}} + instance.{{name}} = Decoders.decodeOptional(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]) + {{/isEnum}} + {{/optionalVars}} + {{/unwrapRequired}} + {{^unwrapRequired}} let instance = {{classname}}(){{#vars}}{{#isEnum}} - instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? ""){{#unwrapRequired}}{{#required}}!{{/required}}{{/unwrapRequired}} {{/isEnum}}{{^isEnum}} - instance.{{name}} = Decoders.decode{{^unwrapRequired}}Optional{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}Optional{{/required}}{{/unwrapRequired}}(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]{{#unwrapRequired}}{{#required}}!{{/required}}{{/unwrapRequired}}){{/isEnum}}{{/vars}} + instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? "") {{/isEnum}}{{^isEnum}} + instance.{{name}} = Decoders.decodeOptional(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]){{/isEnum}}{{/vars}} + {{/unwrapRequired}} return instance }{{/model}} {{/models}} diff --git a/modules/swagger-codegen/src/main/resources/swift/api.mustache b/modules/swagger-codegen/src/main/resources/swift/api.mustache index 195fb88aeed..9801182e082 100644 --- a/modules/swagger-codegen/src/main/resources/swift/api.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/api.mustache @@ -76,9 +76,9 @@ public class {{classname}}: APIBase { {{#bodyParam}} let parameters = {{paramName}}{{^required}}?{{/required}}.encodeToJSON() as? [String:AnyObject]{{/bodyParam}}{{^bodyParam}} let nillableParameters: [String:AnyObject?] = {{^queryParams}}{{^formParams}}[:]{{/formParams}}{{#formParams}}{{^secondaryParam}}[{{/secondaryParam}} - "{{baseName}}": {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}} + "{{baseName}}": {{paramName}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{#hasMore}},{{/hasMore}}{{^hasMore}} ]{{/hasMore}}{{/formParams}}{{/queryParams}}{{#queryParams}}{{^secondaryParam}}[{{/secondaryParam}} - "{{baseName}}": {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}} + "{{baseName}}": {{paramName}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{#hasMore}},{{/hasMore}}{{^hasMore}} ]{{/hasMore}}{{/queryParams}} let parameters = APIHelper.rejectNil(nillableParameters){{/bodyParam}} diff --git a/modules/swagger-codegen/src/main/resources/swift/model.mustache b/modules/swagger-codegen/src/main/resources/swift/model.mustache index 3c0a47c2987..96c4d2ff683 100644 --- a/modules/swagger-codegen/src/main/resources/swift/model.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/model.mustache @@ -21,15 +21,24 @@ public class {{classname}}: JSONEncodable { {{#vars}} {{#isEnum}} {{#description}}/** {{description}} */ - {{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} + {{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} {{/isEnum}} {{^isEnum}} {{#description}}/** {{description}} */ - {{/description}}public var {{name}}: {{{datatype}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} + {{/description}}public var {{name}}: {{{datatype}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} {{/isEnum}} {{/vars}} +{{^unwrapRequired}} public init() {} +{{/unwrapRequired}} +{{#unwrapRequired}} + public init({{#requiredVars}}{{^-first}}, {{/-first}}{{name}}: {{#isEnum}}{{datatypeWithEnum}}!{{/isEnum}}{{^isEnum}}{{datatype}}!{{/isEnum}}{{/requiredVars}}) { + {{#requiredVars}} + self.{{name}} = {{name}} + {{/requiredVars}} + } +{{/unwrapRequired}} // MARK: JSONEncodable func encodeToJSON() -> AnyObject { diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index 01c0be8c9a3..4160e59cc48 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -559,6 +559,97 @@ paths: description: Invalid username supplied '404': description: User not found + + /fake: + post: + tags: + - fake + summary: Fake endpoint for testing various parameters + description: Fake endpoint for testing various parameters + operationId: testEndpointParameters + produces: + - application/xml + - application/json + parameters: + - name: integer + type: integer + maximum: 100 + minimum: 10 + in: formData + description: None + - name: int32 + type: integer + format: int32 + maximum: 200 + minimum: 20 + in: formData + description: None + - name: int64 + type: integer + format: int64 + in: formData + description: None + - name: number + type: number + maximum: 543.2 + minimum: 32.1 + in: formData + description: None + required: true + - name: float + type: number + format: float + maximum: 987.6 + in: formData + description: None + - name: double + type: number + in: formData + format: double + maximum: 123.4 + minimum: 67.8 + required: true + description: None + - name: string + type: string + pattern: /[a-z]/i + in: formData + description: None + required: true + - name: byte + type: string + format: byte + in: formData + description: None + required: true + - name: binary + type: string + format: binary + in: formData + description: None + - name: date + type: string + format: date + in: formData + description: None + - name: dateTime + type: string + format: date-time + in: formData + description: None + - name: password + type: string + format: password + maxLength: 64 + minLength: 10 + in: formData + description: None + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + securityDefinitions: petstore_auth: type: oauth2 @@ -755,25 +846,39 @@ definitions: type: object required: - number + - byte + - date + - password properties: integer: type: integer + maximum: 100 + minimum: 10 int32: type: integer format: int32 + maximum: 200 + minimum: 20 int64: type: integer format: int64 number: + maximum: 543.2 + minimum: 32.1 type: number float: type: number format: float + maximum: 987.6 + minimum: 54.3 double: type: number format: double + maximum: 123.4 + minimum: 67.8 string: type: string + pattern: /[a-z]/i byte: type: string format: byte @@ -786,9 +891,14 @@ definitions: dateTime: type: string format: date-time + uuid: + type: string + format: uuid password: type: string format: password + maxLength: 64 + minLength: 10 externalDocs: description: Find out more about Swagger url: 'http://swagger.io' diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index 5890d48282a..910888030a1 100644 --- a/samples/client/petstore/go/go-petstore/README.md +++ b/samples/client/petstore/go/go-petstore/README.md @@ -7,7 +7,7 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-17T16:17:52.285+08:00 +- Build date: 2016-04-23T17:00:49.475-07:00 - Build package: class io.swagger.codegen.languages.GoClientCodegen ## Installation @@ -46,8 +46,8 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [ApiResponse](docs/ApiResponse.md) - [Category](docs/Category.md) + - [ModelApiResponse](docs/ModelApiResponse.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) - [Tag](docs/Tag.md) @@ -57,12 +57,6 @@ Class | Method | HTTP request | Description ## Documentation For Authorization -## api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ## petstore_auth - **Type**: OAuth @@ -72,6 +66,12 @@ Class | Method | HTTP request | Description - **write:pets**: modify pets in your account - **read:pets**: read your pets +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ## Author diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 9806ccdf38d..d4b53512c68 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -2,13 +2,18 @@ package swagger import ( "strings" + "github.com/go-resty/resty" + "fmt" + "reflect" + "bytes" + "path/filepath" ) -type ApiClient struct { +type APIClient struct { } -func (c *ApiClient) SelectHeaderContentType(contentTypes []string) string { +func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { if (len(contentTypes) == 0){ return "" } @@ -19,7 +24,7 @@ func (c *ApiClient) SelectHeaderContentType(contentTypes []string) string { return contentTypes[0] // use the first content type specified in 'consumes' } -func (c *ApiClient) SelectHeaderAccept(accepts []string) string { +func (c *APIClient) SelectHeaderAccept(accepts []string) string { if (len(accepts) == 0){ return "" } @@ -38,4 +43,81 @@ func contains(source []string, containvalue string) bool { } } return false -} \ No newline at end of file +} + + +func (c *APIClient) CallAPI(path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileName string, + fileBytes []byte) (*resty.Response, error) { + + //set debug flag + configuration := NewConfiguration() + resty.SetDebug(configuration.GetDebug()) + + request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) + + switch strings.ToUpper(method) { + case "GET": + response, err := request.Get(path) + return response, err + case "POST": + response, err := request.Post(path) + return response, err + case "PUT": + response, err := request.Put(path) + return response, err + case "PATCH": + response, err := request.Patch(path) + return response, err + case "DELETE": + response, err := request.Delete(path) + return response, err + } + + return nil, fmt.Errorf("invalid method %v", method) +} + +func (c *APIClient) ParameterToString(obj interface{}) string { + if reflect.TypeOf(obj).String() == "[]string" { + return strings.Join(obj.([]string), ",") + } else { + return obj.(string) + } +} + +func prepareRequest(postBody interface{}, + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileName string, + fileBytes []byte) *resty.Request { + + request := resty.R() + + request.SetBody(postBody) + + // add header parameter, if any + if len(headerParams) > 0 { + request.SetHeaders(headerParams) + } + + // add query parameter, if any + if len(queryParams) > 0 { + request.SetQueryParams(queryParams) + } + + // add form parameter, if any + if len(formParams) > 0 { + request.SetFormData(formParams) + } + + if len(fileBytes) > 0 && fileName != "" { + _, fileNm := filepath.Split(fileName) + request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) + } + return request +} diff --git a/samples/client/petstore/go/go-petstore/api_response.go b/samples/client/petstore/go/go-petstore/api_response.go index abb7971189d..2a34a8cf35a 100644 --- a/samples/client/petstore/go/go-petstore/api_response.go +++ b/samples/client/petstore/go/go-petstore/api_response.go @@ -1,14 +1,24 @@ package swagger import ( + "net/http" ) -type ApiResponse struct { - - Code int32 `json:"code,omitempty"` - - Type_ string `json:"type,omitempty"` - - Message string `json:"message,omitempty"` +type APIResponse struct { + *http.Response + + Message string `json:"message,omitempty"` } + +func NewAPIResponse(r *http.Response) *APIResponse { + response := &APIResponse{Response: r} + + return response +} + +func NewAPIResponseWithError(errorMessage string) *APIResponse { + response := &APIResponse{Message: errorMessage} + + return response +} \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/configuration.go b/samples/client/petstore/go/go-petstore/configuration.go index e8a00bccaf5..2a1b4096399 100644 --- a/samples/client/petstore/go/go-petstore/configuration.go +++ b/samples/client/petstore/go/go-petstore/configuration.go @@ -7,9 +7,9 @@ import ( type Configuration struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` - ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"` - ApiKey map[string] string `json:"apiKey,omitempty"` - Debug bool `json:"debug,omitempty"` + APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"` + APIKey map[string] string `json:"APIKey,omitempty"` + debug bool `json:"debug,omitempty"` DebugFile string `json:"debugFile,omitempty"` OAuthToken string `json:"oAuthToken,omitempty"` Timeout int `json:"timeout,omitempty"` @@ -19,17 +19,17 @@ type Configuration struct { AccessToken string `json:"accessToken,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` - ApiClient ApiClient `json:"apiClient,omitempty"` + APIClient APIClient `json:"APIClient,omitempty"` } func NewConfiguration() *Configuration { return &Configuration{ BasePath: "http://petstore.swagger.io/v2", UserName: "", - Debug: false, + debug: false, DefaultHeader: make(map[string]string), - ApiKey: make(map[string]string), - ApiKeyPrefix: make(map[string]string), + APIKey: make(map[string]string), + APIKeyPrefix: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", } } @@ -42,10 +42,18 @@ func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value } -func (c *Configuration) GetApiKeyWithPrefix(apiKeyIdentifier string) string { - if c.ApiKeyPrefix[apiKeyIdentifier] != ""{ - return c.ApiKeyPrefix[apiKeyIdentifier] + " " + c.ApiKey[apiKeyIdentifier] +func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { + if c.APIKeyPrefix[APIKeyIdentifier] != ""{ + return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] } - return c.ApiKey[apiKeyIdentifier] + return c.APIKey[APIKeyIdentifier] +} + +func (c *Configuration) SetDebug(enable bool){ + c.debug = enable +} + +func (c *Configuration) GetDebug() bool { + return c.debug } \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/docs/ModelApiResponse.md b/samples/client/petstore/go/go-petstore/docs/ModelApiResponse.md new file mode 100644 index 00000000000..f4af2146829 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/docs/ModelApiResponse.md @@ -0,0 +1,12 @@ +# ModelApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **int32** | | [optional] [default to null] +**Type_** | **string** | | [optional] [default to null] +**Message** | **string** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/go/go-petstore/docs/PetApi.md b/samples/client/petstore/go/go-petstore/docs/PetApi.md index 5dad1949b04..e96bdc1a15e 100644 --- a/samples/client/petstore/go/go-petstore/docs/PetApi.md +++ b/samples/client/petstore/go/go-petstore/docs/PetApi.md @@ -36,7 +36,7 @@ void (empty response body) [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: application/json, application/xml - **Accept**: application/xml, application/json @@ -66,7 +66,7 @@ void (empty response body) [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -95,7 +95,7 @@ Name | Type | Description | Notes [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -124,7 +124,7 @@ Name | Type | Description | Notes [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -153,7 +153,7 @@ Name | Type | Description | Notes [api_key](../README.md#api_key) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -182,7 +182,7 @@ void (empty response body) [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: application/json, application/xml - **Accept**: application/xml, application/json @@ -213,7 +213,7 @@ void (empty response body) [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded - **Accept**: application/xml, application/json @@ -221,7 +221,7 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **UploadFile** -> ApiResponse UploadFile($petId, $additionalMetadata, $file) +> ModelApiResponse UploadFile($petId, $additionalMetadata, $file) uploads an image @@ -238,13 +238,13 @@ Name | Type | Description | Notes ### Return type -[**ApiResponse**](ApiResponse.md) +[**ModelApiResponse**](ApiResponse.md) ### Authorization [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: multipart/form-data - **Accept**: application/json diff --git a/samples/client/petstore/go/go-petstore/docs/StoreApi.md b/samples/client/petstore/go/go-petstore/docs/StoreApi.md index 11939c1edba..1ee858d2e30 100644 --- a/samples/client/petstore/go/go-petstore/docs/StoreApi.md +++ b/samples/client/petstore/go/go-petstore/docs/StoreApi.md @@ -32,7 +32,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -58,7 +58,7 @@ This endpoint does not need any parameter. [api_key](../README.md#api_key) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json @@ -87,7 +87,7 @@ Name | Type | Description | Notes No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -116,7 +116,7 @@ Name | Type | Description | Notes No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json diff --git a/samples/client/petstore/go/go-petstore/docs/UserApi.md b/samples/client/petstore/go/go-petstore/docs/UserApi.md index 79ee5175bbd..4950105ca86 100644 --- a/samples/client/petstore/go/go-petstore/docs/UserApi.md +++ b/samples/client/petstore/go/go-petstore/docs/UserApi.md @@ -36,7 +36,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -65,7 +65,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -94,7 +94,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -123,7 +123,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -152,7 +152,7 @@ Name | Type | Description | Notes No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -182,7 +182,7 @@ Name | Type | Description | Notes No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -208,7 +208,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -238,7 +238,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json diff --git a/samples/client/petstore/go/go-petstore/model_api_response.go b/samples/client/petstore/go/go-petstore/model_api_response.go new file mode 100644 index 00000000000..0905f55cf01 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/model_api_response.go @@ -0,0 +1,14 @@ +package swagger + +import ( +) + + +type ModelApiResponse struct { + + Code int32 `json:"code,omitempty"` + + Type_ string `json:"type,omitempty"` + + Message string `json:"message,omitempty"` +} diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 461df7449f3..423e8a795a7 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -5,8 +5,8 @@ import ( "fmt" "encoding/json" "errors" - "github.com/dghubble/sling" "os" + "io/ioutil" ) type PetApi struct { @@ -35,89 +35,70 @@ func NewPetApiWithBasePath(basePath string) *PetApi{ * @param body Pet object that needs to be added to the store * @return void */ -func (a PetApi) AddPet (body Pet) (error) { - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling PetApi->AddPet") - } - _sling := sling.New().Post(a.Configuration.BasePath) +func (a PetApi) AddPet (body Pet) (APIResponse, error) { - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/pet" - // create path and map variables - path := "/v2/pet" - - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "application/json", - "application/xml", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - -// body params - _sling = _sling.BodyJSON(body) - - - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->AddPet") } - return err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "application/json", + "application/xml", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Deletes a pet @@ -126,88 +107,69 @@ func (a PetApi) AddPet (body Pet) (error) { * @param apiKey * @return void */ -func (a PetApi) DeletePet (petId int64, apiKey string) (error) { - // verify the required parameter 'petId' is set - if &petId == nil { - return errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") - } - _sling := sling.New().Delete(a.Configuration.BasePath) +func (a PetApi) DeletePet (petId int64, apiKey string) (APIResponse, error) { - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } + var httpMethod = "Delete" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - // create path and map variables - path := "/v2/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - // header params "api_key" - _sling = _sling.Set("api_key", apiKey) - - - - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'petId' is set + if &petId == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") } - return err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + // header params "api_key" + headerParams["api_key"] = apiKey + + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Finds Pets by status @@ -215,89 +177,69 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { * @param status Status values that need to be considered for filter * @return []Pet */ -func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { - // verify the required parameter 'status' is set - if &status == nil { - return *new([]Pet), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") - } - _sling := sling.New().Get(a.Configuration.BasePath) +func (a PetApi) FindPetsByStatus (status []string) ([]Pet, APIResponse, error) { - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/pet/findByStatus" - // create path and map variables - path := "/v2/pet/findByStatus" + // verify the required parameter 'status' is set + if &status == nil { + return *new([]Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") + } - _sling = _sling.Path(path) + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - type QueryParams struct { - Status []string `url:"status,omitempty"` -} - _sling = _sling.QueryStruct(&QueryParams{ Status: status }) + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + queryParams["status"] = a.Configuration.APIClient.ParameterToString(status) - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new([]Pet) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } - return *successPayload, err + err = json.Unmarshal(httpResponse.Body(), &successPayload) + + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Finds Pets by tags @@ -305,89 +247,69 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { * @param tags Tags to filter by * @return []Pet */ -func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { - // verify the required parameter 'tags' is set - if &tags == nil { - return *new([]Pet), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") - } - _sling := sling.New().Get(a.Configuration.BasePath) +func (a PetApi) FindPetsByTags (tags []string) ([]Pet, APIResponse, error) { - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/pet/findByTags" - // create path and map variables - path := "/v2/pet/findByTags" + // verify the required parameter 'tags' is set + if &tags == nil { + return *new([]Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") + } - _sling = _sling.Path(path) + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - type QueryParams struct { - Tags []string `url:"tags,omitempty"` -} - _sling = _sling.QueryStruct(&QueryParams{ Tags: tags }) + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + queryParams["tags"] = a.Configuration.APIClient.ParameterToString(tags) - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new([]Pet) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } - return *successPayload, err + err = json.Unmarshal(httpResponse.Body(), &successPayload) + + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Find pet by ID @@ -395,85 +317,68 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { * @param petId ID of pet to return * @return Pet */ -func (a PetApi) GetPetById (petId int64) (Pet, error) { - // verify the required parameter 'petId' is set - if &petId == nil { - return *new(Pet), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") - } - _sling := sling.New().Get(a.Configuration.BasePath) +func (a PetApi) GetPetById (petId int64) (Pet, APIResponse, error) { - // authentication (api_key) required - - // set key with prefix in header - _sling.Set("api_key", a.Configuration.GetApiKeyWithPrefix("api_key")) - + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - // create path and map variables - path := "/v2/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + // verify the required parameter 'petId' is set + if &petId == nil { + return *new(Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") + } - _sling = _sling.Path(path) + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - + // authentication (api_key) required + + // set key with prefix in header + headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key") + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new(Pet) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } - return *successPayload, err + err = json.Unmarshal(httpResponse.Body(), &successPayload) + + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Update an existing pet @@ -481,89 +386,70 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { * @param body Pet object that needs to be added to the store * @return void */ -func (a PetApi) UpdatePet (body Pet) (error) { - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") - } - _sling := sling.New().Put(a.Configuration.BasePath) +func (a PetApi) UpdatePet (body Pet) (APIResponse, error) { - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } + var httpMethod = "Put" + // create path and map variables + path := a.Configuration.BasePath + "/pet" - // create path and map variables - path := "/v2/pet" - - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "application/json", - "application/xml", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - -// body params - _sling = _sling.BodyJSON(body) - - - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") } - return err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "application/json", + "application/xml", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Updates a pet in the store with form data @@ -573,92 +459,70 @@ func (a PetApi) UpdatePet (body Pet) (error) { * @param status Updated status of the pet * @return void */ -func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (error) { - // verify the required parameter 'petId' is set - if &petId == nil { - return errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") - } - _sling := sling.New().Post(a.Configuration.BasePath) +func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (APIResponse, error) { - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - // create path and map variables - path := "/v2/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "application/x-www-form-urlencoded", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - - type FormParams struct { - Name string `url:"name,omitempty"` - Status string `url:"status,omitempty"` - } - _sling = _sling.BodyForm(&FormParams{ Name: name,Status: status }) - - - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'petId' is set + if &petId == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") } - return err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "application/x-www-form-urlencoded", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + formParams["name"] = name + formParams["status"] = status + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } /** * uploads an image @@ -666,91 +530,73 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload - * @return ApiResponse + * @return ModelApiResponse */ -func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ApiResponse, error) { - // verify the required parameter 'petId' is set - if &petId == nil { - return *new(ApiResponse), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") - } - _sling := sling.New().Post(a.Configuration.BasePath) +func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ModelApiResponse, APIResponse, error) { - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}/uploadImage" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - // create path and map variables - path := "/v2/pet/{petId}/uploadImage" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "multipart/form-data", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - - type FormParams struct { - AdditionalMetadata string `url:"additionalMetadata,omitempty"` - File *os.File `url:"file,omitempty"` - } - _sling = _sling.BodyForm(&FormParams{ AdditionalMetadata: additionalMetadata,File: file }) - - var successPayload = new(ApiResponse) - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'petId' is set + if &petId == nil { + return *new(ModelApiResponse), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") } - return *successPayload, err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "multipart/form-data", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + formParams["additionalMetadata"] = additionalMetadata + fbs, _ := ioutil.ReadAll(file) + fileBytes = fbs + fileName = file.Name() + + var successPayload = new(ModelApiResponse) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + + err = json.Unmarshal(httpResponse.Body(), &successPayload) + + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index 2fa59c1efd1..a8b48f63b39 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -5,7 +5,6 @@ import ( "fmt" "encoding/json" "errors" - "github.com/dghubble/sling" ) type StoreApi struct { @@ -34,159 +33,123 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{ * @param orderId ID of the order that needs to be deleted * @return void */ -func (a StoreApi) DeleteOrder (orderId string) (error) { - // verify the required parameter 'orderId' is set - if &orderId == nil { - return errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") - } - _sling := sling.New().Delete(a.Configuration.BasePath) +func (a StoreApi) DeleteOrder (orderId string) (APIResponse, error) { - - // create path and map variables - path := "/v2/store/order/{orderId}" - path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + var httpMethod = "Delete" + // create path and map variables + path := a.Configuration.BasePath + "/store/order/{orderId}" + path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - - - - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'orderId' is set + if &orderId == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") } - return err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Returns pet inventories by status * Returns a map of status codes to quantities * @return map[string]int32 */ -func (a StoreApi) GetInventory () (map[string]int32, error) { - _sling := sling.New().Get(a.Configuration.BasePath) +func (a StoreApi) GetInventory () (map[string]int32, APIResponse, error) { - // authentication (api_key) required - - // set key with prefix in header - _sling.Set("api_key", a.Configuration.GetApiKeyWithPrefix("api_key")) - + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/store/inventory" - // create path and map variables - path := "/v2/store/inventory" - _sling = _sling.Path(path) + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - + // authentication (api_key) required + + // set key with prefix in header + headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key") + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new(map[string]int32) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } - return *successPayload, err + err = json.Unmarshal(httpResponse.Body(), &successPayload) + + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Find purchase order by ID @@ -194,80 +157,63 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { * @param orderId ID of pet that needs to be fetched * @return Order */ -func (a StoreApi) GetOrderById (orderId int64) (Order, error) { - // verify the required parameter 'orderId' is set - if &orderId == nil { - return *new(Order), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") - } - _sling := sling.New().Get(a.Configuration.BasePath) +func (a StoreApi) GetOrderById (orderId int64) (Order, APIResponse, error) { - - // create path and map variables - path := "/v2/store/order/{orderId}" - path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/store/order/{orderId}" + path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) - _sling = _sling.Path(path) + // verify the required parameter 'orderId' is set + if &orderId == nil { + return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new(Order) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } - return *successPayload, err + err = json.Unmarshal(httpResponse.Body(), &successPayload) + + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Place an order for a pet @@ -275,79 +221,62 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { * @param body order placed for purchasing the pet * @return Order */ -func (a StoreApi) PlaceOrder (body Order) (Order, error) { - // verify the required parameter 'body' is set - if &body == nil { - return *new(Order), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") - } - _sling := sling.New().Post(a.Configuration.BasePath) +func (a StoreApi) PlaceOrder (body Order) (Order, APIResponse, error) { - - // create path and map variables - path := "/v2/store/order" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/store/order" - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - -// body params - _sling = _sling.BodyJSON(body) - - var successPayload = new(Order) - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'body' is set + if &body == nil { + return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") } - return *successPayload, err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + var successPayload = new(Order) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + + err = json.Unmarshal(httpResponse.Body(), &successPayload) + + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index b6639d9e65f..228c8d3f9bd 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -5,7 +5,6 @@ import ( "fmt" "encoding/json" "errors" - "github.com/dghubble/sling" ) type UserApi struct { @@ -34,81 +33,62 @@ func NewUserApiWithBasePath(basePath string) *UserApi{ * @param body Created user object * @return void */ -func (a UserApi) CreateUser (body User) (error) { - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") - } - _sling := sling.New().Post(a.Configuration.BasePath) +func (a UserApi) CreateUser (body User) (APIResponse, error) { - - // create path and map variables - path := "/v2/user" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/user" - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - -// body params - _sling = _sling.BodyJSON(body) - - - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") } - return err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Creates list of users with given input array @@ -116,81 +96,62 @@ func (a UserApi) CreateUser (body User) (error) { * @param body List of user object * @return void */ -func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") - } - _sling := sling.New().Post(a.Configuration.BasePath) +func (a UserApi) CreateUsersWithArrayInput (body []User) (APIResponse, error) { - - // create path and map variables - path := "/v2/user/createWithArray" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/user/createWithArray" - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - -// body params - _sling = _sling.BodyJSON(body) - - - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") } - return err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Creates list of users with given input array @@ -198,81 +159,62 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { * @param body List of user object * @return void */ -func (a UserApi) CreateUsersWithListInput (body []User) (error) { - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") - } - _sling := sling.New().Post(a.Configuration.BasePath) +func (a UserApi) CreateUsersWithListInput (body []User) (APIResponse, error) { - - // create path and map variables - path := "/v2/user/createWithList" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/user/createWithList" - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - -// body params - _sling = _sling.BodyJSON(body) - - - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") } - return err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Delete user @@ -280,80 +222,61 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { * @param username The name that needs to be deleted * @return void */ -func (a UserApi) DeleteUser (username string) (error) { - // verify the required parameter 'username' is set - if &username == nil { - return errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") - } - _sling := sling.New().Delete(a.Configuration.BasePath) +func (a UserApi) DeleteUser (username string) (APIResponse, error) { - - // create path and map variables - path := "/v2/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + var httpMethod = "Delete" + // create path and map variables + path := a.Configuration.BasePath + "/user/{username}" + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - - - - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'username' is set + if &username == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") } - return err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Get user by user name @@ -361,80 +284,63 @@ func (a UserApi) DeleteUser (username string) (error) { * @param username The name that needs to be fetched. Use user1 for testing. * @return User */ -func (a UserApi) GetUserByName (username string) (User, error) { - // verify the required parameter 'username' is set - if &username == nil { - return *new(User), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") - } - _sling := sling.New().Get(a.Configuration.BasePath) +func (a UserApi) GetUserByName (username string) (User, APIResponse, error) { - - // create path and map variables - path := "/v2/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/user/{username}" + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) - _sling = _sling.Path(path) + // verify the required parameter 'username' is set + if &username == nil { + return *new(User), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new(User) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } - return *successPayload, err + err = json.Unmarshal(httpResponse.Body(), &successPayload) + + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Logs user into the system @@ -443,163 +349,124 @@ func (a UserApi) GetUserByName (username string) (User, error) { * @param password The password for login in clear text * @return string */ -func (a UserApi) LoginUser (username string, password string) (string, error) { - // verify the required parameter 'username' is set - if &username == nil { - return *new(string), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") - } - // verify the required parameter 'password' is set - if &password == nil { - return *new(string), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") - } - _sling := sling.New().Get(a.Configuration.BasePath) +func (a UserApi) LoginUser (username string, password string) (string, APIResponse, error) { - - // create path and map variables - path := "/v2/user/login" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/user/login" - _sling = _sling.Path(path) + // verify the required parameter 'username' is set + if &username == nil { + return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") + } + // verify the required parameter 'password' is set + if &password == nil { + return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - type QueryParams struct { - Username string `url:"username,omitempty"` -Password string `url:"password,omitempty"` -} - _sling = _sling.QueryStruct(&QueryParams{ Username: username,Password: password }) + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + queryParams["username"] = a.Configuration.APIClient.ParameterToString(username) + queryParams["password"] = a.Configuration.APIClient.ParameterToString(password) - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new(string) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } - return *successPayload, err + err = json.Unmarshal(httpResponse.Body(), &successPayload) + + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Logs out current logged in user session * * @return void */ -func (a UserApi) LogoutUser () (error) { - _sling := sling.New().Get(a.Configuration.BasePath) +func (a UserApi) LogoutUser () (APIResponse, error) { - - // create path and map variables - path := "/v2/user/logout" - - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/user/logout" + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept } - return err + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Updated user @@ -608,84 +475,65 @@ func (a UserApi) LogoutUser () (error) { * @param body Updated user object * @return void */ -func (a UserApi) UpdateUser (username string, body User) (error) { - // verify the required parameter 'username' is set - if &username == nil { - return errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") - } - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") - } - _sling := sling.New().Put(a.Configuration.BasePath) +func (a UserApi) UpdateUser (username string, body User) (APIResponse, error) { - - // create path and map variables - path := "/v2/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + var httpMethod = "Put" + // create path and map variables + path := a.Configuration.BasePath + "/user/{username}" + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } - -// body params - _sling = _sling.BodyJSON(body) - - - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + // verify the required parameter 'username' is set + if &username == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") + } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") } - return err + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + + + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } + + return *NewAPIResponse(httpResponse.RawResponse), err } diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go index 8ac7dc1a77a..5b18e3a7675 100644 --- a/samples/client/petstore/go/pet_api_test.go +++ b/samples/client/petstore/go/pet_api_test.go @@ -4,6 +4,7 @@ import ( sw "./go-petstore" "github.com/stretchr/testify/assert" "testing" + "os" ) func TestAddPet(t *testing.T) { @@ -11,19 +12,36 @@ func TestAddPet(t *testing.T) { newPet := (sw.Pet{Id: 12830, Name: "gopher", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"}) - err := s.AddPet(newPet) + apiResponse, err := s.AddPet(newPet) if err != nil { t.Errorf("Error while adding pet") t.Log(err) } + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) + } +} + +func TestFindPetsByStatusWithMissingParam(t *testing.T) { + s := sw.NewPetApi() + + _, apiResponse, err := s.FindPetsByStatus(nil) + + if err != nil { + t.Errorf("Error while testing TestFindPetsByStatusWithMissingParam") + t.Log(err) + } + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse) + } } func TestGetPetById(t *testing.T) { assert := assert.New(t) s := sw.NewPetApi() - resp, err := s.GetPetById(12830) + resp, apiResponse, err := s.GetPetById(12830) if err != nil { t.Errorf("Error while getting pet by id") t.Log(err) @@ -34,14 +52,83 @@ func TestGetPetById(t *testing.T) { //t.Log(resp) } + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) + } +} + +func TestGetPetByIdWithInvalidID(t *testing.T) { + s := sw.NewPetApi() + resp, apiResponse, err := s.GetPetById(999999999) + if err != nil { + t.Errorf("Error while getting pet by invalid id") + t.Log(err) + t.Log(apiResponse) + } else { + t.Log(resp) + } + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) + } } func TestUpdatePetWithForm(t *testing.T) { s := sw.NewPetApi() - err := s.UpdatePetWithForm(12830, "golang", "available") + apiResponse, err := s.UpdatePetWithForm(12830, "golang", "available") if err != nil { t.Errorf("Error while updating pet by id") t.Log(err) + t.Log(apiResponse) + } + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) + } +} + +func TestFindPetsByStatus(t *testing.T) { + s := sw.NewPetApi() + resp, apiResponse, err := s.FindPetsByStatus([]string {"pending"}) + if err != nil { + t.Errorf("Error while getting pet by id") + t.Log(err) + t.Log(apiResponse) + } else { + t.Log(apiResponse) + if len(resp) == 0 { + t.Errorf("Error no pets returned") + } + + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) + } + } +} + +func TestUploadFile(t *testing.T) { + s := sw.NewPetApi() + file, _ := os.Open("../python/testfiles/foo.png") + + _, apiResponse, err := s.UploadFile(12830, "golang", file) + + if err != nil { + t.Errorf("Error while uploading file") + t.Log(err) + } + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) + } +} + +func TestDeletePet(t *testing.T) { + s := sw.NewPetApi() + apiResponse, err := s.DeletePet(12830, "") + + if err != nil { + t.Errorf("Error while deleting pet by id") + t.Log(err) + } + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } diff --git a/samples/client/petstore/go/test.go b/samples/client/petstore/go/test.go index f73d4e338ca..6a50c9bbc8e 100644 --- a/samples/client/petstore/go/test.go +++ b/samples/client/petstore/go/test.go @@ -22,7 +22,9 @@ func main() { s.UpdatePetWithForm(12830, "golang", "available") // test GET - resp, err := s.GetPetById(12830) - fmt.Println("GetPetById: ", resp, err) + resp, err, apiResponse := s.GetPetById(12830) + fmt.Println("GetPetById: ", resp, err, apiResponse) + err2, apiResponse2 := s.DeletePet(12830, "") + fmt.Println("DeletePet: ", err2, apiResponse2) } diff --git a/samples/client/petstore/groovy/build.gradle b/samples/client/petstore/groovy/build.gradle new file mode 100644 index 00000000000..238f5e6e09f --- /dev/null +++ b/samples/client/petstore/groovy/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'groovy' +apply plugin: 'idea' +apply plugin: 'eclipse' + +def artifactory = 'buildserver.supportspace.com' +group = 'com.supportspace' +archivesBaseName = 'swagger-gen-groovy' +version = '0.1' + +buildscript { + repositories { + maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins' } + } + dependencies { + classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.16') + } +} + +repositories { + mavenCentral() + mavenLocal() + mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone']) + maven { url "http://$artifactory:8080/artifactory/repo" } +} + +ext { + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" +} + +dependencies { + compile 'org.codehaus.groovy:groovy-all:2.4.6' + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" + compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1' +} + +task wrapper(type: Wrapper) { gradleVersion = '1.6' } diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy new file mode 100644 index 00000000000..877ed4e4647 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy @@ -0,0 +1,50 @@ +package io.swagger.api; + +import groovyx.net.http.HTTPBuilder +import groovyx.net.http.Method + +import static groovyx.net.http.ContentType.JSON +import static java.net.URI.create; + +class ApiUtils { + + def invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, method, container, type) { + def (url, uriPath) = buildUrlAndUriPath(basePath, versionPath, resourcePath) + println "url=$url uriPath=$uriPath" + def http = new HTTPBuilder(url) + http.request( Method.valueOf(method), JSON ) { + uri.path = uriPath + uri.query = queryParams + response.success = { resp, json -> + if (type != null) { + onSuccess(parse(json, container, type)) + } + } + response.failure = { resp -> + onFailure(resp.status, resp.statusLine.reasonPhrase) + } + } + } + + + def buildUrlAndUriPath(basePath, versionPath, resourcePath) { + // HTTPBuilder expects to get as its constructor parameter an URL, + // without any other additions like path, therefore we need to cut the path + // from the basePath as it is represented by swagger APIs + // we use java.net.URI to manipulate the basePath + // then the uriPath will hold the rest of the path + URI baseUri = create(basePath) + def pathOnly = baseUri.getPath() + [basePath-pathOnly, pathOnly+versionPath+resourcePath] + } + + + def parse(object, container, clazz) { + if (container == "List") { + return object.collect {parse(it, "", clazz)} + } else { + return clazz.newInstance(object) + } + } + +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy new file mode 100644 index 00000000000..5aae4924239 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy @@ -0,0 +1,184 @@ +package io.swagger.api; + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils + +import io.swagger.model.Pet +import java.io.File +import io.swagger.model.ModelApiResponse + +import java.util.*; + +@Mixin(ApiUtils) +class PetApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + def addPet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deletePet ( Long petId, String apiKey, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + headerParams.put("apiKey", apiKey) + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def findPetsByStatus ( List status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/findByStatus" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (status == null) { + throw new RuntimeException("missing required params status") + } + + if (!"null".equals(String.valueOf(status))) + queryParams.put("status", String.valueOf(status)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "array", + Pet.class ) + + } + def findPetsByTags ( List tags, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/findByTags" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (tags == null) { + throw new RuntimeException("missing required params tags") + } + + if (!"null".equals(String.valueOf(tags))) + queryParams.put("tags", String.valueOf(tags)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "array", + Pet.class ) + + } + def getPetById ( Long petId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Pet.class ) + + } + def updatePet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } + def updatePetWithForm ( Long petId, String name, String status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def uploadFile ( Long petId, String additionalMetadata, File file, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}/uploadImage" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + ModelApiResponse.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy new file mode 100644 index 00000000000..0cf30090200 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy @@ -0,0 +1,93 @@ +package io.swagger.api; + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils + +import io.swagger.model.Order + +import java.util.*; + +@Mixin(ApiUtils) +class StoreApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + def deleteOrder ( String orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/order/{orderId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (orderId == null) { + throw new RuntimeException("missing required params orderId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getInventory ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/inventory" + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "map", + Map.class ) + + } + def getOrderById ( Long orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/order/{orderId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (orderId == null) { + throw new RuntimeException("missing required params orderId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Order.class ) + + } + def placeOrder ( Order body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/order" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + Order.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy new file mode 100644 index 00000000000..5a8a4b2eea8 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy @@ -0,0 +1,185 @@ +package io.swagger.api; + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils + +import io.swagger.model.User + +import java.util.*; + +@Mixin(ApiUtils) +class UserApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + def createUser ( User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithArrayInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/createWithArray" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithListInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/createWithList" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deleteUser ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/{username}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getUserByName ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/{username}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + User.class ) + + } + def loginUser ( String username, String password, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/login" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + // verify required params are set + if (password == null) { + throw new RuntimeException("missing required params password") + } + + if (!"null".equals(String.valueOf(username))) + queryParams.put("username", String.valueOf(username)) +if (!"null".equals(String.valueOf(password))) + queryParams.put("password", String.valueOf(password)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + String.class ) + + } + def logoutUser ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/logout" + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + null ) + + } + def updateUser ( String username, User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/{username}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy new file mode 100644 index 00000000000..29509e64e54 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Category { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy new file mode 100644 index 00000000000..505752a6dc3 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy @@ -0,0 +1,18 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class ModelApiResponse { + + Integer code = null + + String type = null + + String message = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy new file mode 100644 index 00000000000..815c72846d9 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy @@ -0,0 +1,27 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; +@Canonical +class Order { + + Long id = null + + Long petId = null + + Integer quantity = null + + Date shipDate = null + + /* Order Status */ + String status = null + + Boolean complete = false + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy new file mode 100644 index 00000000000..667ce9430f4 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy @@ -0,0 +1,30 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.ArrayList; +import java.util.List; +@Canonical +class Pet { + + Long id = null + + Category category = null + + String name = null + + List photoUrls = new ArrayList() + + List tags = new ArrayList() + + /* pet status in the store */ + String status = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy new file mode 100644 index 00000000000..5c30c04a5ff --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Tag { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy new file mode 100644 index 00000000000..6889661e9e5 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy @@ -0,0 +1,29 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class User { + + Long id = null + + String username = null + + String firstName = null + + String lastName = null + + String email = null + + String password = null + + String phone = null + + /* User Status */ + Integer userStatus = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy new file mode 100644 index 00000000000..877ed4e4647 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy @@ -0,0 +1,50 @@ +package io.swagger.api; + +import groovyx.net.http.HTTPBuilder +import groovyx.net.http.Method + +import static groovyx.net.http.ContentType.JSON +import static java.net.URI.create; + +class ApiUtils { + + def invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, method, container, type) { + def (url, uriPath) = buildUrlAndUriPath(basePath, versionPath, resourcePath) + println "url=$url uriPath=$uriPath" + def http = new HTTPBuilder(url) + http.request( Method.valueOf(method), JSON ) { + uri.path = uriPath + uri.query = queryParams + response.success = { resp, json -> + if (type != null) { + onSuccess(parse(json, container, type)) + } + } + response.failure = { resp -> + onFailure(resp.status, resp.statusLine.reasonPhrase) + } + } + } + + + def buildUrlAndUriPath(basePath, versionPath, resourcePath) { + // HTTPBuilder expects to get as its constructor parameter an URL, + // without any other additions like path, therefore we need to cut the path + // from the basePath as it is represented by swagger APIs + // we use java.net.URI to manipulate the basePath + // then the uriPath will hold the rest of the path + URI baseUri = create(basePath) + def pathOnly = baseUri.getPath() + [basePath-pathOnly, pathOnly+versionPath+resourcePath] + } + + + def parse(object, container, clazz) { + if (container == "List") { + return object.collect {parse(it, "", clazz)} + } else { + return clazz.newInstance(object) + } + } + +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy new file mode 100644 index 00000000000..a8b0bebeedc --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy @@ -0,0 +1,218 @@ +package io.swagger.api; + + + + + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils +//------------- + +import io.swagger.model.Pet +import java.io.File +import io.swagger.model.ModelApiResponse + +import java.util.*; + +@Mixin(ApiUtils) +class PetApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + + def addPet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deletePet ( Long petId, String apiKey, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + headerParams.put("apiKey", apiKey) + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def findPetsByStatus ( List status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/findByStatus" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + if(!"null".equals(String.valueOf(status))) + queryParams.put("status", String.valueOf(status)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "List", + Pet.class ) + + } + def findPetsByTags ( List tags, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/findByTags" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + if(!"null".equals(String.valueOf(tags))) + queryParams.put("tags", String.valueOf(tags)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "List", + Pet.class ) + + } + def getPetById ( Long petId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Pet.class ) + + } + def updatePet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } + def updatePetWithForm ( Long petId, String name, String status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def uploadFile ( Long petId, String additionalMetadata, File file, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}/uploadImage" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + ModelApiResponse.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy new file mode 100644 index 00000000000..681000fbcdb --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy @@ -0,0 +1,104 @@ +package io.swagger.api; + + + + + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils +//------------- + +import java.util.Map +import io.swagger.model.Order + +import java.util.*; + +@Mixin(ApiUtils) +class StoreApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + + def deleteOrder ( String orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/order/{orderId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getInventory ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/inventory" + + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "Map", + Map.class ) + + } + def getOrderById ( Long orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/order/{orderId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Order.class ) + + } + def placeOrder ( Order body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/order" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + Order.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy new file mode 100644 index 00000000000..033057a08eb --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy @@ -0,0 +1,200 @@ +package io.swagger.api; + + + + + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils +//------------- + +import io.swagger.model.User +import java.util.List + +import java.util.*; + +@Mixin(ApiUtils) +class UserApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + + def createUser ( User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithArrayInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/createWithArray" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithListInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/createWithList" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deleteUser ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{username}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getUserByName ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{username}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + User.class ) + + } + def loginUser ( String username, String password, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/login" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + if(!"null".equals(String.valueOf(username))) + queryParams.put("username", String.valueOf(username)) +if(!"null".equals(String.valueOf(password))) + queryParams.put("password", String.valueOf(password)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + String.class ) + + } + def logoutUser ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/logout" + + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + null ) + + } + def updateUser ( String username, User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{username}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy new file mode 100644 index 00000000000..29509e64e54 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Category { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy new file mode 100644 index 00000000000..505752a6dc3 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy @@ -0,0 +1,18 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class ModelApiResponse { + + Integer code = null + + String type = null + + String message = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy new file mode 100644 index 00000000000..815c72846d9 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy @@ -0,0 +1,27 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; +@Canonical +class Order { + + Long id = null + + Long petId = null + + Integer quantity = null + + Date shipDate = null + + /* Order Status */ + String status = null + + Boolean complete = false + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy new file mode 100644 index 00000000000..667ce9430f4 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy @@ -0,0 +1,30 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.ArrayList; +import java.util.List; +@Canonical +class Pet { + + Long id = null + + Category category = null + + String name = null + + List photoUrls = new ArrayList() + + List tags = new ArrayList() + + /* pet status in the store */ + String status = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy new file mode 100644 index 00000000000..5c30c04a5ff --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Tag { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy new file mode 100644 index 00000000000..6889661e9e5 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy @@ -0,0 +1,29 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class User { + + Long id = null + + String username = null + + String firstName = null + + String lastName = null + + String email = null + + String password = null + + String phone = null + + /* User Status */ + Integer userStatus = null + + +} + diff --git a/samples/client/petstore/java/default/build.gradle b/samples/client/petstore/java/default/build.gradle index bfba070e070..33ceee9bb95 100644 --- a/samples/client/petstore/java/default/build.gradle +++ b/samples/client/petstore/java/default/build.gradle @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - swagger_annotations_version = "1.5.0" - jackson_version = "2.4.2" - jersey_version = "1.18" - jodatime_version = "2.3" + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" + jersey_version = "1.19.1" + jodatime_version = "2.9.3" junit_version = "4.12" } diff --git a/samples/client/petstore/java/default/docs/Name.md b/samples/client/petstore/java/default/docs/Name.md index a1adac1dd39..5390a15e9cd 100644 --- a/samples/client/petstore/java/default/docs/Name.md +++ b/samples/client/petstore/java/default/docs/Name.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | **snakeCase** | **Integer** | | [optional] +**property** | **String** | | [optional] diff --git a/samples/client/petstore/java/default/pom.xml b/samples/client/petstore/java/default/pom.xml index 803c7eab63a..2ea4060bc3a 100644 --- a/samples/client/petstore/java/default/pom.xml +++ b/samples/client/petstore/java/default/pom.xml @@ -172,9 +172,9 @@ UTF-8 1.5.8 - 1.18 - 2.4.2 - 2.3 + 1.19.1 + 2.7.0 + 2.9.3 1.0.0 4.12 diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index 584c85aaae4..c4ff05ec24f 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -8,8 +8,8 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java index 6446b547742..e93e3c3ee72 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java @@ -17,6 +17,7 @@ public class Name { private Integer name = null; private Integer snakeCase = null; + private String property = null; /** @@ -43,6 +44,23 @@ public class Name { } + /** + **/ + public Name property(String property) { + this.property = property; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("property") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -53,12 +71,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(this.name, name.name) && - Objects.equals(this.snakeCase, name.snakeCase); + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -68,6 +87,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/feign/build.gradle b/samples/client/petstore/java/feign/build.gradle index 656d38a57eb..d1f56b19208 100644 --- a/samples/client/petstore/java/feign/build.gradle +++ b/samples/client/petstore/java/feign/build.gradle @@ -94,11 +94,12 @@ if(hasProperty('target') && target == 'android') { } ext { - swagger_annotations_version = "1.5.0" - jackson_version = "2.6.3" - feign_version = "8.1.1" - jodatime_version = "2.5" + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" + feign_version = "8.16.0" + jodatime_version = "2.9.3" junit_version = "4.12" + oltu_version = "1.0.1" } dependencies { @@ -111,6 +112,7 @@ dependencies { compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" compile "joda-time:joda-time:$jodatime_version" + compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" compile "com.brsanthu:migbase64:2.2" testCompile "junit:junit:$junit_version" } diff --git a/samples/client/petstore/java/feign/pom.xml b/samples/client/petstore/java/feign/pom.xml index d7ad6ee49b9..164399be4a6 100644 --- a/samples/client/petstore/java/feign/pom.xml +++ b/samples/client/petstore/java/feign/pom.xml @@ -110,7 +110,7 @@ io.swagger swagger-annotations - ${swagger-annotations-version} + ${swagger-core-version} @@ -179,12 +179,12 @@ - 1.5.0 - 8.1.1 - 2.6.3 - 2.5 + 1.5.8 + 8.16.0 + 2.7.0 + 2.9.3 4.12 1.0.0 - 1.0.0 + 1.0.1 diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java index 043861f4e53..5d534251519 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java @@ -14,7 +14,7 @@ import feign.codec.EncodeException; import feign.codec.Encoder; import feign.RequestTemplate; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class FormAwareEncoder implements Encoder { public static final String UTF_8 = "utf-8"; private static final String LINE_FEED = "\r\n"; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java index 6439885ed11..0a07276e65b 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java index e2e1ad0bee6..e1a0e57b005 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java @@ -3,8 +3,8 @@ package io.swagger.client.api; import io.swagger.client.ApiClient; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; @@ -12,7 +12,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:32.462+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public interface PetApi extends ApiClient.Api { diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java index 45c9610c5c0..6b124765369 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public interface StoreApi extends ApiClient.Api { diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java index ae731977c6b..281cf2df46a 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public interface UserApi extends ApiClient.Api { diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java index 8e3eb2af935..6b79f42855b 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java index 3d79c411824..09e48e27ad5 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Cat extends Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java index 66f4830bce0..6d4ffb945a0 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java index 96d35603bf5..5ff3690685f 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Dog extends Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java index 9c6b5e35de6..ae470044a23 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class FormatTest { private Integer integer = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java index 41b7842d606..e3d07e1b441 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Model200Response { private Integer name = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java index 91fb6b5b939..a1ca4f7ef45 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:32.462+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class ModelApiResponse { private Integer code = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java index 2994e48adaf..b8b35a72382 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java index e51b32ff5a2..d993ca02455 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java @@ -12,11 +12,12 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Name { private Integer name = null; private Integer snakeCase = null; + private String property = null; /** @@ -43,6 +44,23 @@ public class Name { } + /** + **/ + public Name property(String property) { + this.property = property; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("property") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -53,12 +71,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(this.name, name.name) && - Objects.equals(this.snakeCase, name.snakeCase); + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -68,6 +87,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java index 3c0ea427c41..9004aa13a10 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Order { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java index ee4ce28371b..f23c9124882 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java index 786d75c976c..b2b87fad3a4 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java index 4e323812065..55bef8324de 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java index 23e363a518e..d8657dda7f5 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/build.gradle b/samples/client/petstore/java/jersey2/build.gradle index 2daaf89454a..9c98d11c4cd 100644 --- a/samples/client/petstore/java/jersey2/build.gradle +++ b/samples/client/petstore/java/jersey2/build.gradle @@ -95,9 +95,9 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.0" - jackson_version = "2.4.2" - jersey_version = "2.22" - jodatime_version = "2.3" + jackson_version = "2.7.0" + jersey_version = "2.22.2" + jodatime_version = "2.9.3" junit_version = "4.12" } diff --git a/samples/client/petstore/java/jersey2/docs/Name.md b/samples/client/petstore/java/jersey2/docs/Name.md index a1adac1dd39..5390a15e9cd 100644 --- a/samples/client/petstore/java/jersey2/docs/Name.md +++ b/samples/client/petstore/java/jersey2/docs/Name.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | **snakeCase** | **Integer** | | [optional] +**property** | **String** | | [optional] diff --git a/samples/client/petstore/java/jersey2/pom.xml b/samples/client/petstore/java/jersey2/pom.xml index 216caa5675b..c07ae01939a 100644 --- a/samples/client/petstore/java/jersey2/pom.xml +++ b/samples/client/petstore/java/jersey2/pom.xml @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 @@ -131,7 +131,7 @@ io.swagger swagger-annotations - ${swagger-annotations-version} + ${swagger-core-version} @@ -194,10 +194,10 @@ - 1.5.0 - 2.22 - 2.4.2 - 2.3 + 1.5.8 + 2.22.2 + 2.7.0 + 2.9.3 1.0.0 4.12 diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java index f513e2165c7..d5c0fa366bd 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java index c6c4f0b1cd6..91b18d8f79c 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java index 8d447238daf..a6ffdc8fbe7 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java @@ -8,7 +8,7 @@ import java.text.DateFormat; import javax.ws.rs.ext.ContextResolver; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class JSON implements ContextResolver { private ObjectMapper mapper; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java index 6fb0888876f..b3532990688 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java index cd18a247928..6409e1b1765 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index d96bf5dcc0b..39b9775f39d 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -8,15 +8,15 @@ import io.swagger.client.Pair; import javax.ws.rs.core.GenericType; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:21.396+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class PetApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index 65d0ff6a615..d2a87ef01fa 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class StoreApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java index 8a1cba219a6..b97e2357a4b 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class UserApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index acdcaa52fcd..62506180f53 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index fc96078e06e..65681bc9aa5 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -9,7 +9,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java index e70241f1171..dda7cae0a05 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java index d56e70d7689..a4dfdc3bc56 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java index da8a3553b00..f150e8d3121 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Cat extends Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java index e8e19c2d32e..78f43782919 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java index 0d620e5addd..45c85698089 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Dog extends Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java index 1586ae89d6d..774ce0ebcfe 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class FormatTest { private Integer integer = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java index 1db08de21f4..cd6a37772e0 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Model200Response { private Integer name = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java index fe1bf3f483d..5a3f9254bae 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:21.396+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class ModelApiResponse { private Integer code = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java index 1f89198ddda..e6214862791 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java index cc7dbe3dd6e..f710f6122e4 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java @@ -12,11 +12,12 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Name { private Integer name = null; private Integer snakeCase = null; + private String property = null; /** @@ -43,6 +44,23 @@ public class Name { } + /** + **/ + public Name property(String property) { + this.property = property; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("property") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -53,12 +71,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(this.name, name.name) && - Objects.equals(this.snakeCase, name.snakeCase); + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -68,6 +87,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index 136aa894eb4..c2fbdbcc9f9 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Order { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 859a1ce8c3c..100c8f265f0 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java index be6b9c3c92a..fa2813e9c42 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java index 276ff12d6eb..f82159f2111 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java index 646f9969f30..56bfb774ccb 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/okhttp-gson/build.gradle b/samples/client/petstore/java/okhttp-gson/build.gradle index 73518e39969..57812871f64 100644 --- a/samples/client/petstore/java/okhttp-gson/build.gradle +++ b/samples/client/petstore/java/okhttp-gson/build.gradle @@ -94,9 +94,9 @@ if(hasProperty('target') && target == 'android') { } dependencies { - compile 'io.swagger:swagger-annotations:1.5.0' - compile 'com.squareup.okhttp:okhttp:2.7.2' - compile 'com.squareup.okhttp:logging-interceptor:2.7.2' - compile 'com.google.code.gson:gson:2.3.1' + compile 'io.swagger:swagger-annotations:1.5.8' + compile 'com.squareup.okhttp:okhttp:2.7.5' + compile 'com.squareup.okhttp:logging-interceptor:2.7.5' + compile 'com.google.code.gson:gson:2.6.2' testCompile 'junit:junit:4.12' } diff --git a/samples/client/petstore/java/okhttp-gson/build.sbt b/samples/client/petstore/java/okhttp-gson/build.sbt index 873affa9604..1be5d0b6f4d 100644 --- a/samples/client/petstore/java/okhttp-gson/build.sbt +++ b/samples/client/petstore/java/okhttp-gson/build.sbt @@ -9,10 +9,10 @@ lazy val root = (project in file(".")). publishArtifact in (Compile, packageDoc) := false, resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( - "io.swagger" % "swagger-annotations" % "1.5.0", - "com.squareup.okhttp" % "okhttp" % "2.7.2", - "com.squareup.okhttp" % "logging-interceptor" % "2.7.2", - "com.google.code.gson" % "gson" % "2.3.1", - "junit" % "junit" % "4.8.1" % "test" + "io.swagger" % "swagger-annotations" % "1.5.8", + "com.squareup.okhttp" % "okhttp" % "2.7.5", + "com.squareup.okhttp" % "logging-interceptor" % "2.7.5", + "com.google.code.gson" % "gson" % "2.6.2", + "junit" % "junit" % "4.12.0" % "test" ) ) diff --git a/samples/client/petstore/java/okhttp-gson/docs/Name.md b/samples/client/petstore/java/okhttp-gson/docs/Name.md index a1adac1dd39..5390a15e9cd 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/Name.md +++ b/samples/client/petstore/java/okhttp-gson/docs/Name.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | **snakeCase** | **Integer** | | [optional] +**property** | **String** | | [optional] diff --git a/samples/client/petstore/java/okhttp-gson/pom.xml b/samples/client/petstore/java/okhttp-gson/pom.xml index 520d234a769..6b5fb468d62 100644 --- a/samples/client/petstore/java/okhttp-gson/pom.xml +++ b/samples/client/petstore/java/okhttp-gson/pom.xml @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 @@ -160,8 +160,8 @@ 1.5.8 - 2.7.2 - 2.3.1 + 2.7.5 + 2.6.2 1.0.0 4.12 diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java index 38c89d2d0fc..91d660ba2ac 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java index e879206d377..cba4c9e4fde 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java index e1b2c38f0a2..d7d9f17cf3c 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java index 32556afd1b6..bcd8b8115c8 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index ac7ad688c56..75fb730c422 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -18,8 +18,8 @@ import com.squareup.okhttp.Response; import java.io.IOException; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.lang.reflect.Type; import java.util.ArrayList; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index fa2d5293018..81c31c9f07d 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java index 81d6fddf5b0..b281311fa19 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Name.java index cb65d370816..7ba516f17ec 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Name.java @@ -21,6 +21,9 @@ public class Name { @SerializedName("snake_case") private Integer snakeCase = null; + @SerializedName("property") + private String property = null; + /** **/ @ApiModelProperty(required = true, value = "") @@ -38,6 +41,16 @@ public class Name { return snakeCase; } + /** + **/ + @ApiModelProperty(value = "") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + @Override public boolean equals(Object o) { @@ -49,12 +62,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(this.name, name.name) && - Objects.equals(this.snakeCase, name.snakeCase); + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -64,6 +78,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/retrofit/build.gradle b/samples/client/petstore/java/retrofit/build.gradle index 7d0d52536eb..079d1240a39 100644 --- a/samples/client/petstore/java/retrofit/build.gradle +++ b/samples/client/petstore/java/retrofit/build.gradle @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - okhttp_version = "2.3.0" - oltu_version = "1.0.0" + okhttp_version = "2.7.5" + oltu_version = "1.0.1" retrofit_version = "1.9.0" - swagger_annotations_version = "1.5.0" + swagger_annotations_version = "1.5.8" junit_version = "4.12" } diff --git a/samples/client/petstore/java/retrofit/pom.xml b/samples/client/petstore/java/retrofit/pom.xml index 6e2a7b76ac2..2fe5ddc8efc 100644 --- a/samples/client/petstore/java/retrofit/pom.xml +++ b/samples/client/petstore/java/retrofit/pom.xml @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 @@ -110,7 +110,7 @@ io.swagger swagger-annotations - ${swagger-annotations-version} + ${swagger-core-version} com.squareup.retrofit @@ -137,10 +137,10 @@ - 1.5.0 + 1.5.8 1.9.0 - 2.4.0 - 1.0.0 + 2.7.5 + 1.0.1 1.0.0 4.12 diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java index 1ec34d9e71d..8adb42d4fb8 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:01.525+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:55:47.640+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java index a019a4bf886..66ed6aea981 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java @@ -7,8 +7,8 @@ import retrofit.http.*; import retrofit.mime.*; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Name.java index fd90800298e..b24b87366a4 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Name.java @@ -21,6 +21,9 @@ public class Name { @SerializedName("snake_case") private Integer snakeCase = null; + @SerializedName("property") + private String property = null; + /** **/ @ApiModelProperty(required = true, value = "") @@ -38,6 +41,16 @@ public class Name { return snakeCase; } + /** + **/ + @ApiModelProperty(value = "") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + @Override public boolean equals(Object o) { @@ -49,12 +62,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(name, name.name) && - Objects.equals(snakeCase, name.snakeCase); + Objects.equals(snakeCase, name.snakeCase) && + Objects.equals(property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -64,6 +78,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/retrofit2/build.gradle b/samples/client/petstore/java/retrofit2/build.gradle index a893deaa2ae..6b96656a4a8 100644 --- a/samples/client/petstore/java/retrofit2/build.gradle +++ b/samples/client/petstore/java/retrofit2/build.gradle @@ -94,10 +94,9 @@ if(hasProperty('target') && target == 'android') { } ext { - oltu_version = "1.0.0" - retrofit_version = "2.0.0-beta4" - gson_version = "2.4" - swagger_annotations_version = "1.5.0" + oltu_version = "1.0.1" + retrofit_version = "2.0.2" + swagger_annotations_version = "1.5.8" junit_version = "4.12" } diff --git a/samples/client/petstore/java/retrofit2/hello.txt b/samples/client/petstore/java/retrofit2/hello.txt deleted file mode 100644 index 6769dd60bdf..00000000000 --- a/samples/client/petstore/java/retrofit2/hello.txt +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2/pom.xml b/samples/client/petstore/java/retrofit2/pom.xml index 2d8f0440161..05774ac3834 100644 --- a/samples/client/petstore/java/retrofit2/pom.xml +++ b/samples/client/petstore/java/retrofit2/pom.xml @@ -100,8 +100,7 @@ maven-compiler-plugin 2.3.2 - - 1.7 + 1.7 1.7 @@ -111,7 +110,12 @@ io.swagger swagger-annotations - ${swagger-annotations-version} + ${swagger-core-version} + + + com.squareup.retrofit2 + converter-gson + ${retrofit-version} com.squareup.retrofit2 @@ -123,11 +127,6 @@ converter-scalars ${retrofit-version} - - com.squareup.retrofit2 - converter-gson - ${retrofit-version} - org.apache.oltu.oauth2 org.apache.oltu.oauth2.client @@ -143,9 +142,11 @@ - 1.5.0 - 2.0.0-beta4 - 1.0.0 + 1.5.8 + 2.0.2 + + 3.2.0 + 1.0.1 1.0.0 4.12 diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java index fd13370ea3a..f5e5cea4151 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:03.337+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-27T10:03:24.454+02:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java new file mode 100644 index 00000000000..dc732e67ae7 --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java @@ -0,0 +1,43 @@ +package io.swagger.client.api; + +import io.swagger.client.CollectionFormats.*; + + +import retrofit2.Call; +import retrofit2.http.*; + +import okhttp3.RequestBody; + +import java.util.Date; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public interface FakeApi { + /** + * Fake endpoint for testing various parameters + * Fake endpoint for testing various parameters + * @param number None (required) + * @param _double None (required) + * @param string None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @return Call + */ + + @FormUrlEncoded + @POST("fake") + Call testEndpointParameters( + @Field("number") String number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password + ); + +} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java index 29d17bbdfe7..40d1ca0ecea 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java @@ -51,6 +51,8 @@ public class FormatTest { private String password = null; /** + * minimum: 10.0 + * maximum: 100.0 **/ @ApiModelProperty(value = "") public Integer getInteger() { @@ -61,6 +63,8 @@ public class FormatTest { } /** + * minimum: 20.0 + * maximum: 200.0 **/ @ApiModelProperty(value = "") public Integer getInt32() { @@ -81,6 +85,8 @@ public class FormatTest { } /** + * minimum: 32.1 + * maximum: 543.2 **/ @ApiModelProperty(required = true, value = "") public BigDecimal getNumber() { @@ -91,6 +97,8 @@ public class FormatTest { } /** + * minimum: 54.3 + * maximum: 987.6 **/ @ApiModelProperty(value = "") public Float getFloat() { @@ -101,6 +109,8 @@ public class FormatTest { } /** + * minimum: 67.8 + * maximum: 123.4 **/ @ApiModelProperty(value = "") public Double getDouble() { @@ -122,7 +132,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public byte[] getByte() { return _byte; } @@ -142,7 +152,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public Date getDate() { return date; } @@ -162,7 +172,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public String getPassword() { return password; } diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Name.java index fd90800298e..b24b87366a4 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Name.java @@ -21,6 +21,9 @@ public class Name { @SerializedName("snake_case") private Integer snakeCase = null; + @SerializedName("property") + private String property = null; + /** **/ @ApiModelProperty(required = true, value = "") @@ -38,6 +41,16 @@ public class Name { return snakeCase; } + /** + **/ + @ApiModelProperty(value = "") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + @Override public boolean equals(Object o) { @@ -49,12 +62,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(name, name.name) && - Objects.equals(snakeCase, name.snakeCase); + Objects.equals(snakeCase, name.snakeCase) && + Objects.equals(property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -64,6 +78,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/TestUtils.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/TestUtils.java deleted file mode 100644 index 7ddf142426e..00000000000 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/TestUtils.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.swagger; - -import java.util.Random; -import java.util.concurrent.atomic.AtomicLong; - -public class TestUtils { - private static final AtomicLong atomicId = createAtomicId(); - - public static long nextId() { - return atomicId.getAndIncrement(); - } - - private static AtomicLong createAtomicId() { - int baseId = new Random(System.currentTimeMillis()).nextInt(1000000) + 20000; - return new AtomicLong((long) baseId); - } -} diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java deleted file mode 100644 index ac8abefb216..00000000000 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.TestUtils; - -import io.swagger.client.ApiClient; -import io.swagger.client.CollectionFormats.*; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.*; - -import retrofit2.Response; - -import okhttp3.MediaType; -import okhttp3.RequestBody; - -import static org.junit.Assert.*; - -public class PetApiTest { - PetApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(PetApi.class); - } - - @Test - public void testCreateAndGetPet() throws Exception { - Pet pet = createRandomPet(); - Response rp2 = api.addPet(pet).execute(); - - Response rp = api.getPetById(pet.getId()).execute(); - Pet fetched = rp.body(); - assertNotNull(fetched); - assertEquals(pet.getId(), fetched.getId()); - assertNotNull(fetched.getCategory()); - assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); - } - - @Test - public void testUpdatePet() throws Exception { - Pet pet = createRandomPet(); - pet.setName("programmer"); - - api.updatePet(pet).execute(); - - Pet fetched = api.getPetById(pet.getId()).execute().body(); - assertNotNull(fetched); - assertEquals(pet.getId(), fetched.getId()); - assertNotNull(fetched.getCategory()); - assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); - } - - @Test - public void testFindPetsByStatus() throws Exception { - Pet pet = createRandomPet(); - pet.setName("programmer"); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - - api.updatePet(pet).execute(); - - List pets = api.findPetsByStatus(new CSVParams("available")).execute().body(); - assertNotNull(pets); - - boolean found = false; - for (Pet fetched : pets) { - if (fetched.getId().equals(pet.getId())) { - found = true; - break; - } - } - - assertTrue(found); - } - - @Test - public void testFindPetsByTags() throws Exception { - Pet pet = createRandomPet(); - pet.setName("monster"); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - - List tags = new ArrayList(); - Tag tag1 = new Tag(); - tag1.setName("friendly"); - tags.add(tag1); - pet.setTags(tags); - - api.updatePet(pet).execute(); - - List pets = api.findPetsByTags(new CSVParams("friendly")).execute().body(); - assertNotNull(pets); - - boolean found = false; - for (Pet fetched : pets) { - if (fetched.getId().equals(pet.getId())) { - found = true; - break; - } - } - assertTrue(found); - } - - @Test - public void testUpdatePetWithForm() throws Exception { - Pet pet = createRandomPet(); - pet.setName("frank"); - api.addPet(pet).execute(); - - Pet fetched = api.getPetById(pet.getId()).execute().body(); - - api.updatePetWithForm(fetched.getId(), "furt", null).execute(); - Pet updated = api.getPetById(fetched.getId()).execute().body(); - - assertEquals(updated.getName(), "furt"); - } - - @Test - public void testDeletePet() throws Exception { - Pet pet = createRandomPet(); - api.addPet(pet).execute(); - - Pet fetched = api.getPetById(pet.getId()).execute().body(); - api.deletePet(fetched.getId(), null).execute(); - - assertFalse(api.getPetById(fetched.getId()).execute().isSuccess()); - } - - @Test - public void testUploadFile() throws Exception { - Pet pet = createRandomPet(); - api.addPet(pet).execute(); - - File file = new File("hello.txt"); - BufferedWriter writer = new BufferedWriter(new FileWriter(file)); - writer.write("Hello world!"); - writer.close(); - - api.uploadFile(pet.getId(), null, RequestBody.create(MediaType.parse("text/plain"), file)).execute(); - } - - @Test - public void testEqualsAndHashCode() { - Pet pet1 = new Pet(); - Pet pet2 = new Pet(); - assertTrue(pet1.equals(pet2)); - assertTrue(pet2.equals(pet1)); - assertTrue(pet1.hashCode() == pet2.hashCode()); - assertTrue(pet1.equals(pet1)); - assertTrue(pet1.hashCode() == pet1.hashCode()); - - pet2.setName("really-happy"); - pet2.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"})); - assertFalse(pet1.equals(pet2)); - assertFalse(pet2.equals(pet1)); - assertFalse(pet1.hashCode() == (pet2.hashCode())); - assertTrue(pet2.equals(pet2)); - assertTrue(pet2.hashCode() == pet2.hashCode()); - - pet1.setName("really-happy"); - pet1.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"})); - assertTrue(pet1.equals(pet2)); - assertTrue(pet2.equals(pet1)); - assertTrue(pet1.hashCode() == pet2.hashCode()); - assertTrue(pet1.equals(pet1)); - assertTrue(pet1.hashCode() == pet1.hashCode()); - } - - private Pet createRandomPet() { - Pet pet = new Pet(); - pet.setId(TestUtils.nextId()); - pet.setName("gorilla"); - - Category category = new Category(); - category.setName("really-happy"); - - pet.setCategory(category); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - List photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}); - pet.setPhotoUrls(photos); - - return pet; - } -} diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java deleted file mode 100644 index 249d5dc4828..00000000000 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.TestUtils; - -import io.swagger.client.ApiClient; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - -import java.lang.reflect.Field; -import java.util.Map; - -import org.junit.*; - -import retrofit2.Response; -import static org.junit.Assert.*; - -public class StoreApiTest { - StoreApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(StoreApi.class); - } - - @Test - public void testGetInventory() throws Exception { - Map inventory = api.getInventory().execute().body(); - assertTrue(inventory.keySet().size() > 0); - } - - @Test - public void testPlaceOrder() throws Exception { - Order order = createOrder(); - api.placeOrder(order).execute(); - - Order fetched = api.getOrderById(order.getId()).execute().body(); - assertEquals(order.getId(), fetched.getId()); - assertEquals(order.getPetId(), fetched.getPetId()); - assertEquals(order.getQuantity(), fetched.getQuantity()); - } - - @Test - public void testDeleteOrder() throws Exception { - Order order = createOrder(); - Response aa = api.placeOrder(order).execute(); - - Order fetched = api.getOrderById(order.getId()).execute().body(); - assertEquals(fetched.getId(), order.getId()); - - api.deleteOrder(String.valueOf(order.getId())).execute(); - - api.getOrderById(order.getId()).execute(); - //also in retrofit 1 should return an error but don't, check server api impl. - } - - private Order createOrder() { - Order order = new Order(); - order.setPetId(new Long(200)); - order.setQuantity(new Integer(13)); - order.setShipDate(new java.util.Date()); - order.setStatus(Order.StatusEnum.PLACED); - order.setComplete(true); - - try { - Field idField = Order.class.getDeclaredField("id"); - idField.setAccessible(true); - idField.set(order, TestUtils.nextId()); - } catch (Exception e) { - throw new RuntimeException(e); - } - - return order; - } -} diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/UserApiTest.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/UserApiTest.java deleted file mode 100644 index 6c35c94383a..00000000000 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/UserApiTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.TestUtils; - -import io.swagger.client.ApiClient; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - - -import java.util.Arrays; - -import org.junit.*; -import static org.junit.Assert.*; - -public class UserApiTest { - UserApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(UserApi.class); - } - - @Test - public void testCreateUser() throws Exception { - User user = createUser(); - - api.createUser(user).execute(); - - User fetched = api.getUserByName(user.getUsername()).execute().body(); - assertEquals(user.getId(), fetched.getId()); - } - - @Test - public void testCreateUsersWithArray() throws Exception { - User user1 = createUser(); - user1.setUsername("user" + user1.getId()); - User user2 = createUser(); - user2.setUsername("user" + user2.getId()); - - api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2})).execute(); - - User fetched = api.getUserByName(user1.getUsername()).execute().body(); - assertEquals(user1.getId(), fetched.getId()); - } - - @Test - public void testCreateUsersWithList() throws Exception { - User user1 = createUser(); - user1.setUsername("user" + user1.getId()); - User user2 = createUser(); - user2.setUsername("user" + user2.getId()); - - api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2})).execute(); - - User fetched = api.getUserByName(user1.getUsername()).execute().body(); - assertEquals(user1.getId(), fetched.getId()); - } - - @Test - public void testLoginUser() throws Exception { - User user = createUser(); - api.createUser(user).execute(); - - String token = api.loginUser(user.getUsername(), user.getPassword()).execute().body(); - assertTrue(token.startsWith("logged in user session:")); - } - - @Test - public void logoutUser() throws Exception { - api.logoutUser().execute(); - } - - private User createUser() { - User user = new User(); - user.setId(TestUtils.nextId()); - user.setUsername("fred"); - user.setFirstName("Fred"); - user.setLastName("Meyer"); - user.setEmail("fred@fredmeyer.com"); - user.setPassword("xxXXxx"); - user.setPhone("408-867-5309"); - user.setUserStatus(123); - - return user; - } -} diff --git a/samples/client/petstore/java/retrofit2rx/build.gradle b/samples/client/petstore/java/retrofit2rx/build.gradle index 123bae25560..cbd0119e24b 100644 --- a/samples/client/petstore/java/retrofit2rx/build.gradle +++ b/samples/client/petstore/java/retrofit2rx/build.gradle @@ -94,12 +94,11 @@ if(hasProperty('target') && target == 'android') { } ext { - oltu_version = "1.0.0" - retrofit_version = "2.0.0-beta4" - gson_version = "2.4" - swagger_annotations_version = "1.5.0" + oltu_version = "1.0.1" + retrofit_version = "2.0.2" + swagger_annotations_version = "1.5.8" junit_version = "4.12" - rx_java_version = "1.0.16" + rx_java_version = "1.1.3" } diff --git a/samples/client/petstore/java/retrofit2rx/pom.xml b/samples/client/petstore/java/retrofit2rx/pom.xml index b2cf9949578..79d826c3a41 100644 --- a/samples/client/petstore/java/retrofit2rx/pom.xml +++ b/samples/client/petstore/java/retrofit2rx/pom.xml @@ -100,8 +100,7 @@ maven-compiler-plugin 2.3.2 - - 1.7 + 1.7 1.7 @@ -111,7 +110,12 @@ io.swagger swagger-annotations - ${swagger-annotations-version} + ${swagger-core-version} + + + com.squareup.retrofit2 + converter-gson + ${retrofit-version} com.squareup.retrofit2 @@ -123,11 +127,6 @@ converter-scalars ${retrofit-version} - - com.squareup.retrofit2 - converter-gson - ${retrofit-version} - org.apache.oltu.oauth2 org.apache.oltu.oauth2.client @@ -153,10 +152,11 @@ - 1.5.0 - 2.0.0-beta4 - 1.0.16 - 1.0.0 + 1.5.8 + 2.0.2 + 1.1.3 + 3.2.0 + 1.0.1 1.0.0 4.12 diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java index 423a5762822..cee81411e96 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:05.103+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-27T10:03:29.641+02:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java new file mode 100644 index 00000000000..beaa9833892 --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java @@ -0,0 +1,43 @@ +package io.swagger.client.api; + +import io.swagger.client.CollectionFormats.*; + +import rx.Observable; + +import retrofit2.http.*; + +import okhttp3.RequestBody; + +import java.util.Date; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public interface FakeApi { + /** + * Fake endpoint for testing various parameters + * Fake endpoint for testing various parameters + * @param number None (required) + * @param _double None (required) + * @param string None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @return Call + */ + + @FormUrlEncoded + @POST("fake") + Observable testEndpointParameters( + @Field("number") String number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password + ); + +} diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java index 29d17bbdfe7..40d1ca0ecea 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java @@ -51,6 +51,8 @@ public class FormatTest { private String password = null; /** + * minimum: 10.0 + * maximum: 100.0 **/ @ApiModelProperty(value = "") public Integer getInteger() { @@ -61,6 +63,8 @@ public class FormatTest { } /** + * minimum: 20.0 + * maximum: 200.0 **/ @ApiModelProperty(value = "") public Integer getInt32() { @@ -81,6 +85,8 @@ public class FormatTest { } /** + * minimum: 32.1 + * maximum: 543.2 **/ @ApiModelProperty(required = true, value = "") public BigDecimal getNumber() { @@ -91,6 +97,8 @@ public class FormatTest { } /** + * minimum: 54.3 + * maximum: 987.6 **/ @ApiModelProperty(value = "") public Float getFloat() { @@ -101,6 +109,8 @@ public class FormatTest { } /** + * minimum: 67.8 + * maximum: 123.4 **/ @ApiModelProperty(value = "") public Double getDouble() { @@ -122,7 +132,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public byte[] getByte() { return _byte; } @@ -142,7 +152,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public Date getDate() { return date; } @@ -162,7 +172,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public String getPassword() { return password; } diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Name.java index fd90800298e..b24b87366a4 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Name.java @@ -21,6 +21,9 @@ public class Name { @SerializedName("snake_case") private Integer snakeCase = null; + @SerializedName("property") + private String property = null; + /** **/ @ApiModelProperty(required = true, value = "") @@ -38,6 +41,16 @@ public class Name { return snakeCase; } + /** + **/ + @ApiModelProperty(value = "") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + @Override public boolean equals(Object o) { @@ -49,12 +62,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(name, name.name) && - Objects.equals(snakeCase, name.snakeCase); + Objects.equals(snakeCase, name.snakeCase) && + Objects.equals(property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -64,6 +78,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java deleted file mode 100644 index e506ec00e9a..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ /dev/null @@ -1,255 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.client.ApiClient; -import io.swagger.client.CollectionFormats.*; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.*; - -import okhttp3.MediaType; -import okhttp3.RequestBody; - -import static org.junit.Assert.*; - -public class PetApiTest { - PetApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(PetApi.class); - } - - @Test - public void testCreateAndGetPet() throws Exception { - final Pet pet = createRandomPet(); - api.addPet(pet).subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Pet fetched) { - assertNotNull(fetched); - assertEquals(pet.getId(), fetched.getId()); - assertNotNull(fetched.getCategory()); - assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); - } - }); - - } - }); - - } - - @Test - public void testUpdatePet() throws Exception { - final Pet pet = createRandomPet(); - pet.setName("programmer"); - - api.updatePet(pet).subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Pet fetched) { - assertNotNull(fetched); - assertEquals(pet.getId(), fetched.getId()); - assertNotNull(fetched.getCategory()); - assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); - } - }); - - } - }); - - } - - @Test - public void testFindPetsByStatus() throws Exception { - final Pet pet = createRandomPet(); - pet.setName("programmer"); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - - api.updatePet(pet).subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.findPetsByStatus(new CSVParams("available")).subscribe(new SkeletonSubscriber>() { - @Override - public void onNext(List pets) { - assertNotNull(pets); - - boolean found = false; - for (Pet fetched : pets) { - if (fetched.getId().equals(pet.getId())) { - found = true; - break; - } - } - - assertTrue(found); - } - }); - - } - }); - - } - - @Test - public void testFindPetsByTags() throws Exception { - final Pet pet = createRandomPet(); - pet.setName("monster"); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - - List tags = new ArrayList(); - Tag tag1 = new Tag(); - tag1.setName("friendly"); - tags.add(tag1); - pet.setTags(tags); - - api.updatePet(pet).subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.findPetsByTags(new CSVParams("friendly")).subscribe(new SkeletonSubscriber>() { - @Override - public void onNext(List pets) { - assertNotNull(pets); - - boolean found = false; - for (Pet fetched : pets) { - if (fetched.getId().equals(pet.getId())) { - found = true; - break; - } - } - assertTrue(found); - } - }); - - } - }); - - } - - @Test - public void testUpdatePetWithForm() throws Exception { - final Pet pet = createRandomPet(); - pet.setName("frank"); - api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError()); - api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(final Pet fetched) { - api.updatePetWithForm(fetched.getId(), "furt", null) - .subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.getPetById(fetched.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Pet updated) { - assertEquals(updated.getName(), "furt"); - } - }); - - } - }); - } - }); - - - } - - @Test - public void testDeletePet() throws Exception { - Pet pet = createRandomPet(); - api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError()); - - api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Pet fetched) { - - api.deletePet(fetched.getId(), null).subscribe(SkeletonSubscriber.failTestOnError()); - api.getPetById(fetched.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Pet deletedPet) { - fail("Should not have found deleted pet."); - } - - @Override - public void onError(Throwable e) { - // expected, because the pet has been deleted. - } - }); - } - }); - } - - @Test - public void testUploadFile() throws Exception { - File file = File.createTempFile("test", "hello.txt"); - BufferedWriter writer = new BufferedWriter(new FileWriter(file)); - - writer.write("Hello world!"); - writer.close(); - - Pet pet = createRandomPet(); - api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError()); - - RequestBody body = RequestBody.create(MediaType.parse("text/plain"), file); - api.uploadFile(pet.getId(), "a test file", body).subscribe(new SkeletonSubscriber() { - @Override - public void onError(Throwable e) { - // this also yields a 400 for other tests, so I guess it's okay... - } - }); - } - - @Test - public void testEqualsAndHashCode() { - Pet pet1 = new Pet(); - Pet pet2 = new Pet(); - assertTrue(pet1.equals(pet2)); - assertTrue(pet2.equals(pet1)); - assertTrue(pet1.hashCode() == pet2.hashCode()); - assertTrue(pet1.equals(pet1)); - assertTrue(pet1.hashCode() == pet1.hashCode()); - - pet2.setName("really-happy"); - pet2.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"})); - assertFalse(pet1.equals(pet2)); - assertFalse(pet2.equals(pet1)); - assertFalse(pet1.hashCode() == (pet2.hashCode())); - assertTrue(pet2.equals(pet2)); - assertTrue(pet2.hashCode() == pet2.hashCode()); - - pet1.setName("really-happy"); - pet1.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"})); - assertTrue(pet1.equals(pet2)); - assertTrue(pet2.equals(pet1)); - assertTrue(pet1.hashCode() == pet2.hashCode()); - assertTrue(pet1.equals(pet1)); - assertTrue(pet1.hashCode() == pet1.hashCode()); - } - - private Pet createRandomPet() { - Pet pet = new Pet(); - pet.setId(System.currentTimeMillis()); - pet.setName("gorilla"); - - Category category = new Category(); - category.setName("really-happy"); - - pet.setCategory(category); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - List photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}); - pet.setPhotoUrls(photos); - - return pet; - } -} diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/SkeletonSubscriber.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/SkeletonSubscriber.java deleted file mode 100644 index 5d34a1e5d5d..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/SkeletonSubscriber.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.swagger.petstore.test; - -import junit.framework.TestFailure; -import rx.Subscriber; - -/** - * Skeleton subscriber for tests that will fail when onError() is called unexpectedly. - */ -public abstract class SkeletonSubscriber extends Subscriber { - - public static SkeletonSubscriber failTestOnError() { - return new SkeletonSubscriber() { - }; - } - - @Override - public void onCompleted() { - // space for rent - } - - @Override - public void onNext(T t) { - // space for rent - } - - @Override - public void onError(Throwable e) { - throw new RuntimeException("Subscriber onError() called with unhandled exception!", e); - } -} diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java deleted file mode 100644 index f5a34eab200..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.client.ApiClient; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - -import java.lang.reflect.Field; -import java.util.Map; - -import org.junit.*; - -import retrofit2.Response; - -import static org.junit.Assert.*; - -public class StoreApiTest { - StoreApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(StoreApi.class); - } - - @Test - public void testGetInventory() throws Exception { - api.getInventory().subscribe(new SkeletonSubscriber>() { - @Override - public void onNext(Map inventory) { - assertTrue(inventory.keySet().size() > 0); - } - }); - - } - - @Test - public void testPlaceOrder() throws Exception { - final Order order = createOrder(); - api.placeOrder(order).subscribe(SkeletonSubscriber.failTestOnError()); - api.getOrderById(order.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Order fetched) { - assertEquals(order.getId(), fetched.getId()); - assertEquals(order.getPetId(), fetched.getPetId()); - assertEquals(order.getQuantity(), fetched.getQuantity()); - } - }); - } - - @Test - public void testDeleteOrder() throws Exception { - final Order order = createOrder(); - api.placeOrder(order).subscribe(SkeletonSubscriber.failTestOnError()); - - api.getOrderById(order.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Order fetched) { - assertEquals(fetched.getId(), order.getId()); - } - }); - - - api.deleteOrder(String.valueOf(order.getId())).subscribe(SkeletonSubscriber.failTestOnError()); - api.getOrderById(order.getId()) - .subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Order order) { - throw new RuntimeException("Should not have found deleted order."); - } - - @Override - public void onError(Throwable e) { - // should not find deleted order. - } - } - ); - } - - private Order createOrder() { - Order order = new Order(); - order.setPetId(new Long(200)); - order.setQuantity(new Integer(13)); - order.setShipDate(new java.util.Date()); - order.setStatus(Order.StatusEnum.PLACED); - order.setComplete(true); - - try { - Field idField = Order.class.getDeclaredField("id"); - idField.setAccessible(true); - idField.set(order, System.currentTimeMillis()); - } catch (Exception e) { - throw new RuntimeException(e); - } - - return order; - } -} diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/UserApiTest.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/UserApiTest.java deleted file mode 100644 index 59e238b457b..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/UserApiTest.java +++ /dev/null @@ -1,108 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.client.ApiClient; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - - -import java.util.Arrays; - -import org.junit.*; - -import static org.junit.Assert.*; - -/** - * NOTE: This serves as a sample and test case for the generator, which is why this is java-7 code. - * Much looks much nicer with no anonymous classes. - */ -public class UserApiTest { - UserApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(UserApi.class); - } - - @Test - public void testCreateUser() throws Exception { - final User user = createUser(); - - api.createUser(user).subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.getUserByName(user.getUsername()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(User fetched) { - assertEquals(user.getId(), fetched.getId()); - } - }); - } - }); - } - - @Test - public void testCreateUsersWithArray() throws Exception { - final User user1 = createUser(); - user1.setUsername("abc123"); - User user2 = createUser(); - user2.setUsername("123abc"); - - api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2})).subscribe(SkeletonSubscriber.failTestOnError()); - - api.getUserByName(user1.getUsername()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(User fetched) { - assertEquals(user1.getId(), fetched.getId()); - } - }); - } - - @Test - public void testCreateUsersWithList() throws Exception { - final User user1 = createUser(); - user1.setUsername("abc123"); - User user2 = createUser(); - user2.setUsername("123abc"); - - api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2})).subscribe(SkeletonSubscriber.failTestOnError()); - - api.getUserByName(user1.getUsername()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(User fetched) { - assertEquals(user1.getId(), fetched.getId()); - } - }); - } - - @Test - public void testLoginUser() throws Exception { - User user = createUser(); - api.createUser(user); - - api.loginUser(user.getUsername(), user.getPassword()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(String token) { - assertTrue(token.startsWith("logged in user session:")); - } - }); - } - - @Test - public void logoutUser() throws Exception { - api.logoutUser(); - } - - private User createUser() { - User user = new User(); - user.setId(System.currentTimeMillis()); - user.setUsername("fred"); - user.setFirstName("Fred"); - user.setLastName("Meyer"); - user.setEmail("fred@fredmeyer.com"); - user.setPassword("xxXXxx"); - user.setPhone("408-867-5309"); - user.setUserStatus(123); - - return user; - } -} \ No newline at end of file diff --git a/samples/client/petstore/javascript-closure-angular/API/Client/PetApi.js b/samples/client/petstore/javascript-closure-angular/API/Client/PetApi.js index 5cf1c6d751d..39a22ebcdbe 100644 --- a/samples/client/petstore/javascript-closure-angular/API/Client/PetApi.js +++ b/samples/client/petstore/javascript-closure-angular/API/Client/PetApi.js @@ -3,9 +3,9 @@ * Do not edit this file by hand or your changes will be lost next time it is * generated. * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * Version: 1.0.0 - * Generated at: 2016-04-16T18:02:07.029+08:00 + * Generated at: 2016-04-28T06:15:51.482Z * Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen */ /** @@ -40,11 +40,50 @@ API.Client.PetApi = function($http, $httpParamSerializer, $injector) { /** @private {!angular.$http} */ this.http_ = $http; - /** @private {!Object} */ - this.httpParamSerializer_ = $injector.get('$httpParamSerializer'); + /** @package {!Object} */ + this.httpParamSerializer = $injector.get('$httpParamSerializer'); } API.Client.PetApi.$inject = ['$http', '$httpParamSerializer', '$injector']; +/** + * Update an existing pet + * + * @param {!Pet} body Pet object that needs to be added to the store + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.PetApi.prototype.updatePet = function(body, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/pet'; + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'body' is set + if (!body) { + throw new Error('Missing required parameter body when calling updatePet'); + } + /** @type {!Object} */ + var httpRequestParams = { + method: 'PUT', + url: path, + json: true, + data: body, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + /** * Add a new pet to the store * @@ -60,7 +99,7 @@ API.Client.PetApi.prototype.addPet = function(body, opt_extraHttpRequestParams) var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'body' is set if (!body) { throw new Error('Missing required parameter body when calling addPet'); @@ -71,7 +110,9 @@ API.Client.PetApi.prototype.addPet = function(body, opt_extraHttpRequestParams) url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -79,47 +120,7 @@ API.Client.PetApi.prototype.addPet = function(body, opt_extraHttpRequestParams) httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); -} - -/** - * Deletes a pet - * - * @param {!number} petId Pet id to delete - * @param {!string=} opt_apiKey - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.PetApi.prototype.deletePet = function(petId, opt_apiKey, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/pet/{petId}' - .replace('{' + 'petId' + '}', String(petId)); - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'petId' is set - if (!petId) { - throw new Error('Missing required parameter petId when calling deletePet'); - } - headerParams['api_key'] = opt_apiKey; - - /** @type {!Object} */ - var httpRequestParams = { - method: 'DELETE', - url: path, - json: true, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -137,7 +138,7 @@ API.Client.PetApi.prototype.findPetsByStatus = function(status, opt_extraHttpReq var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'status' is set if (!status) { throw new Error('Missing required parameter status when calling findPetsByStatus'); @@ -151,7 +152,9 @@ API.Client.PetApi.prototype.findPetsByStatus = function(status, opt_extraHttpReq method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -159,7 +162,7 @@ API.Client.PetApi.prototype.findPetsByStatus = function(status, opt_extraHttpReq httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -177,7 +180,7 @@ API.Client.PetApi.prototype.findPetsByTags = function(tags, opt_extraHttpRequest var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'tags' is set if (!tags) { throw new Error('Missing required parameter tags when calling findPetsByTags'); @@ -191,7 +194,9 @@ API.Client.PetApi.prototype.findPetsByTags = function(tags, opt_extraHttpRequest method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -199,7 +204,7 @@ API.Client.PetApi.prototype.findPetsByTags = function(tags, opt_extraHttpRequest httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -218,7 +223,7 @@ API.Client.PetApi.prototype.getPetById = function(petId, opt_extraHttpRequestPar var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'petId' is set if (!petId) { throw new Error('Missing required parameter petId when calling getPetById'); @@ -228,7 +233,9 @@ API.Client.PetApi.prototype.getPetById = function(petId, opt_extraHttpRequestPar method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -236,44 +243,7 @@ API.Client.PetApi.prototype.getPetById = function(petId, opt_extraHttpRequestPar httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); -} - -/** - * Update an existing pet - * - * @param {!Pet} body Pet object that needs to be added to the store - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.PetApi.prototype.updatePet = function(body, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/pet'; - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'body' is set - if (!body) { - throw new Error('Missing required parameter body when calling updatePet'); - } - /** @type {!Object} */ - var httpRequestParams = { - method: 'PUT', - url: path, - json: true, - data: body, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -294,7 +264,7 @@ API.Client.PetApi.prototype.updatePetWithForm = function(petId, opt_name, opt_st var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); /** @type {!Object} */ var formParams = {}; @@ -313,7 +283,9 @@ API.Client.PetApi.prototype.updatePetWithForm = function(petId, opt_name, opt_st method: 'POST', url: path, json: false, - data: this.httpParamSerializer_(formParams), + + data: this.httpParamSerializer(formParams), + params: queryParameters, headers: headerParams }; @@ -322,7 +294,49 @@ API.Client.PetApi.prototype.updatePetWithForm = function(petId, opt_name, opt_st httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + +/** + * Deletes a pet + * + * @param {!number} petId Pet id to delete + * @param {!string=} opt_apiKey + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.PetApi.prototype.deletePet = function(petId, opt_apiKey, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'petId' is set + if (!petId) { + throw new Error('Missing required parameter petId when calling deletePet'); + } + headerParams['api_key'] = opt_apiKey; + + /** @type {!Object} */ + var httpRequestParams = { + method: 'DELETE', + url: path, + json: true, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -343,7 +357,7 @@ API.Client.PetApi.prototype.uploadFile = function(petId, opt_additionalMetadata, var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); /** @type {!Object} */ var formParams = {}; @@ -362,7 +376,9 @@ API.Client.PetApi.prototype.uploadFile = function(petId, opt_additionalMetadata, method: 'POST', url: path, json: false, - data: this.httpParamSerializer_(formParams), + + data: this.httpParamSerializer(formParams), + params: queryParameters, headers: headerParams }; @@ -371,5 +387,5 @@ API.Client.PetApi.prototype.uploadFile = function(petId, opt_additionalMetadata, httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } diff --git a/samples/client/petstore/javascript-closure-angular/API/Client/StoreApi.js b/samples/client/petstore/javascript-closure-angular/API/Client/StoreApi.js index e6c1216099a..9e18eceefcc 100644 --- a/samples/client/petstore/javascript-closure-angular/API/Client/StoreApi.js +++ b/samples/client/petstore/javascript-closure-angular/API/Client/StoreApi.js @@ -3,9 +3,9 @@ * Do not edit this file by hand or your changes will be lost next time it is * generated. * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * Version: 1.0.0 - * Generated at: 2016-04-16T18:02:07.029+08:00 + * Generated at: 2016-04-28T06:15:51.482Z * Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen */ /** @@ -39,48 +39,11 @@ API.Client.StoreApi = function($http, $httpParamSerializer, $injector) { /** @private {!angular.$http} */ this.http_ = $http; - /** @private {!Object} */ - this.httpParamSerializer_ = $injector.get('$httpParamSerializer'); + /** @package {!Object} */ + this.httpParamSerializer = $injector.get('$httpParamSerializer'); } API.Client.StoreApi.$inject = ['$http', '$httpParamSerializer', '$injector']; -/** - * Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @param {!string} orderId ID of the order that needs to be deleted - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.StoreApi.prototype.deleteOrder = function(orderId, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/store/order/{orderId}' - .replace('{' + 'orderId' + '}', String(orderId)); - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'orderId' is set - if (!orderId) { - throw new Error('Missing required parameter orderId when calling deleteOrder'); - } - /** @type {!Object} */ - var httpRequestParams = { - method: 'DELETE', - url: path, - json: true, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); -} - /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -95,13 +58,15 @@ API.Client.StoreApi.prototype.getInventory = function(opt_extraHttpRequestParams var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); /** @type {!Object} */ var httpRequestParams = { method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -109,44 +74,7 @@ API.Client.StoreApi.prototype.getInventory = function(opt_extraHttpRequestParams httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); -} - -/** - * Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @param {!number} orderId ID of pet that needs to be fetched - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.StoreApi.prototype.getOrderById = function(orderId, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/store/order/{orderId}' - .replace('{' + 'orderId' + '}', String(orderId)); - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'orderId' is set - if (!orderId) { - throw new Error('Missing required parameter orderId when calling getOrderById'); - } - /** @type {!Object} */ - var httpRequestParams = { - method: 'GET', - url: path, - json: true, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -164,7 +92,7 @@ API.Client.StoreApi.prototype.placeOrder = function(body, opt_extraHttpRequestPa var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'body' is set if (!body) { throw new Error('Missing required parameter body when calling placeOrder'); @@ -175,7 +103,9 @@ API.Client.StoreApi.prototype.placeOrder = function(body, opt_extraHttpRequestPa url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -183,5 +113,83 @@ API.Client.StoreApi.prototype.placeOrder = function(body, opt_extraHttpRequestPa httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + +/** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param {!number} orderId ID of pet that needs to be fetched + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.StoreApi.prototype.getOrderById = function(orderId, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', String(orderId)); + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'orderId' is set + if (!orderId) { + throw new Error('Missing required parameter orderId when calling getOrderById'); + } + /** @type {!Object} */ + var httpRequestParams = { + method: 'GET', + url: path, + json: true, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + +/** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param {!string} orderId ID of the order that needs to be deleted + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.StoreApi.prototype.deleteOrder = function(orderId, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', String(orderId)); + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'orderId' is set + if (!orderId) { + throw new Error('Missing required parameter orderId when calling deleteOrder'); + } + /** @type {!Object} */ + var httpRequestParams = { + method: 'DELETE', + url: path, + json: true, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); } diff --git a/samples/client/petstore/javascript-closure-angular/API/Client/UserApi.js b/samples/client/petstore/javascript-closure-angular/API/Client/UserApi.js index 97b524c9d8a..733f7d65f5a 100644 --- a/samples/client/petstore/javascript-closure-angular/API/Client/UserApi.js +++ b/samples/client/petstore/javascript-closure-angular/API/Client/UserApi.js @@ -3,9 +3,9 @@ * Do not edit this file by hand or your changes will be lost next time it is * generated. * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * Version: 1.0.0 - * Generated at: 2016-04-16T18:02:07.029+08:00 + * Generated at: 2016-04-28T06:15:51.482Z * Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen */ /** @@ -39,8 +39,8 @@ API.Client.UserApi = function($http, $httpParamSerializer, $injector) { /** @private {!angular.$http} */ this.http_ = $http; - /** @private {!Object} */ - this.httpParamSerializer_ = $injector.get('$httpParamSerializer'); + /** @package {!Object} */ + this.httpParamSerializer = $injector.get('$httpParamSerializer'); } API.Client.UserApi.$inject = ['$http', '$httpParamSerializer', '$injector']; @@ -59,7 +59,7 @@ API.Client.UserApi.prototype.createUser = function(body, opt_extraHttpRequestPar var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'body' is set if (!body) { throw new Error('Missing required parameter body when calling createUser'); @@ -70,7 +70,9 @@ API.Client.UserApi.prototype.createUser = function(body, opt_extraHttpRequestPar url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -78,7 +80,7 @@ API.Client.UserApi.prototype.createUser = function(body, opt_extraHttpRequestPar httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -96,7 +98,7 @@ API.Client.UserApi.prototype.createUsersWithArrayInput = function(body, opt_extr var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'body' is set if (!body) { throw new Error('Missing required parameter body when calling createUsersWithArrayInput'); @@ -107,7 +109,9 @@ API.Client.UserApi.prototype.createUsersWithArrayInput = function(body, opt_extr url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -115,7 +119,7 @@ API.Client.UserApi.prototype.createUsersWithArrayInput = function(body, opt_extr httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -133,7 +137,7 @@ API.Client.UserApi.prototype.createUsersWithListInput = function(body, opt_extra var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'body' is set if (!body) { throw new Error('Missing required parameter body when calling createUsersWithListInput'); @@ -144,7 +148,9 @@ API.Client.UserApi.prototype.createUsersWithListInput = function(body, opt_extra url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -152,81 +158,7 @@ API.Client.UserApi.prototype.createUsersWithListInput = function(body, opt_extra httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); -} - -/** - * Delete user - * This can only be done by the logged in user. - * @param {!string} username The name that needs to be deleted - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.UserApi.prototype.deleteUser = function(username, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/user/{username}' - .replace('{' + 'username' + '}', String(username)); - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'username' is set - if (!username) { - throw new Error('Missing required parameter username when calling deleteUser'); - } - /** @type {!Object} */ - var httpRequestParams = { - method: 'DELETE', - url: path, - json: true, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); -} - -/** - * Get user by user name - * - * @param {!string} username The name that needs to be fetched. Use user1 for testing. - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.UserApi.prototype.getUserByName = function(username, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/user/{username}' - .replace('{' + 'username' + '}', String(username)); - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'username' is set - if (!username) { - throw new Error('Missing required parameter username when calling getUserByName'); - } - /** @type {!Object} */ - var httpRequestParams = { - method: 'GET', - url: path, - json: true, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -245,7 +177,7 @@ API.Client.UserApi.prototype.loginUser = function(username, password, opt_extraH var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'username' is set if (!username) { throw new Error('Missing required parameter username when calling loginUser'); @@ -267,7 +199,9 @@ API.Client.UserApi.prototype.loginUser = function(username, password, opt_extraH method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -275,7 +209,7 @@ API.Client.UserApi.prototype.loginUser = function(username, password, opt_extraH httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -292,13 +226,15 @@ API.Client.UserApi.prototype.logoutUser = function(opt_extraHttpRequestParams) { var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); /** @type {!Object} */ var httpRequestParams = { method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -306,7 +242,46 @@ API.Client.UserApi.prototype.logoutUser = function(opt_extraHttpRequestParams) { httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + +/** + * Get user by user name + * + * @param {!string} username The name that needs to be fetched. Use user1 for testing. + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.UserApi.prototype.getUserByName = function(username, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'username' is set + if (!username) { + throw new Error('Missing required parameter username when calling getUserByName'); + } + /** @type {!Object} */ + var httpRequestParams = { + method: 'GET', + url: path, + json: true, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -326,7 +301,7 @@ API.Client.UserApi.prototype.updateUser = function(username, body, opt_extraHttp var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'username' is set if (!username) { throw new Error('Missing required parameter username when calling updateUser'); @@ -341,7 +316,9 @@ API.Client.UserApi.prototype.updateUser = function(username, body, opt_extraHttp url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -349,5 +326,44 @@ API.Client.UserApi.prototype.updateUser = function(username, body, opt_extraHttp httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + +/** + * Delete user + * This can only be done by the logged in user. + * @param {!string} username The name that needs to be deleted + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.UserApi.prototype.deleteUser = function(username, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'username' is set + if (!username) { + throw new Error('Missing required parameter username when calling deleteUser'); + } + /** @type {!Object} */ + var httpRequestParams = { + method: 'DELETE', + url: path, + json: true, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); } diff --git a/samples/client/petstore/objc/README.md b/samples/client/petstore/objc/README.md index 5223de2bc98..bd0f24851a7 100644 --- a/samples/client/petstore/objc/README.md +++ b/samples/client/petstore/objc/README.md @@ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi - API version: 1.0.0 - Package version: -- Build date: 2016-04-12T15:30:12.334+08:00 +- Build date: 2016-04-25T18:52:19.055+02:00 - Build package: class io.swagger.codegen.languages.ObjcClientCodegen ## Requirements @@ -41,18 +41,9 @@ Import the following: #import #import // load models -#import -#import -#import #import -#import -#import -#import -#import #import #import -#import -#import #import #import // load API classes for accessing endpoints @@ -107,20 +98,15 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *SWGPetApi* | [**addPet**](docs/SWGPetApi.md#addpet) | **POST** /pet | Add a new pet to the store -*SWGPetApi* | [**addPetUsingByteArray**](docs/SWGPetApi.md#addpetusingbytearray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store *SWGPetApi* | [**deletePet**](docs/SWGPetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet *SWGPetApi* | [**findPetsByStatus**](docs/SWGPetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status *SWGPetApi* | [**findPetsByTags**](docs/SWGPetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags *SWGPetApi* | [**getPetById**](docs/SWGPetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID -*SWGPetApi* | [**getPetByIdInObject**](docs/SWGPetApi.md#getpetbyidinobject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -*SWGPetApi* | [**petPetIdtestingByteArraytrueGet**](docs/SWGPetApi.md#petpetidtestingbytearraytrueget) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' *SWGPetApi* | [**updatePet**](docs/SWGPetApi.md#updatepet) | **PUT** /pet | Update an existing pet *SWGPetApi* | [**updatePetWithForm**](docs/SWGPetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *SWGPetApi* | [**uploadFile**](docs/SWGPetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *SWGStoreApi* | [**deleteOrder**](docs/SWGStoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*SWGStoreApi* | [**findOrdersByStatus**](docs/SWGStoreApi.md#findordersbystatus) | **GET** /store/findByStatus | Finds orders by status *SWGStoreApi* | [**getInventory**](docs/SWGStoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status -*SWGStoreApi* | [**getInventoryInObject**](docs/SWGStoreApi.md#getinventoryinobject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' *SWGStoreApi* | [**getOrderById**](docs/SWGStoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID *SWGStoreApi* | [**placeOrder**](docs/SWGStoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet *SWGUserApi* | [**createUser**](docs/SWGUserApi.md#createuser) | **POST** /user | Create user @@ -135,18 +121,9 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [SWG200Response](docs/SWG200Response.md) - - [SWGAnimal](docs/SWGAnimal.md) - - [SWGCat](docs/SWGCat.md) - [SWGCategory](docs/SWGCategory.md) - - [SWGDog](docs/SWGDog.md) - - [SWGFormatTest](docs/SWGFormatTest.md) - - [SWGInlineResponse200](docs/SWGInlineResponse200.md) - - [SWGName](docs/SWGName.md) - [SWGOrder](docs/SWGOrder.md) - [SWGPet](docs/SWGPet.md) - - [SWGReturn](docs/SWGReturn.md) - - [SWGSpecialModelName_](docs/SWGSpecialModelName_.md) - [SWGTag](docs/SWGTag.md) - [SWGUser](docs/SWGUser.md) @@ -154,11 +131,14 @@ Class | Method | HTTP request | Description ## Documentation For Authorization -## test_api_key_header +## petstore_auth -- **Type**: API key -- **API key parameter name**: test_api_key_header -- **Location**: HTTP header +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets ## api_key @@ -166,40 +146,9 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header -## test_http_basic - -- **Type**: HTTP basic authentication - -## test_api_client_secret - -- **Type**: API key -- **API key parameter name**: x-test_api_client_secret -- **Location**: HTTP header - -## test_api_client_id - -- **Type**: API key -- **API key parameter name**: x-test_api_client_id -- **Location**: HTTP header - -## test_api_key_query - -- **Type**: API key -- **API key parameter name**: test_api_key_query -- **Location**: URL query string - -## petstore_auth - -- **Type**: OAuth -- **Flow**: implicit -- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog -- **Scopes**: - - **write:pets**: modify pets in your account - - **read:pets**: read your pets - ## Author -apiteam@swagger.io +apiteam@wordnik.com diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h index af299ff0008..5d40ef2f5f0 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h @@ -12,18 +12,9 @@ * Do not edit the class manually. */ -#import "SWG200Response.h" -#import "SWGAnimal.h" -#import "SWGCat.h" #import "SWGCategory.h" -#import "SWGDog.h" -#import "SWGFormatTest.h" -#import "SWGInlineResponse200.h" -#import "SWGName.h" #import "SWGOrder.h" #import "SWGPet.h" -#import "SWGReturn.h" -#import "SWGSpecialModelName_.h" #import "SWGTag.h" #import "SWGUser.h" @@ -38,6 +29,16 @@ */ extern NSString *const SWGResponseObjectErrorKey; +/** + * A key for deserialization ErrorDomain + */ +extern NSString *const SWGDeserializationErrorDomainKey; + +/** + * Code for deserialization type mismatch error + */ +extern NSInteger const SWGTypeMismatchErrorCode; + /** * Log debug message macro */ @@ -184,8 +185,9 @@ extern NSString *const SWGResponseObjectErrorKey; * * @param data The data will be deserialized. * @param class The type of objective-c object. + * @param error The error */ -- (id) deserialize:(id) data class:(NSString *) class; +- (id) deserialize:(id) data class:(NSString *) class error:(NSError**)error; /** * Logs request and response diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m index 0c8f21d3ae7..ecdf4aaafb2 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m @@ -2,6 +2,10 @@ NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject"; +NSString *const SWGDeserializationErrorDomainKey = @"SWGDeserializationErrorDomainKey"; + +NSInteger const SWGTypeMismatchErrorCode = 143553; + static long requestId = 0; static bool offlineState = false; static NSMutableSet * queuedRequests = nil; @@ -288,13 +292,7 @@ static void (^reachabilityChangeBlock)(int); #pragma mark - Deserialize methods -- (id) deserialize:(id) data class:(NSString *) class { - NSRegularExpression *regexp = nil; - NSTextCheckingResult *match = nil; - NSMutableArray *resultArray = nil; - NSMutableDictionary *resultDict = nil; - NSString *innerType = nil; - +- (id) deserialize:(id) data class:(NSString *) class error:(NSError **) error { // return nil if data is nil or class is nil if (!data || !class) { return nil; @@ -310,6 +308,12 @@ static void (^reachabilityChangeBlock)(int); return data; } + NSRegularExpression *regexp = nil; + NSTextCheckingResult *match = nil; + NSMutableArray *resultArray = nil; + NSMutableDictionary *resultDict = nil; + NSString *innerType = nil; + // list of models NSString *arrayOfModelsPat = @"NSArray<(.+)>"; regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfModelsPat @@ -321,14 +325,25 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { + if(![data isKindOfClass: [NSArray class]]) { + if(error) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : NSLocalizedString(@"Received response is not an array", nil)}; + *error = [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGTypeMismatchErrorCode userInfo:userInfo]; + } + return nil; + } NSArray *dataArray = data; innerType = [class substringWithRange:[match rangeAtIndex:1]]; resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [resultArray addObject:[self deserialize:obj class:innerType]]; + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else { + * stop = YES; } - ]; + }]; return resultArray; } @@ -348,7 +363,12 @@ static void (^reachabilityChangeBlock)(int); resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [resultArray addObject:[self deserialize:obj class:innerType]]; + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else { + * stop = YES; + } }]; return resultArray; @@ -369,7 +389,12 @@ static void (^reachabilityChangeBlock)(int); resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]]; [data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - [resultDict setValue:[self deserialize:obj class:valueType] forKey:key]; + id dicObj = [self deserialize:obj class:valueType error:error]; + if(dicObj) { + [resultDict setValue:dicObj forKey:key]; + } else { + * stop = YES; + } }]; return resultDict; @@ -407,7 +432,7 @@ static void (^reachabilityChangeBlock)(int); // model Class ModelClass = NSClassFromString(class); if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) { - return [[ModelClass alloc] initWithDictionary:data error:nil]; + return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error]; } return nil; @@ -635,7 +660,12 @@ static void (^reachabilityChangeBlock)(int); } else { [self operationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { - completionBlock([self deserialize:data class:responseType], error); + NSError * serializationError; + id response = [self deserialize:data class:responseType error:&serializationError]; + if(!response && !error){ + error = serializationError; + } + completionBlock(response, error); }]; } return requestId; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m index 0e5b36f4a81..c9d80f5c488 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m @@ -122,12 +122,12 @@ - (NSDictionary *) authSettings { return @{ - @"test_api_key_header": + @"petstore_auth": @{ - @"type": @"api_key", + @"type": @"oauth", @"in": @"header", - @"key": @"test_api_key_header", - @"value": [self getApiKeyWithPrefix:@"test_api_key_header"] + @"key": @"Authorization", + @"value": [self getAccessToken] }, @"api_key": @{ @@ -136,41 +136,6 @@ @"key": @"api_key", @"value": [self getApiKeyWithPrefix:@"api_key"] }, - @"test_http_basic": - @{ - @"type": @"basic", - @"in": @"header", - @"key": @"Authorization", - @"value": [self getBasicAuthToken] - }, - @"test_api_client_secret": - @{ - @"type": @"api_key", - @"in": @"header", - @"key": @"x-test_api_client_secret", - @"value": [self getApiKeyWithPrefix:@"x-test_api_client_secret"] - }, - @"test_api_client_id": - @{ - @"type": @"api_key", - @"in": @"header", - @"key": @"x-test_api_client_id", - @"value": [self getApiKeyWithPrefix:@"x-test_api_client_id"] - }, - @"test_api_key_query": - @{ - @"type": @"api_key", - @"in": @"query", - @"key": @"test_api_key_query", - @"value": [self getApiKeyWithPrefix:@"test_api_key_query"] - }, - @"petstore_auth": - @{ - @"type": @"oauth", - @"in": @"header", - @"key": @"Authorization", - @"value": [self getAccessToken] - }, }; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h index aeb69eafa69..577434faae6 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h @@ -16,17 +16,17 @@ @interface SWGInlineResponse200 : SWGObject -@property(nonatomic) NSArray* tags; +@property(nonatomic) NSArray* /* NSString */ photoUrls; + +@property(nonatomic) NSString* name; @property(nonatomic) NSNumber* _id; @property(nonatomic) NSObject* category; + +@property(nonatomic) NSArray* tags; /* pet status in the store [optional] */ @property(nonatomic) NSString* status; -@property(nonatomic) NSString* name; - -@property(nonatomic) NSArray* /* NSString */ photoUrls; - @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m index 5ac2e7b4057..5fbe9ec6ec2 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m @@ -20,7 +20,7 @@ */ + (JSONKeyMapper *)keyMapper { - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"tags": @"tags", @"id": @"_id", @"category": @"category", @"status": @"status", @"name": @"name", @"photoUrls": @"photoUrls" }]; + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"photoUrls": @"photoUrls", @"name": @"name", @"id": @"_id", @"category": @"category", @"tags": @"tags", @"status": @"status" }]; } /** @@ -30,7 +30,7 @@ */ + (BOOL)propertyIsOptional:(NSString *)propertyName { - NSArray *optionalProperties = @[@"tags", @"category", @"status", @"name", @"photoUrls"]; + NSArray *optionalProperties = @[@"photoUrls", @"name", @"category", @"tags", @"status"]; if ([optionalProperties containsObject:propertyName]) { return YES; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h index 7f3abaa3949..ef66979613f 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h @@ -1,6 +1,5 @@ #import #import "SWGPet.h" -#import "SWGInlineResponse200.h" #import "SWGObject.h" #import "SWGApiClient.h" @@ -33,19 +32,6 @@ completionHandler: (void (^)(NSError* error)) handler; -/// -/// -/// Fake endpoint to test byte array in body parameter for adding a new pet to the store -/// -/// -/// @param body Pet object in the form of byte array (optional) -/// -/// -/// @return --(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body - completionHandler: (void (^)(NSError* error)) handler; - - /// /// /// Deletes a pet @@ -64,9 +50,9 @@ /// /// /// Finds Pets by status -/// Multiple status values can be provided with comma separated strings +/// Multiple status values can be provided with comma seperated strings /// -/// @param status Status values that need to be considered for query (optional) (default to available) +/// @param status Status values that need to be considered for filter (optional) (default to available) /// /// /// @return NSArray* @@ -100,32 +86,6 @@ completionHandler: (void (^)(SWGPet* output, NSError* error)) handler; -/// -/// -/// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -/// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions -/// -/// @param petId ID of pet that needs to be fetched -/// -/// -/// @return SWGInlineResponse200* --(NSNumber*) getPetByIdInObjectWithPetId: (NSNumber*) petId - completionHandler: (void (^)(SWGInlineResponse200* output, NSError* error)) handler; - - -/// -/// -/// Fake endpoint to test byte array return by 'Find pet by ID' -/// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions -/// -/// @param petId ID of pet that needs to be fetched -/// -/// -/// @return NSString* --(NSNumber*) petPetIdtestingByteArraytrueGetWithPetId: (NSNumber*) petId - completionHandler: (void (^)(NSString* output, NSError* error)) handler; - - /// /// /// Update an existing pet diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index 8c7959a8c3f..87201064542 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -1,7 +1,6 @@ #import "SWGPetApi.h" #import "SWGQueryParamCollection.h" #import "SWGPet.h" -#import "SWGInlineResponse200.h" @interface SWGPetApi () @@ -132,70 +131,6 @@ static SWGPetApi* singletonAPI = nil; ]; } -/// -/// Fake endpoint to test byte array in body parameter for adding a new pet to the store -/// -/// @param body Pet object in the form of byte array (optional) -/// -/// @returns void -/// --(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body - completionHandler: (void (^)(NSError* error)) handler { - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet?testing_byte_array=true"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; - - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - bodyParam = body; - - return [self.apiClient requestWithPath: resourcePath - method: @"POST" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: nil - completionBlock: ^(id data, NSError *error) { - handler(error); - } - ]; -} - /// /// Deletes a pet /// @@ -277,8 +212,8 @@ static SWGPetApi* singletonAPI = nil; /// /// Finds Pets by status -/// Multiple status values can be provided with comma separated strings -/// @param status Status values that need to be considered for query (optional, default to available) +/// Multiple status values can be provided with comma seperated strings +/// @param status Status values that need to be considered for filter (optional, default to available) /// /// @returns NSArray* /// @@ -456,7 +391,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; + NSArray *authSettings = @[@"petstore_auth", @"api_key"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -480,148 +415,6 @@ static SWGPetApi* singletonAPI = nil; ]; } -/// -/// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -/// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions -/// @param petId ID of pet that needs to be fetched -/// -/// @returns SWGInlineResponse200* -/// --(NSNumber*) getPetByIdInObjectWithPetId: (NSNumber*) petId - completionHandler: (void (^)(SWGInlineResponse200* output, NSError* error)) handler { - // verify the required parameter 'petId' is set - if (petId == nil) { - [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `getPetByIdInObject`"]; - } - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}?response=inline_arbitrary_object"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - if (petId != nil) { - pathParams[@"petId"] = petId; - } - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - return [self.apiClient requestWithPath: resourcePath - method: @"GET" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: @"SWGInlineResponse200*" - completionBlock: ^(id data, NSError *error) { - handler((SWGInlineResponse200*)data, error); - } - ]; -} - -/// -/// Fake endpoint to test byte array return by 'Find pet by ID' -/// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions -/// @param petId ID of pet that needs to be fetched -/// -/// @returns NSString* -/// --(NSNumber*) petPetIdtestingByteArraytrueGetWithPetId: (NSNumber*) petId - completionHandler: (void (^)(NSString* output, NSError* error)) handler { - // verify the required parameter 'petId' is set - if (petId == nil) { - [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `petPetIdtestingByteArraytrueGet`"]; - } - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}?testing_byte_array=true"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - if (petId != nil) { - pathParams[@"petId"] = petId; - } - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - return [self.apiClient requestWithPath: resourcePath - method: @"GET" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: @"NSString*" - completionBlock: ^(id data, NSError *error) { - handler((NSString*)data, error); - } - ]; -} - /// /// Update an existing pet /// diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h index 039f07c8df7..0a7bc70864a 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h @@ -32,19 +32,6 @@ completionHandler: (void (^)(NSError* error)) handler; -/// -/// -/// Finds orders by status -/// A single status value can be provided as a string -/// -/// @param status Status value that needs to be considered for query (optional) (default to placed) -/// -/// -/// @return NSArray* --(NSNumber*) findOrdersByStatusWithStatus: (NSString*) status - completionHandler: (void (^)(NSArray* output, NSError* error)) handler; - - /// /// /// Returns pet inventories by status @@ -57,18 +44,6 @@ (void (^)(NSDictionary* /* NSString, NSNumber */ output, NSError* error)) handler; -/// -/// -/// Fake endpoint to test arbitrary object return by 'Get inventory' -/// Returns an arbitrary object which is actually a map of status codes to quantities -/// -/// -/// -/// @return NSObject* --(NSNumber*) getInventoryInObjectWithCompletionHandler: - (void (^)(NSObject* output, NSError* error)) handler; - - /// /// /// Find purchase order by ID diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m index af0002db3b3..84cd3a699d0 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m @@ -138,72 +138,6 @@ static SWGStoreApi* singletonAPI = nil; ]; } -/// -/// Finds orders by status -/// A single status value can be provided as a string -/// @param status Status value that needs to be considered for query (optional, default to placed) -/// -/// @returns NSArray* -/// --(NSNumber*) findOrdersByStatusWithStatus: (NSString*) status - completionHandler: (void (^)(NSArray* output, NSError* error)) handler { - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/findByStatus"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - if (status != nil) { - queryParams[@"status"] = status; - } - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"test_api_client_id", @"test_api_client_secret"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - return [self.apiClient requestWithPath: resourcePath - method: @"GET" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: @"NSArray*" - completionBlock: ^(id data, NSError *error) { - handler((NSArray*)data, error); - } - ]; -} - /// /// Returns pet inventories by status /// Returns a map of status codes to quantities @@ -265,67 +199,6 @@ static SWGStoreApi* singletonAPI = nil; ]; } -/// -/// Fake endpoint to test arbitrary object return by 'Get inventory' -/// Returns an arbitrary object which is actually a map of status codes to quantities -/// @returns NSObject* -/// --(NSNumber*) getInventoryInObjectWithCompletionHandler: - (void (^)(NSObject* output, NSError* error)) handler { - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/inventory?response=arbitrary_object"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"api_key"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - return [self.apiClient requestWithPath: resourcePath - method: @"GET" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: @"NSObject*" - completionBlock: ^(id data, NSError *error) { - handler((NSObject*)data, error); - } - ]; -} - /// /// Find purchase order by ID /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -373,7 +246,7 @@ static SWGStoreApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"test_api_key_header", @"test_api_key_query"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -436,7 +309,7 @@ static SWGStoreApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"test_api_client_id", @"test_api_client_secret"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m index 71e729ef02c..914d1822402 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m @@ -306,7 +306,7 @@ static SWGUserApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"test_http_basic"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/SwaggerClientTests/Podfile b/samples/client/petstore/objc/SwaggerClientTests/Podfile index ea5cdb0e6e8..22654e6adda 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Podfile +++ b/samples/client/petstore/objc/SwaggerClientTests/Podfile @@ -1,10 +1,10 @@ source 'https://github.com/CocoaPods/Specs.git' -target 'SwaggerClient_Example', :exclusive => true do +target 'SwaggerClient_Example' do pod "SwaggerClient", :path => "../" end -target 'SwaggerClient_Tests', :exclusive => true do +target 'SwaggerClient_Tests' do pod "SwaggerClient", :path => "../" pod 'Specta' diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj index 867a6811293..f7274144997 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj @@ -15,14 +15,15 @@ 6003F59A195388D20070C39A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F599195388D20070C39A /* main.m */; }; 6003F59E195388D20070C39A /* SWGAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F59D195388D20070C39A /* SWGAppDelegate.m */; }; 6003F5A7195388D20070C39A /* SWGViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5A6195388D20070C39A /* SWGViewController.m */; }; - 6003F5A9195388D20070C39A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5A8195388D20070C39A /* Images.xcassets */; }; 6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F5AF195388D20070C39A /* XCTest.framework */; }; 6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; }; 6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; }; - 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; }; 94BE6BE84795B5034A811E61 /* libPods-SwaggerClient_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D46325ECAD48245C07F6733 /* libPods-SwaggerClient_Example.a */; }; + B2ADC17C287DCABF329BA8AC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC7027D4B025ABCA7999F /* Main.storyboard */; }; + B2ADC2D632658A5F73C6CE66 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC65E342ADA697322D68C /* Images.xcassets */; }; + B2ADC56977372855A63F4E4D /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC084A2C0BDF217832B03 /* Launch Screen.storyboard */; }; CF0ADB481B5F95D6008A2729 /* PetTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CF0ADB471B5F95D6008A2729 /* PetTest.m */; }; CF8F71391B5F73AC00162980 /* DeserializationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CF8F71381B5F73AC00162980 /* DeserializationTest.m */; }; CFDFB4121B3CFFA8009739C5 /* UserApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CFDFB40D1B3CFEC3009739C5 /* UserApiTest.m */; }; @@ -56,7 +57,6 @@ 6003F59D195388D20070C39A /* SWGAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SWGAppDelegate.m; sourceTree = ""; }; 6003F5A5195388D20070C39A /* SWGViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SWGViewController.h; sourceTree = ""; }; 6003F5A6195388D20070C39A /* SWGViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SWGViewController.m; sourceTree = ""; }; - 6003F5A8195388D20070C39A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 6003F5AE195388D20070C39A /* SwaggerClient_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwaggerClient_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 6003F5AF195388D20070C39A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 6003F5B7195388D20070C39A /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = ""; }; @@ -64,8 +64,10 @@ 6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; 73CCD82196AABD64F2807C7B /* Pods-SwaggerClient_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwaggerClient_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwaggerClient_Tests/Pods-SwaggerClient_Tests.debug.xcconfig"; sourceTree = ""; }; - 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 8D46325ECAD48245C07F6733 /* libPods-SwaggerClient_Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SwaggerClient_Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B2ADC084A2C0BDF217832B03 /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = "Launch Screen.storyboard"; path = "SwaggerClient/Launch Screen.storyboard"; sourceTree = ""; }; + B2ADC65E342ADA697322D68C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = SwaggerClient/Images.xcassets; sourceTree = ""; }; + B2ADC7027D4B025ABCA7999F /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Main.storyboard; path = SwaggerClient/Main.storyboard; sourceTree = ""; }; BFB4BE760737508B3CFC23B2 /* Pods-SwaggerClient_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwaggerClient_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwaggerClient_Example/Pods-SwaggerClient_Example.release.xcconfig"; sourceTree = ""; }; CF0ADB471B5F95D6008A2729 /* PetTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PetTest.m; sourceTree = ""; }; CF8F71381B5F73AC00162980 /* DeserializationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DeserializationTest.m; sourceTree = ""; }; @@ -121,6 +123,7 @@ children = ( 6003F58A195388D20070C39A /* SwaggerClient_Example.app */, 6003F5AE195388D20070C39A /* SwaggerClient_Tests.xctest */, + B2ADC084A2C0BDF217832B03 /* Launch Screen.storyboard */, ); name = Products; sourceTree = ""; @@ -143,10 +146,8 @@ children = ( 6003F59C195388D20070C39A /* SWGAppDelegate.h */, 6003F59D195388D20070C39A /* SWGAppDelegate.m */, - 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */, 6003F5A5195388D20070C39A /* SWGViewController.h */, 6003F5A6195388D20070C39A /* SWGViewController.m */, - 6003F5A8195388D20070C39A /* Images.xcassets */, 6003F594195388D20070C39A /* Supporting Files */, ); name = "Example for SwaggerClient"; @@ -194,6 +195,8 @@ children = ( E9675D953C6DCDE71A1BDFD4 /* SwaggerClient.podspec */, 4CCE21315897B7D544C83242 /* README.md */, + B2ADC7027D4B025ABCA7999F /* Main.storyboard */, + B2ADC65E342ADA697322D68C /* Images.xcassets */, ); name = "Podspec Metadata"; sourceTree = ""; @@ -287,9 +290,10 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */, - 6003F5A9195388D20070C39A /* Images.xcassets in Resources */, 6003F598195388D20070C39A /* InfoPlist.strings in Resources */, + B2ADC17C287DCABF329BA8AC /* Main.storyboard in Resources */, + B2ADC2D632658A5F73C6CE66 /* Images.xcassets in Resources */, + B2ADC56977372855A63F4E4D /* Launch Screen.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard new file mode 100644 index 00000000000..36df4e16819 --- /dev/null +++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist index d617744f3f4..e21b2835ad7 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist +++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist @@ -2,11 +2,6 @@ - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - CFBundleDevelopmentRegion en CFBundleDisplayName @@ -29,6 +24,13 @@ 1.0 LSRequiresIPhoneOS + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + UILaunchStoryboardName + Launch Screen UIMainStoryboardFile Main UIRequiredDeviceCapabilities diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m index 7b4b348e4d5..5f5d274b4b0 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m @@ -26,9 +26,9 @@ [formatter setTimeZone:timezone]; [formatter setDateFormat:@"yyyy-MM-dd"]; NSDate *date = [formatter dateFromString:dateStr]; - - NSDate *deserializedDate = [apiClient deserialize:dateStr class:@"NSDate*"]; - + NSError* error; + NSDate *deserializedDate = [apiClient deserialize:dateStr class:@"NSDate*" error:&error]; + XCTAssertNil(error); XCTAssertEqualWithAccuracy([date timeIntervalSinceReferenceDate], [deserializedDate timeIntervalSinceReferenceDate], 0.001); } @@ -38,30 +38,33 @@ NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; NSDate *dateTime = [formatter dateFromString:dateTimeStr]; - - NSDate *deserializedDateTime = [apiClient deserialize:dateTimeStr class:@"NSDate*"]; - + NSError* error; + NSDate *deserializedDateTime = [apiClient deserialize:dateTimeStr class:@"NSDate*" error:&error]; + XCTAssertNil(error); XCTAssertEqualWithAccuracy([dateTime timeIntervalSinceReferenceDate], [deserializedDateTime timeIntervalSinceReferenceDate], 0.001); } - (void)testDeserializeObject { NSNumber *data = @1; - NSNumber *result = [apiClient deserialize:data class:@"NSObject*"]; - + NSError* error; + NSNumber *result = [apiClient deserialize:data class:@"NSObject*" error:&error]; + XCTAssertNil(error); XCTAssertEqualObjects(data, result); } - (void)testDeserializeString { NSString *data = @"test string"; - NSString *result = [apiClient deserialize:data class:@"NSString*"]; - + NSError* error; + NSString *result = [apiClient deserialize:data class:@"NSString*" error:&error]; + XCTAssertNil(error); XCTAssertTrue([result isEqualToString:data]); } - (void)testDeserializeListOfString { NSArray *data = @[@"test string"]; - NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSString */"]; - + NSError* error; + NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSString */" error:&error]; + XCTAssertNil(error); XCTAssertTrue([result isKindOfClass:[NSArray class]]); XCTAssertTrue([result[0] isKindOfClass:[NSString class]]); } @@ -88,8 +91,8 @@ @"status": @"available" }]; - - NSArray *result = [apiClient deserialize:data class:@"NSArray*"]; + NSError* error; + NSArray *result = [apiClient deserialize:data class:@"NSArray*" error:&error]; XCTAssertTrue([result isKindOfClass:[NSArray class]]); XCTAssertTrue([[result firstObject] isKindOfClass:[SWGPet class]]); @@ -119,8 +122,8 @@ } }; - - NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, SWGPet */"]; + NSError* error; + NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, SWGPet */" error:&error]; XCTAssertTrue([result isKindOfClass:[NSDictionary class]]); XCTAssertTrue([result[@"pet"] isKindOfClass:[SWGPet class]]); @@ -134,8 +137,8 @@ @"bar": @1 } }; - - NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, NSDictionary* /* NSString, NSNumber */ */"]; + NSError* error; + NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, NSDictionary* /* NSString, NSNumber */ */" error:&error]; XCTAssertTrue([result isKindOfClass:[NSDictionary class]]); XCTAssertTrue([result[@"foo"] isKindOfClass:[NSDictionary class]]); @@ -144,8 +147,8 @@ - (void)testDeserializeNestedList { NSArray *data = @[@[@"foo"]]; - - NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSArray* /* NSString */ */"]; + NSError* error; + NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSArray* /* NSString */ */" error:&error]; XCTAssertTrue([result isKindOfClass:[NSArray class]]); XCTAssertTrue([result[0] isKindOfClass:[NSArray class]]); @@ -157,11 +160,12 @@ NSNumber *result; data = @"true"; - result = [apiClient deserialize:data class:@"NSNumber*"]; + NSError* error; + result = [apiClient deserialize:data class:@"NSNumber*" error:&error]; XCTAssertTrue([result isEqual:@YES]); data = @"false"; - result = [apiClient deserialize:data class:@"NSNumber*"]; + result = [apiClient deserialize:data class:@"NSNumber*" error:&error]; XCTAssertTrue([result isEqual:@NO]); } diff --git a/samples/client/petstore/objc/docs/SWGCategory.md b/samples/client/petstore/objc/docs/SWGCategory.md new file mode 100644 index 00000000000..93a8d14ecb9 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGCategory.md @@ -0,0 +1,11 @@ +# SWGCategory + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | **NSNumber*** | | [optional] +**name** | **NSString*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGOrder.md b/samples/client/petstore/objc/docs/SWGOrder.md new file mode 100644 index 00000000000..b2a9f25eae9 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGOrder.md @@ -0,0 +1,15 @@ +# SWGOrder + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | **NSNumber*** | | [optional] +**petId** | **NSNumber*** | | [optional] +**quantity** | **NSNumber*** | | [optional] +**shipDate** | **NSDate*** | | [optional] +**status** | **NSString*** | Order Status | [optional] +**complete** | **NSNumber*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGPet.md b/samples/client/petstore/objc/docs/SWGPet.md new file mode 100644 index 00000000000..6c7286531f9 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGPet.md @@ -0,0 +1,15 @@ +# SWGPet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | **NSNumber*** | | [optional] +**category** | [**SWGCategory***](SWGCategory.md) | | [optional] +**name** | **NSString*** | | +**photoUrls** | **NSArray* /* NSString */** | | +**tags** | [**NSArray<SWGTag>***](SWGTag.md) | | [optional] +**status** | **NSString*** | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGPetApi.md b/samples/client/petstore/objc/docs/SWGPetApi.md new file mode 100644 index 00000000000..78a54942c2f --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGPetApi.md @@ -0,0 +1,530 @@ +# SWGPetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](SWGPetApi.md#addpet) | **POST** /pet | Add a new pet to the store +[**deletePet**](SWGPetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](SWGPetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](SWGPetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](SWGPetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](SWGPetApi.md#updatepet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](SWGPetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](SWGPetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **addPet** +```objc +-(NSNumber*) addPetWithBody: (SWGPet*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Add a new pet to the store + + + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +SWGPet* body = [[SWGPet alloc] init]; // Pet object that needs to be added to the store (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Add a new pet to the store + [apiInstance addPetWithBody:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->addPet: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**SWGPet***](SWGPet*.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **deletePet** +```objc +-(NSNumber*) deletePetWithPetId: (NSNumber*) petId + apiKey: (NSString*) apiKey + completionHandler: (void (^)(NSError* error)) handler; +``` + +Deletes a pet + + + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +NSNumber* petId = @789; // Pet id to delete +NSString* apiKey = @"apiKey_example"; // (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Deletes a pet + [apiInstance deletePetWithPetId:petId + apiKey:apiKey + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->deletePet: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **NSNumber***| Pet id to delete | + **apiKey** | **NSString***| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **findPetsByStatus** +```objc +-(NSNumber*) findPetsByStatusWithStatus: (NSArray* /* NSString */) status + completionHandler: (void (^)(NSArray* output, NSError* error)) handler; +``` + +Finds Pets by status + +Multiple status values can be provided with comma seperated strings + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +NSArray* /* NSString */ status = @[@"available"]; // Status values that need to be considered for filter (optional) (default to available) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Finds Pets by status + [apiInstance findPetsByStatusWithStatus:status + completionHandler: ^(NSArray* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->findPetsByStatus: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**NSArray* /* NSString */**](NSString*.md)| Status values that need to be considered for filter | [optional] [default to available] + +### Return type + +[**NSArray***](SWGPet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **findPetsByTags** +```objc +-(NSNumber*) findPetsByTagsWithTags: (NSArray* /* NSString */) tags + completionHandler: (void (^)(NSArray* output, NSError* error)) handler; +``` + +Finds Pets by tags + +Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +NSArray* /* NSString */ tags = @[@"tags_example"]; // Tags to filter by (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Finds Pets by tags + [apiInstance findPetsByTagsWithTags:tags + completionHandler: ^(NSArray* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->findPetsByTags: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**NSArray* /* NSString */**](NSString*.md)| Tags to filter by | [optional] + +### Return type + +[**NSArray***](SWGPet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getPetById** +```objc +-(NSNumber*) getPetByIdWithPetId: (NSNumber*) petId + completionHandler: (void (^)(SWGPet* output, NSError* error)) handler; +``` + +Find pet by ID + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + +// Configure API key authorization: (authentication scheme: api_key) +[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"]; +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +//[apiConfig setApiKeyPrefix:@"BEARER" forApiKeyIdentifier:@"api_key"]; + + +NSNumber* petId = @789; // ID of pet that needs to be fetched + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Find pet by ID + [apiInstance getPetByIdWithPetId:petId + completionHandler: ^(SWGPet* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->getPetById: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **NSNumber***| ID of pet that needs to be fetched | + +### Return type + +[**SWGPet***](SWGPet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updatePet** +```objc +-(NSNumber*) updatePetWithBody: (SWGPet*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Update an existing pet + + + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +SWGPet* body = [[SWGPet alloc] init]; // Pet object that needs to be added to the store (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Update an existing pet + [apiInstance updatePetWithBody:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->updatePet: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**SWGPet***](SWGPet*.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updatePetWithForm** +```objc +-(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId + name: (NSString*) name + status: (NSString*) status + completionHandler: (void (^)(NSError* error)) handler; +``` + +Updates a pet in the store with form data + + + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +NSString* petId = @"petId_example"; // ID of pet that needs to be updated +NSString* name = @"name_example"; // Updated name of the pet (optional) +NSString* status = @"status_example"; // Updated status of the pet (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Updates a pet in the store with form data + [apiInstance updatePetWithFormWithPetId:petId + name:name + status:status + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->updatePetWithForm: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **NSString***| ID of pet that needs to be updated | + **name** | **NSString***| Updated name of the pet | [optional] + **status** | **NSString***| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **uploadFile** +```objc +-(NSNumber*) uploadFileWithPetId: (NSNumber*) petId + additionalMetadata: (NSString*) additionalMetadata + file: (NSURL*) file + completionHandler: (void (^)(NSError* error)) handler; +``` + +uploads an image + + + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +NSNumber* petId = @789; // ID of pet to update +NSString* additionalMetadata = @"additionalMetadata_example"; // Additional data to pass to server (optional) +NSURL* file = [NSURL fileURLWithPath:@"/path/to/file.txt"]; // file to upload (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // uploads an image + [apiInstance uploadFileWithPetId:petId + additionalMetadata:additionalMetadata + file:file + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->uploadFile: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **NSNumber***| ID of pet to update | + **additionalMetadata** | **NSString***| Additional data to pass to server | [optional] + **file** | **NSURL***| file to upload | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/objc/docs/SWGStoreApi.md b/samples/client/petstore/objc/docs/SWGStoreApi.md new file mode 100644 index 00000000000..1eacf83431a --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGStoreApi.md @@ -0,0 +1,244 @@ +# SWGStoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](SWGStoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**getInventory**](SWGStoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](SWGStoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +[**placeOrder**](SWGStoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet + + +# **deleteOrder** +```objc +-(NSNumber*) deleteOrderWithOrderId: (NSString*) orderId + completionHandler: (void (^)(NSError* error)) handler; +``` + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```objc + +NSString* orderId = @"orderId_example"; // ID of the order that needs to be deleted + +@try +{ + SWGStoreApi *apiInstance = [[SWGStoreApi alloc] init]; + + // Delete purchase order by ID + [apiInstance deleteOrderWithOrderId:orderId + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGStoreApi->deleteOrder: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **NSString***| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getInventory** +```objc +-(NSNumber*) getInventoryWithCompletionHandler: + (void (^)(NSDictionary* /* NSString, NSNumber */ output, NSError* error)) handler; +``` + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure API key authorization: (authentication scheme: api_key) +[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"]; +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +//[apiConfig setApiKeyPrefix:@"BEARER" forApiKeyIdentifier:@"api_key"]; + + + +@try +{ + SWGStoreApi *apiInstance = [[SWGStoreApi alloc] init]; + + // Returns pet inventories by status + [apiInstance getInventoryWithCompletionHandler: + ^(NSDictionary* /* NSString, NSNumber */ output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGStoreApi->getInventory: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**NSDictionary* /* NSString, NSNumber */**](NSDictionary.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getOrderById** +```objc +-(NSNumber*) getOrderByIdWithOrderId: (NSString*) orderId + completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler; +``` + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```objc + +NSString* orderId = @"orderId_example"; // ID of pet that needs to be fetched + +@try +{ + SWGStoreApi *apiInstance = [[SWGStoreApi alloc] init]; + + // Find purchase order by ID + [apiInstance getOrderByIdWithOrderId:orderId + completionHandler: ^(SWGOrder* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGStoreApi->getOrderById: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **NSString***| ID of pet that needs to be fetched | + +### Return type + +[**SWGOrder***](SWGOrder.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **placeOrder** +```objc +-(NSNumber*) placeOrderWithBody: (SWGOrder*) body + completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler; +``` + +Place an order for a pet + + + +### Example +```objc + +SWGOrder* body = [[SWGOrder alloc] init]; // order placed for purchasing the pet (optional) + +@try +{ + SWGStoreApi *apiInstance = [[SWGStoreApi alloc] init]; + + // Place an order for a pet + [apiInstance placeOrderWithBody:body + completionHandler: ^(SWGOrder* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGStoreApi->placeOrder: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**SWGOrder***](SWGOrder*.md)| order placed for purchasing the pet | [optional] + +### Return type + +[**SWGOrder***](SWGOrder.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/objc/docs/SWGTag.md b/samples/client/petstore/objc/docs/SWGTag.md new file mode 100644 index 00000000000..5495d5c8a99 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGTag.md @@ -0,0 +1,11 @@ +# SWGTag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | **NSNumber*** | | [optional] +**name** | **NSString*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGUser.md b/samples/client/petstore/objc/docs/SWGUser.md new file mode 100644 index 00000000000..35bf5540cad --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGUser.md @@ -0,0 +1,17 @@ +# SWGUser + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | **NSNumber*** | | [optional] +**username** | **NSString*** | | [optional] +**firstName** | **NSString*** | | [optional] +**lastName** | **NSString*** | | [optional] +**email** | **NSString*** | | [optional] +**password** | **NSString*** | | [optional] +**phone** | **NSString*** | | [optional] +**userStatus** | **NSNumber*** | User Status | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGUserApi.md b/samples/client/petstore/objc/docs/SWGUserApi.md new file mode 100644 index 00000000000..4fe7a25bccf --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGUserApi.md @@ -0,0 +1,466 @@ +# SWGUserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](SWGUserApi.md#createuser) | **POST** /user | Create user +[**createUsersWithArrayInput**](SWGUserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](SWGUserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](SWGUserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](SWGUserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +[**loginUser**](SWGUserApi.md#loginuser) | **GET** /user/login | Logs user into the system +[**logoutUser**](SWGUserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](SWGUserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +# **createUser** +```objc +-(NSNumber*) createUserWithBody: (SWGUser*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Create user + +This can only be done by the logged in user. + +### Example +```objc + +SWGUser* body = [[SWGUser alloc] init]; // Created user object (optional) + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Create user + [apiInstance createUserWithBody:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->createUser: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**SWGUser***](SWGUser*.md)| Created user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **createUsersWithArrayInput** +```objc +-(NSNumber*) createUsersWithArrayInputWithBody: (NSArray*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Creates list of users with given input array + + + +### Example +```objc + +NSArray* body = @[[[SWGUser alloc] init]]; // List of user object (optional) + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Creates list of users with given input array + [apiInstance createUsersWithArrayInputWithBody:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->createUsersWithArrayInput: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**NSArray<SWGUser>***](SWGUser.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **createUsersWithListInput** +```objc +-(NSNumber*) createUsersWithListInputWithBody: (NSArray*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Creates list of users with given input array + + + +### Example +```objc + +NSArray* body = @[[[SWGUser alloc] init]]; // List of user object (optional) + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Creates list of users with given input array + [apiInstance createUsersWithListInputWithBody:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->createUsersWithListInput: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**NSArray<SWGUser>***](SWGUser.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **deleteUser** +```objc +-(NSNumber*) deleteUserWithUsername: (NSString*) username + completionHandler: (void (^)(NSError* error)) handler; +``` + +Delete user + +This can only be done by the logged in user. + +### Example +```objc + +NSString* username = @"username_example"; // The name that needs to be deleted + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Delete user + [apiInstance deleteUserWithUsername:username + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->deleteUser: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **NSString***| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getUserByName** +```objc +-(NSNumber*) getUserByNameWithUsername: (NSString*) username + completionHandler: (void (^)(SWGUser* output, NSError* error)) handler; +``` + +Get user by user name + + + +### Example +```objc + +NSString* username = @"username_example"; // The name that needs to be fetched. Use user1 for testing. + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Get user by user name + [apiInstance getUserByNameWithUsername:username + completionHandler: ^(SWGUser* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->getUserByName: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **NSString***| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**SWGUser***](SWGUser.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **loginUser** +```objc +-(NSNumber*) loginUserWithUsername: (NSString*) username + password: (NSString*) password + completionHandler: (void (^)(NSString* output, NSError* error)) handler; +``` + +Logs user into the system + + + +### Example +```objc + +NSString* username = @"username_example"; // The user name for login (optional) +NSString* password = @"password_example"; // The password for login in clear text (optional) + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Logs user into the system + [apiInstance loginUserWithUsername:username + password:password + completionHandler: ^(NSString* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->loginUser: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **NSString***| The user name for login | [optional] + **password** | **NSString***| The password for login in clear text | [optional] + +### Return type + +**NSString*** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **logoutUser** +```objc +-(NSNumber*) logoutUserWithCompletionHandler: + (void (^)(NSError* error)) handler; +``` + +Logs out current logged in user session + + + +### Example +```objc + + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Logs out current logged in user session + [apiInstance logoutUserWithCompletionHandler: + ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->logoutUser: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updateUser** +```objc +-(NSNumber*) updateUserWithUsername: (NSString*) username + body: (SWGUser*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Updated user + +This can only be done by the logged in user. + +### Example +```objc + +NSString* username = @"username_example"; // name that need to be deleted +SWGUser* body = [[SWGUser alloc] init]; // Updated user object (optional) + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Updated user + [apiInstance updateUserWithUsername:username + body:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->updateUser: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **NSString***| name that need to be deleted | + **body** | [**SWGUser***](SWGUser*.md)| Updated user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index ac92e7daa21..80e8d1bae7a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-19T21:31:44.449+02:00 +- Build date: 2016-04-23T22:48:00.795+08:00 - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements @@ -122,6 +122,12 @@ Class | Method | HTTP request | Description ## Documentation For Authorization +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ## petstore_auth - **Type**: OAuth @@ -131,12 +137,6 @@ Class | Method | HTTP request | Description - **write:pets**: modify pets in your account - **read:pets**: read your pets -## api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ## Author diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/FormatTest.md b/samples/client/petstore/php/SwaggerClient-php/docs/FormatTest.md index e0598317f5e..e043ee8d2b8 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/FormatTest.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/FormatTest.md @@ -10,11 +10,11 @@ Name | Type | Description | Notes **float** | **float** | | [optional] **double** | **double** | | [optional] **string** | **string** | | [optional] -**byte** | **string** | | [optional] +**byte** | **string** | | **binary** | **string** | | [optional] -**date** | [**\DateTime**](Date.md) | | [optional] +**date** | [**\DateTime**](Date.md) | | **date_time** | [**\DateTime**](\DateTime.md) | | [optional] -**password** | **string** | | [optional] +**password** | **string** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Name.md b/samples/client/petstore/php/SwaggerClient-php/docs/Name.md index 905680a7d30..5f31a2cc7fd 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Name.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Name.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **int** | | **snake_case** | **int** | | [optional] +**property** | **string** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php index c44cda7b709..9e1c4b92762 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php @@ -58,7 +58,8 @@ class Name implements ArrayAccess */ static $swaggerTypes = array( 'name' => 'int', - 'snake_case' => 'int' + 'snake_case' => 'int', + 'property' => 'string' ); static function swaggerTypes() { @@ -71,7 +72,8 @@ class Name implements ArrayAccess */ static $attributeMap = array( 'name' => 'name', - 'snake_case' => 'snake_case' + 'snake_case' => 'snake_case', + 'property' => 'property' ); static function attributeMap() { @@ -84,7 +86,8 @@ class Name implements ArrayAccess */ static $setters = array( 'name' => 'setName', - 'snake_case' => 'setSnakeCase' + 'snake_case' => 'setSnakeCase', + 'property' => 'setProperty' ); static function setters() { @@ -97,7 +100,8 @@ class Name implements ArrayAccess */ static $getters = array( 'name' => 'getName', - 'snake_case' => 'getSnakeCase' + 'snake_case' => 'getSnakeCase', + 'property' => 'getProperty' ); static function getters() { @@ -114,6 +118,11 @@ class Name implements ArrayAccess * @var int */ protected $snake_case; + /** + * $property + * @var string + */ + protected $property; /** * Constructor @@ -126,6 +135,7 @@ class Name implements ArrayAccess if ($data != null) { $this->name = $data["name"]; $this->snake_case = $data["snake_case"]; + $this->property = $data["property"]; } } /** @@ -168,6 +178,26 @@ class Name implements ArrayAccess $this->snake_case = $snake_case; return $this; } + /** + * Gets property + * @return string + */ + public function getProperty() + { + return $this->property; + } + + /** + * Sets property + * @param string $property + * @return $this + */ + public function setProperty($property) + { + + $this->property = $property; + return $this; + } /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index ac63c18fbd5..3adaa899f5f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -256,7 +256,7 @@ class ObjectSerializer } else { return null; } - } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) { + } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { settype($data, $class); return $data; } elseif ($class === '\SplFileObject') { diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 79eef580326..851c5458cb1 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https:// - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-20T22:11:45.927+08:00 +- Build date: 2016-04-27T17:36:32.266+08:00 - Build package: class io.swagger.codegen.languages.PythonClientCodegen ## Requirements. @@ -50,18 +50,26 @@ import time import swagger_client from swagger_client.rest import ApiException from pprint import pprint - -# Configure OAuth2 access token for authorization: petstore_auth -swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' # create an instance of the API class -api_instance = swagger_client.PetApi -body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store +api_instance = swagger_client.FakeApi +number = 3.4 # float | None +double = 1.2 # float | None +string = 'string_example' # str | None +byte = 'B' # str | None +integer = 56 # int | None (optional) +int32 = 56 # int | None (optional) +int64 = 789 # int | None (optional) +float = 3.4 # float | None (optional) +binary = 'B' # str | None (optional) +date = '2013-10-20' # date | None (optional) +date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional) +password = 'password_example' # str | None (optional) try: - # Add a new pet to the store - api_instance.add_pet(body) + # Fake endpoint for testing various parameters + api_instance.test_endpoint_parameters(number, double, string, byte, integer=integer, int32=int32, int64=int64, float=float, binary=binary, date=date, date_time=date_time, password=password) except ApiException as e: - print "Exception when calling PetApi->add_pet: %s\n" % e + print "Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e ``` @@ -71,6 +79,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status diff --git a/samples/client/petstore/python/docs/FormatTest.md b/samples/client/petstore/python/docs/FormatTest.md index 4182a447086..3e489e863fa 100644 --- a/samples/client/petstore/python/docs/FormatTest.md +++ b/samples/client/petstore/python/docs/FormatTest.md @@ -10,11 +10,12 @@ Name | Type | Description | Notes **float** | **float** | | [optional] **double** | **float** | | [optional] **string** | **str** | | [optional] -**byte** | **str** | | [optional] +**byte** | **str** | | **binary** | **str** | | [optional] -**date** | **date** | | [optional] +**date** | **date** | | **date_time** | **datetime** | | [optional] -**password** | **str** | | [optional] +**uuid** | **str** | | [optional] +**password** | **str** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index 2169ecd37e7..783f8b9713a 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -17,6 +17,7 @@ from .models.tag import Tag from .models.user import User # import apis into sdk package +from .apis.fake_api import FakeApi from .apis.pet_api import PetApi from .apis.store_api import StoreApi from .apis.user_api import UserApi diff --git a/samples/client/petstore/python/swagger_client/apis/__init__.py b/samples/client/petstore/python/swagger_client/apis/__init__.py index a3a12ea9ac1..ddde8c164bf 100644 --- a/samples/client/petstore/python/swagger_client/apis/__init__.py +++ b/samples/client/petstore/python/swagger_client/apis/__init__.py @@ -1,6 +1,7 @@ from __future__ import absolute_import # import apis into api package +from .fake_api import FakeApi from .pet_api import PetApi from .store_api import StoreApi from .user_api import UserApi diff --git a/samples/client/petstore/python/swagger_client/models/format_test.py b/samples/client/petstore/python/swagger_client/models/format_test.py index 8654d79bc3c..28f348edf04 100644 --- a/samples/client/petstore/python/swagger_client/models/format_test.py +++ b/samples/client/petstore/python/swagger_client/models/format_test.py @@ -48,6 +48,7 @@ class FormatTest(object): 'binary': 'str', 'date': 'date', 'date_time': 'datetime', + 'uuid': 'str', 'password': 'str' } @@ -63,6 +64,7 @@ class FormatTest(object): 'binary': 'binary', 'date': 'date', 'date_time': 'dateTime', + 'uuid': 'uuid', 'password': 'password' } @@ -77,6 +79,7 @@ class FormatTest(object): self._binary = None self._date = None self._date_time = None + self._uuid = None self._password = None @property @@ -321,6 +324,28 @@ class FormatTest(object): """ self._date_time = date_time + @property + def uuid(self): + """ + Gets the uuid of this FormatTest. + + + :return: The uuid of this FormatTest. + :rtype: str + """ + return self._uuid + + @uuid.setter + def uuid(self, uuid): + """ + Sets the uuid of this FormatTest. + + + :param uuid: The uuid of this FormatTest. + :type: str + """ + self._uuid = uuid + @property def password(self): """ diff --git a/samples/client/petstore/ruby/Gemfile.lock b/samples/client/petstore/ruby/Gemfile.lock index 98c02ee9163..cb8128052ab 100644 --- a/samples/client/petstore/ruby/Gemfile.lock +++ b/samples/client/petstore/ruby/Gemfile.lock @@ -22,29 +22,31 @@ GEM ethon (0.8.1) ffi (>= 1.3.0) ffi (1.9.8) + hashdiff (0.3.0) json (1.8.3) - rspec (3.2.0) - rspec-core (~> 3.2.0) - rspec-expectations (~> 3.2.0) - rspec-mocks (~> 3.2.0) - rspec-core (3.2.2) - rspec-support (~> 3.2.0) - rspec-expectations (3.2.0) + rspec (3.4.0) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-core (3.4.4) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-mocks (3.2.1) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-support (3.2.2) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) safe_yaml (1.0.4) sys-uname (0.9.2) ffi (>= 1.0.0) typhoeus (1.0.1) ethon (>= 0.8.0) - vcr (2.9.3) - webmock (1.21.0) + vcr (3.0.1) + webmock (1.24.5) addressable (>= 2.3.6) crack (>= 0.3.2) + hashdiff PLATFORMS ruby @@ -55,6 +57,6 @@ DEPENDENCIES autotest-growl (~> 0.2, >= 0.2.16) autotest-rails-pure (~> 4.1, >= 4.1.2) petstore! - rspec (~> 3.2, >= 3.2.0) - vcr (~> 2.9, >= 2.9.3) - webmock (~> 1.6, >= 1.6.2) + rspec (~> 3.4, >= 3.4.0) + vcr (~> 3.0, >= 3.0.1) + webmock (~> 1.24, >= 1.24.3) diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 4dc28289fa3..cab06a92ce1 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-20T18:46:00.664+08:00 +- Build date: 2016-04-26T10:05:22.048-07:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -26,6 +26,7 @@ Then either install the gem locally: ```shell gem install ./petstore-1.0.0.gem ``` +(for development, run `gem install --dev ./petstore-1.0.0.gem` to install the development dependencies) or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). @@ -54,22 +55,32 @@ Please follow the [installation](#installation) procedure and then run the follo # Load the gem require 'petstore' -# Setup authorization -Petstore.configure do |config| - # Configure OAuth2 access token for authorization: petstore_auth - config.access_token = 'YOUR ACCESS TOKEN' -end +api_instance = Petstore::FakeApi.new -api_instance = Petstore::PetApi.new +number = "number_example" # String | None -body = Petstore::Pet.new # Pet | Pet object that needs to be added to the store +double = 1.2 # Float | None +string = "string_example" # String | None + +byte = "B" # String | None + +opts = { + integer: 56, # Integer | None + int32: 56, # Integer | None + int64: 789, # Integer | None + float: 3.4, # Float | None + binary: "B", # String | None + date: Date.parse("2013-10-20"), # Date | None + date_time: DateTime.parse("2013-10-20T19:20:30+01:00"), # DateTime | None + password: "password_example" # String | None +} begin - #Add a new pet to the store - api_instance.add_pet(body) + #Fake endpoint for testing various parameters + api_instance.test_endpoint_parameters(number, double, string, byte, opts) rescue Petstore::ApiError => e - puts "Exception when calling PetApi->add_pet: #{e}" + puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}" end ``` @@ -80,6 +91,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*Petstore::FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters *Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *Petstore::PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet *Petstore::PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status diff --git a/samples/client/petstore/ruby/docs/FakeApi.md b/samples/client/petstore/ruby/docs/FakeApi.md new file mode 100644 index 00000000000..a7c0b42a475 --- /dev/null +++ b/samples/client/petstore/ruby/docs/FakeApi.md @@ -0,0 +1,82 @@ +# Petstore::FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters + + +# **test_endpoint_parameters** +> test_endpoint_parameters(number, double, string, byte, opts) + +Fake endpoint for testing various parameters + +Fake endpoint for testing various parameters + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new + +number = "number_example" # String | None + +double = 1.2 # Float | None + +string = "string_example" # String | None + +byte = "B" # String | None + +opts = { + integer: 56, # Integer | None + int32: 56, # Integer | None + int64: 789, # Integer | None + float: 3.4, # Float | None + binary: "B", # String | None + date: Date.parse("2013-10-20"), # Date | None + date_time: DateTime.parse("2013-10-20T19:20:30+01:00"), # DateTime | None + password: "password_example" # String | None +} + +begin + #Fake endpoint for testing various parameters + api_instance.test_endpoint_parameters(number, double, string, byte, opts) +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **String**| None | + **double** | **Float**| None | + **string** | **String**| None | + **byte** | **String**| None | + **integer** | **Integer**| None | [optional] + **int32** | **Integer**| None | [optional] + **int64** | **Integer**| None | [optional] + **float** | **Float**| None | [optional] + **binary** | **String**| None | [optional] + **date** | **Date**| None | [optional] + **date_time** | **DateTime**| None | [optional] + **password** | **String**| None | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + + diff --git a/samples/client/petstore/ruby/docs/FormatTest.md b/samples/client/petstore/ruby/docs/FormatTest.md index 2b64ed317b2..7197a7a6584 100644 --- a/samples/client/petstore/ruby/docs/FormatTest.md +++ b/samples/client/petstore/ruby/docs/FormatTest.md @@ -10,10 +10,10 @@ Name | Type | Description | Notes **float** | **Float** | | [optional] **double** | **Float** | | [optional] **string** | **String** | | [optional] -**byte** | **String** | | [optional] +**byte** | **String** | | **binary** | **String** | | [optional] -**date** | **Date** | | [optional] +**date** | **Date** | | **date_time** | **DateTime** | | [optional] -**password** | **String** | | [optional] +**password** | **String** | | diff --git a/samples/client/petstore/ruby/docs/Name.md b/samples/client/petstore/ruby/docs/Name.md index 2864a67fbd3..4858862c725 100644 --- a/samples/client/petstore/ruby/docs/Name.md +++ b/samples/client/petstore/ruby/docs/Name.md @@ -5,5 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | **snake_case** | **Integer** | | [optional] +**property** | **String** | | [optional] diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index 5964a522d9f..f203db3f5ba 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -37,6 +37,7 @@ require 'petstore/models/tag' require 'petstore/models/user' # APIs +require 'petstore/api/fake_api' require 'petstore/api/pet_api' require 'petstore/api/store_api' require 'petstore/api/user_api' diff --git a/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb new file mode 100644 index 00000000000..a0cf2913f43 --- /dev/null +++ b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb @@ -0,0 +1,171 @@ +=begin +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require "uri" + +module Petstore + class FakeApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + + # Fake endpoint for testing various parameters + # Fake endpoint for testing various parameters + # @param number None + # @param double None + # @param string None + # @param byte None + # @param [Hash] opts the optional parameters + # @option opts [Integer] :integer None + # @option opts [Integer] :int32 None + # @option opts [Integer] :int64 None + # @option opts [Float] :float None + # @option opts [String] :binary None + # @option opts [Date] :date None + # @option opts [DateTime] :date_time None + # @option opts [String] :password None + # @return [nil] + def test_endpoint_parameters(number, double, string, byte, opts = {}) + test_endpoint_parameters_with_http_info(number, double, string, byte, opts) + return nil + end + + # Fake endpoint for testing various parameters + # Fake endpoint for testing various parameters + # @param number None + # @param double None + # @param string None + # @param byte None + # @param [Hash] opts the optional parameters + # @option opts [Integer] :integer None + # @option opts [Integer] :int32 None + # @option opts [Integer] :int64 None + # @option opts [Float] :float None + # @option opts [String] :binary None + # @option opts [Date] :date None + # @option opts [DateTime] :date_time None + # @option opts [String] :password None + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def test_endpoint_parameters_with_http_info(number, double, string, byte, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: FakeApi.test_endpoint_parameters ..." + end + # verify the required parameter 'number' is set + fail ArgumentError, "Missing the required parameter 'number' when calling FakeApi.test_endpoint_parameters" if number.nil? + if number > 543.2 + fail ArgumentError, 'invalid value for "number" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 543.2.' + end + + if number < 32.1 + fail ArgumentError, 'invalid value for "number" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 32.1.' + end + + # verify the required parameter 'double' is set + fail ArgumentError, "Missing the required parameter 'double' when calling FakeApi.test_endpoint_parameters" if double.nil? + if double > 123.4 + fail ArgumentError, 'invalid value for "double" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 123.4.' + end + + if double < 67.8 + fail ArgumentError, 'invalid value for "double" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 67.8.' + end + + # verify the required parameter 'string' is set + fail ArgumentError, "Missing the required parameter 'string' when calling FakeApi.test_endpoint_parameters" if string.nil? + if string !~ Regexp.new(/[a-z]/i) + fail ArgumentError, 'invalid value for "string" when calling FakeApi.test_endpoint_parameters, must conform to the pattern /[a-z]/i.' + end + + # verify the required parameter 'byte' is set + fail ArgumentError, "Missing the required parameter 'byte' when calling FakeApi.test_endpoint_parameters" if byte.nil? + if opts[:'integer'] > 100.0 + fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 100.0.' + end + + if opts[:'integer'] < 10.0 + fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 10.0.' + end + + if opts[:'int32'] > 200.0 + fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 200.0.' + end + + if opts[:'int32'] < 20.0 + fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 20.0.' + end + + if opts[:'float'] > 987.6 + fail ArgumentError, 'invalid value for "opts[:"float"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 987.6.' + end + + if opts[:'password'].to_s.length > 64 + fail ArgumentError, 'invalid value for "opts[:"password"]" when calling FakeApi.test_endpoint_parameters, the character length must be smaller than or equal to 64.' + end + + if opts[:'password'].to_s.length < 10 + fail ArgumentError, 'invalid value for "opts[:"password"]" when calling FakeApi.test_endpoint_parameters, the character length must be great than or equal to 10.' + end + + # resource path + local_var_path = "/fake".sub('{format}','json') + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + local_header_accept = ['application/xml', 'application/json'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result + + # HTTP header 'Content-Type' + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) + + # form parameters + form_params = {} + form_params["number"] = number + form_params["double"] = double + form_params["string"] = string + form_params["byte"] = byte + form_params["integer"] = opts[:'integer'] if opts[:'integer'] + form_params["int32"] = opts[:'int32'] if opts[:'int32'] + form_params["int64"] = opts[:'int64'] if opts[:'int64'] + form_params["float"] = opts[:'float'] if opts[:'float'] + form_params["binary"] = opts[:'binary'] if opts[:'binary'] + form_params["date"] = opts[:'date'] if opts[:'date'] + form_params["dateTime"] = opts[:'date_time'] if opts[:'date_time'] + form_params["password"] = opts[:'password'] if opts[:'password'] + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_endpoint_parameters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index 4355642fc58..7e4121d5120 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -41,12 +41,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def add_pet_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#add_pet ..." + @api_client.config.logger.debug "Calling API: PetApi.add_pet ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling add_pet" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling PetApi.add_pet" if body.nil? # resource path local_var_path = "/pet".sub('{format}','json') @@ -101,12 +99,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_pet_with_http_info(pet_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#delete_pet ..." + @api_client.config.logger.debug "Calling API: PetApi.delete_pet ..." end - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil? - + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet" if pet_id.nil? # resource path local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) @@ -160,12 +156,10 @@ module Petstore # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def find_pets_by_status_with_http_info(status, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#find_pets_by_status ..." + @api_client.config.logger.debug "Calling API: PetApi.find_pets_by_status ..." end - # verify the required parameter 'status' is set - fail "Missing the required parameter 'status' when calling find_pets_by_status" if status.nil? - + fail ArgumentError, "Missing the required parameter 'status' when calling PetApi.find_pets_by_status" if status.nil? # resource path local_var_path = "/pet/findByStatus".sub('{format}','json') @@ -220,12 +214,10 @@ module Petstore # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def find_pets_by_tags_with_http_info(tags, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#find_pets_by_tags ..." + @api_client.config.logger.debug "Calling API: PetApi.find_pets_by_tags ..." end - # verify the required parameter 'tags' is set - fail "Missing the required parameter 'tags' when calling find_pets_by_tags" if tags.nil? - + fail ArgumentError, "Missing the required parameter 'tags' when calling PetApi.find_pets_by_tags" if tags.nil? # resource path local_var_path = "/pet/findByTags".sub('{format}','json') @@ -280,12 +272,10 @@ module Petstore # @return [Array<(Pet, Fixnum, Hash)>] Pet data, response status code and response headers def get_pet_by_id_with_http_info(pet_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#get_pet_by_id ..." + @api_client.config.logger.debug "Calling API: PetApi.get_pet_by_id ..." end - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling get_pet_by_id" if pet_id.nil? - + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id" if pet_id.nil? # resource path local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) @@ -339,12 +329,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_pet_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#update_pet ..." + @api_client.config.logger.debug "Calling API: PetApi.update_pet ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling update_pet" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling PetApi.update_pet" if body.nil? # resource path local_var_path = "/pet".sub('{format}','json') @@ -401,12 +389,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_pet_with_form_with_http_info(pet_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#update_pet_with_form ..." + @api_client.config.logger.debug "Calling API: PetApi.update_pet_with_form ..." end - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil? - + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form" if pet_id.nil? # resource path local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) @@ -465,12 +451,10 @@ module Petstore # @return [Array<(ApiResponse, Fixnum, Hash)>] ApiResponse data, response status code and response headers def upload_file_with_http_info(pet_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#upload_file ..." + @api_client.config.logger.debug "Calling API: PetApi.upload_file ..." end - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil? - + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file" if pet_id.nil? # resource path local_var_path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 5a3c8efeb82..04c7f2701d8 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -41,12 +41,14 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_order_with_http_info(order_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: StoreApi#delete_order ..." + @api_client.config.logger.debug "Calling API: StoreApi.delete_order ..." end - # verify the required parameter 'order_id' is set - fail "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil? - + fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order" if order_id.nil? + if order_id < 1.0 + fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.delete_order, must be greater than or equal to 1.0.' + end + # resource path local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s) @@ -97,9 +99,8 @@ module Petstore # @return [Array<(Hash, Fixnum, Hash)>] Hash data, response status code and response headers def get_inventory_with_http_info(opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: StoreApi#get_inventory ..." + @api_client.config.logger.debug "Calling API: StoreApi.get_inventory ..." end - # resource path local_var_path = "/store/inventory".sub('{format}','json') @@ -153,12 +154,18 @@ module Petstore # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers def get_order_by_id_with_http_info(order_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: StoreApi#get_order_by_id ..." + @api_client.config.logger.debug "Calling API: StoreApi.get_order_by_id ..." end - # verify the required parameter 'order_id' is set - fail "Missing the required parameter 'order_id' when calling get_order_by_id" if order_id.nil? - + fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.get_order_by_id" if order_id.nil? + if order_id > 5.0 + fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be smaller than or equal to 5.0.' + end + + if order_id < 1.0 + fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be greater than or equal to 1.0.' + end + # resource path local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s) @@ -212,12 +219,10 @@ module Petstore # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers def place_order_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: StoreApi#place_order ..." + @api_client.config.logger.debug "Calling API: StoreApi.place_order ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling place_order" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling StoreApi.place_order" if body.nil? # resource path local_var_path = "/store/order".sub('{format}','json') diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index d5535aac583..469c950934a 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -41,12 +41,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_user_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#create_user ..." + @api_client.config.logger.debug "Calling API: UserApi.create_user ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling create_user" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_user" if body.nil? # resource path local_var_path = "/user".sub('{format}','json') @@ -99,12 +97,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_users_with_array_input_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#create_users_with_array_input ..." + @api_client.config.logger.debug "Calling API: UserApi.create_users_with_array_input ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling create_users_with_array_input" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_users_with_array_input" if body.nil? # resource path local_var_path = "/user/createWithArray".sub('{format}','json') @@ -157,12 +153,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_users_with_list_input_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#create_users_with_list_input ..." + @api_client.config.logger.debug "Calling API: UserApi.create_users_with_list_input ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling create_users_with_list_input" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_users_with_list_input" if body.nil? # resource path local_var_path = "/user/createWithList".sub('{format}','json') @@ -215,12 +209,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_user_with_http_info(username, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#delete_user ..." + @api_client.config.logger.debug "Calling API: UserApi.delete_user ..." end - # verify the required parameter 'username' is set - fail "Missing the required parameter 'username' when calling delete_user" if username.nil? - + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user" if username.nil? # resource path local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) @@ -273,12 +265,10 @@ module Petstore # @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers def get_user_by_name_with_http_info(username, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#get_user_by_name ..." + @api_client.config.logger.debug "Calling API: UserApi.get_user_by_name ..." end - # verify the required parameter 'username' is set - fail "Missing the required parameter 'username' when calling get_user_by_name" if username.nil? - + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name" if username.nil? # resource path local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) @@ -334,15 +324,12 @@ module Petstore # @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers def login_user_with_http_info(username, password, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#login_user ..." + @api_client.config.logger.debug "Calling API: UserApi.login_user ..." end - # verify the required parameter 'username' is set - fail "Missing the required parameter 'username' when calling login_user" if username.nil? - + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.login_user" if username.nil? # verify the required parameter 'password' is set - fail "Missing the required parameter 'password' when calling login_user" if password.nil? - + fail ArgumentError, "Missing the required parameter 'password' when calling UserApi.login_user" if password.nil? # resource path local_var_path = "/user/login".sub('{format}','json') @@ -396,9 +383,8 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def logout_user_with_http_info(opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#logout_user ..." + @api_client.config.logger.debug "Calling API: UserApi.logout_user ..." end - # resource path local_var_path = "/user/logout".sub('{format}','json') @@ -453,15 +439,12 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_user_with_http_info(username, body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#update_user ..." + @api_client.config.logger.debug "Calling API: UserApi.update_user ..." end - # verify the required parameter 'username' is set - fail "Missing the required parameter 'username' when calling update_user" if username.nil? - + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.update_user" if username.nil? # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling update_user" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.update_user" if body.nil? # resource path local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index 342d3b2464d..5612f227d09 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -42,9 +42,26 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] + if attributes.has_key?(:'className') self.class_name = attributes[:'className'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @class_name.nil? + return false + end + end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb index 683083be4b2..79da573e941 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -50,15 +50,30 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'code'] + if attributes.has_key?(:'code') self.code = attributes[:'code'] end - if attributes[:'type'] + + if attributes.has_key?(:'type') self.type = attributes[:'type'] end - if attributes[:'message'] + + if attributes.has_key?(:'message') self.message = attributes[:'message'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index 4489e6abb85..12f17b85553 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -46,12 +46,30 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] + if attributes.has_key?(:'className') self.class_name = attributes[:'className'] end - if attributes[:'declawed'] + + if attributes.has_key?(:'declawed') self.declawed = attributes[:'declawed'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @class_name.nil? + return false + end + end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index 0f6d61d83af..c4879d65bb4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -46,12 +46,26 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'name'] + + if attributes.has_key?(:'name') self.name = attributes[:'name'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index 5173f9a01ec..90d213dbf45 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -46,12 +46,30 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] + if attributes.has_key?(:'className') self.class_name = attributes[:'className'] end - if attributes[:'breed'] + + if attributes.has_key?(:'breed') self.breed = attributes[:'breed'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @class_name.nil? + return false + end + end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 87b6d4e4695..a7ebd095f9d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -86,42 +86,256 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'integer'] + if attributes.has_key?(:'integer') self.integer = attributes[:'integer'] end - if attributes[:'int32'] + + if attributes.has_key?(:'int32') self.int32 = attributes[:'int32'] end - if attributes[:'int64'] + + if attributes.has_key?(:'int64') self.int64 = attributes[:'int64'] end - if attributes[:'number'] + + if attributes.has_key?(:'number') self.number = attributes[:'number'] end - if attributes[:'float'] + + if attributes.has_key?(:'float') self.float = attributes[:'float'] end - if attributes[:'double'] + + if attributes.has_key?(:'double') self.double = attributes[:'double'] end - if attributes[:'string'] + + if attributes.has_key?(:'string') self.string = attributes[:'string'] end - if attributes[:'byte'] + + if attributes.has_key?(:'byte') self.byte = attributes[:'byte'] end - if attributes[:'binary'] + + if attributes.has_key?(:'binary') self.binary = attributes[:'binary'] end - if attributes[:'date'] + + if attributes.has_key?(:'date') self.date = attributes[:'date'] end - if attributes[:'dateTime'] + + if attributes.has_key?(:'dateTime') self.date_time = attributes[:'dateTime'] end - if attributes[:'password'] + + if attributes.has_key?(:'password') self.password = attributes[:'password'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @integer > 100.0 + return false + end + + if @integer < 10.0 + return false + end + + if @int32 > 200.0 + return false + end + + if @int32 < 20.0 + return false + end + + if @number.nil? + return false + end + + if @number > 543.2 + return false + end + + if @number < 32.1 + return false + end + + if @float > 987.6 + return false + end + + if @float < 54.3 + return false + end + + if @double > 123.4 + return false + end + + if @double < 67.8 + return false + end + + if @string !~ Regexp.new(/[a-z]/i) + return false + end + + if @byte.nil? + return false + end + + if @date.nil? + return false + end + + if @password.nil? + return false + end + + if @password.to_s.length > 64 + return false + end + + if @password.to_s.length < 10 + return false + end + + end + + # Custom attribute writer method with validation + # @param [Object] integer Value to be assigned + def integer=(integer) + if integer.nil? + fail ArgumentError, "integer cannot be nil" + end + + if integer > 100.0 + fail ArgumentError, "invalid value for 'integer', must be smaller than or equal to 100.0." + end + + if integer < 10.0 + fail ArgumentError, "invalid value for 'integer', must be greater than or equal to 10.0." + end + + @integer = integer + end + + # Custom attribute writer method with validation + # @param [Object] int32 Value to be assigned + def int32=(int32) + if int32.nil? + fail ArgumentError, "int32 cannot be nil" + end + + if int32 > 200.0 + fail ArgumentError, "invalid value for 'int32', must be smaller than or equal to 200.0." + end + + if int32 < 20.0 + fail ArgumentError, "invalid value for 'int32', must be greater than or equal to 20.0." + end + + @int32 = int32 + end + + # Custom attribute writer method with validation + # @param [Object] number Value to be assigned + def number=(number) + if number.nil? + fail ArgumentError, "number cannot be nil" + end + + if number > 543.2 + fail ArgumentError, "invalid value for 'number', must be smaller than or equal to 543.2." + end + + if number < 32.1 + fail ArgumentError, "invalid value for 'number', must be greater than or equal to 32.1." + end + + @number = number + end + + # Custom attribute writer method with validation + # @param [Object] float Value to be assigned + def float=(float) + if float.nil? + fail ArgumentError, "float cannot be nil" + end + + if float > 987.6 + fail ArgumentError, "invalid value for 'float', must be smaller than or equal to 987.6." + end + + if float < 54.3 + fail ArgumentError, "invalid value for 'float', must be greater than or equal to 54.3." + end + + @float = float + end + + # Custom attribute writer method with validation + # @param [Object] double Value to be assigned + def double=(double) + if double.nil? + fail ArgumentError, "double cannot be nil" + end + + if double > 123.4 + fail ArgumentError, "invalid value for 'double', must be smaller than or equal to 123.4." + end + + if double < 67.8 + fail ArgumentError, "invalid value for 'double', must be greater than or equal to 67.8." + end + + @double = double + end + + # Custom attribute writer method with validation + # @param [Object] string Value to be assigned + def string=(string) + if string.nil? + fail ArgumentError, "string cannot be nil" + end + + if @string !~ Regexp.new(/[a-z]/i) + fail ArgumentError, "invalid value for 'string', must conform to the pattern /[a-z]/i." + end + + @string = string + end + + # Custom attribute writer method with validation + # @param [Object] password Value to be assigned + def password=(password) + if password.nil? + fail ArgumentError, "password cannot be nil" + end + + if password.to_s.length > 64 + fail ArgumentError, "invalid value for 'password', the character length must be smaller than or equal to 64." + end + + if password.to_s.length < 10 + fail ArgumentError, "invalid value for 'password', the character length must be great than or equal to 10." + end + + @password = password end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb index 9cacbdb1298..7a2473fb8b9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb @@ -43,9 +43,22 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb index 31adf497fa2..0361451b290 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -43,9 +43,22 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'return'] + if attributes.has_key?(:'return') self._return = attributes[:'return'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index 9818aa41cc4..d5e3ef4adb8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -23,11 +23,14 @@ module Petstore attr_accessor :snake_case + attr_accessor :property + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'name' => :'name', - :'snake_case' => :'snake_case' + :'snake_case' => :'snake_case', + :'property' => :'property' } end @@ -35,7 +38,8 @@ module Petstore def self.swagger_types { :'name' => :'Integer', - :'snake_case' => :'Integer' + :'snake_case' => :'Integer', + :'property' => :'String' } end @@ -47,12 +51,34 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end - if attributes[:'snake_case'] + + if attributes.has_key?(:'snake_case') self.snake_case = attributes[:'snake_case'] end + + if attributes.has_key?(:'property') + self.property = attributes[:'property'] + end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @name.nil? + return false + end + end # Checks equality by comparing each attribute. @@ -61,7 +87,8 @@ module Petstore return true if self.equal?(o) self.class == o.class && name == o.name && - snake_case == o.snake_case + snake_case == o.snake_case && + property == o.property end # @see the `==` method @@ -73,7 +100,7 @@ module Petstore # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash - [name, snake_case].hash + [name, snake_case, property].hash end # Builds the object from hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index 81f2601e9d9..6c021e50ec7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -63,26 +63,48 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'petId'] + + if attributes.has_key?(:'petId') self.pet_id = attributes[:'petId'] end - if attributes[:'quantity'] + + if attributes.has_key?(:'quantity') self.quantity = attributes[:'quantity'] end - if attributes[:'shipDate'] + + if attributes.has_key?(:'shipDate') self.ship_date = attributes[:'shipDate'] end - if attributes[:'status'] + + if attributes.has_key?(:'status') self.status = attributes[:'status'] end - if attributes[:'complete'] + + if attributes.has_key?(:'complete') self.complete = attributes[:'complete'] else self.complete = false end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + allowed_values = ["placed", "approved", "delivered"] + if @status && !allowed_values.include?(@status) + return false + end end # Custom attribute writer method checking allowed values (enum). @@ -90,7 +112,7 @@ module Petstore def status=(status) allowed_values = ["placed", "approved", "delivered"] if status && !allowed_values.include?(status) - fail "invalid value for 'status', must be one of #{allowed_values}" + fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}." end @status = status end diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index 095f91ca7c3..ba4d466df21 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -63,28 +63,58 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'category'] + + if attributes.has_key?(:'category') self.category = attributes[:'category'] end - if attributes[:'name'] + + if attributes.has_key?(:'name') self.name = attributes[:'name'] end - if attributes[:'photoUrls'] + + if attributes.has_key?(:'photoUrls') if (value = attributes[:'photoUrls']).is_a?(Array) self.photo_urls = value end end - if attributes[:'tags'] + + if attributes.has_key?(:'tags') if (value = attributes[:'tags']).is_a?(Array) self.tags = value end end - if attributes[:'status'] + + if attributes.has_key?(:'status') self.status = attributes[:'status'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @name.nil? + return false + end + + if @photo_urls.nil? + return false + end + + allowed_values = ["available", "pending", "sold"] + if @status && !allowed_values.include?(@status) + return false + end end # Custom attribute writer method checking allowed values (enum). @@ -92,7 +122,7 @@ module Petstore def status=(status) allowed_values = ["available", "pending", "sold"] if status && !allowed_values.include?(status) - fail "invalid value for 'status', must be one of #{allowed_values}" + fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}." end @status = status end diff --git a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb index 4c859270d1b..853d1e49600 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -42,9 +42,22 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'$special[property.name]'] + if attributes.has_key?(:'$special[property.name]') self.special_property_name = attributes[:'$special[property.name]'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index e5c80ee2228..d6d49068e37 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -46,12 +46,26 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'name'] + + if attributes.has_key?(:'name') self.name = attributes[:'name'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index e7ce160dfa2..f0c39b741d5 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -71,30 +71,50 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'username'] + + if attributes.has_key?(:'username') self.username = attributes[:'username'] end - if attributes[:'firstName'] + + if attributes.has_key?(:'firstName') self.first_name = attributes[:'firstName'] end - if attributes[:'lastName'] + + if attributes.has_key?(:'lastName') self.last_name = attributes[:'lastName'] end - if attributes[:'email'] + + if attributes.has_key?(:'email') self.email = attributes[:'email'] end - if attributes[:'password'] + + if attributes.has_key?(:'password') self.password = attributes[:'password'] end - if attributes[:'phone'] + + if attributes.has_key?(:'phone') self.phone = attributes[:'phone'] end - if attributes[:'userStatus'] + + if attributes.has_key?(:'userStatus') self.user_status = attributes[:'userStatus'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/spec/api/fake_api_spec.rb b/samples/client/petstore/ruby/spec/api/fake_api_spec.rb new file mode 100644 index 00000000000..84929b8115c --- /dev/null +++ b/samples/client/petstore/ruby/spec/api/fake_api_spec.rb @@ -0,0 +1,66 @@ +=begin +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Petstore::FakeApi +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'FakeApi' do + before do + # run before each test + @instance = Petstore::FakeApi.new + end + + after do + # run after each test + end + + describe 'test an instance of FakeApi' do + it 'should create an instact of FakeApi' do + @instance.should be_a(Petstore::FakeApi) + end + end + + # unit tests for test_endpoint_parameters + # Fake endpoint for testing various parameters + # Fake endpoint for testing various parameters + # @param number None + # @param double None + # @param string None + # @param byte None + # @param [Hash] opts the optional parameters + # @option opts [Integer] :integer None + # @option opts [Integer] :int32 None + # @option opts [Integer] :int64 None + # @option opts [Float] :float None + # @option opts [String] :binary None + # @option opts [Date] :date None + # @option opts [DateTime] :date_time None + # @option opts [String] :password None + # @return [nil] + describe 'test_endpoint_parameters test' do + it "should work" do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + +end diff --git a/samples/client/petstore/ruby/spec/api_client_spec.rb b/samples/client/petstore/ruby/spec/api_client_spec.rb index a02d4a2d760..3e57a432391 100644 --- a/samples/client/petstore/ruby/spec/api_client_spec.rb +++ b/samples/client/petstore/ruby/spec/api_client_spec.rb @@ -206,7 +206,7 @@ describe Petstore::ApiClient do end it "fails for invalid collection format" do - proc { api_client.build_collection_param(param, :INVALID) }.should raise_error + proc { api_client.build_collection_param(param, :INVALID) }.should raise_error(RuntimeError, 'unknown collection format: :INVALID') end end diff --git a/samples/client/petstore/ruby/spec/base_object_spec.rb b/samples/client/petstore/ruby/spec/base_object_spec.rb index 61dcb4d6d9d..a315d52276b 100644 --- a/samples/client/petstore/ruby/spec/base_object_spec.rb +++ b/samples/client/petstore/ruby/spec/base_object_spec.rb @@ -30,8 +30,16 @@ class ArrayMapObject < Petstore::Category end end - describe 'BaseObject' do + describe 'boolean values' do + let(:obj) { Petstore::Cat.new({declawed: false}) } + + it 'should have values set' do + obj.declawed.should_not eq nil + obj.declawed.should eq false + end + end + describe 'array and map properties' do let(:obj) { ArrayMapObject.new } diff --git a/samples/client/petstore/ruby/spec/models/name_spec.rb b/samples/client/petstore/ruby/spec/models/name_spec.rb index 9eef65de2fa..e4942b173b9 100644 --- a/samples/client/petstore/ruby/spec/models/name_spec.rb +++ b/samples/client/petstore/ruby/spec/models/name_spec.rb @@ -56,5 +56,15 @@ describe 'Name' do end end + describe 'test attribute "property"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + end diff --git a/samples/client/petstore/ruby/spec/spec_helper.rb b/samples/client/petstore/ruby/spec/spec_helper.rb index 68147e76b72..50702c439b7 100644 --- a/samples/client/petstore/ruby/spec/spec_helper.rb +++ b/samples/client/petstore/ruby/spec/spec_helper.rb @@ -55,7 +55,7 @@ end # create a random order, return its id def prepare_store(store_api) - order_id = random_id + order_id = 5 order = Petstore::Order.new("id" => order_id, "petId" => 123, "quantity" => 789, diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java index 2e8ef241f49..52ca606b544 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java @@ -1,9 +1,13 @@ package io.swagger.api; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; import javax.ws.rs.*; import javax.ws.rs.core.Response; diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java index 39ffe2436a8..b7ccabe7d8b 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java @@ -3,6 +3,10 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; import javax.ws.rs.*; import javax.ws.rs.core.Response; diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java index 19e5ab04f3a..8874d96a519 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java @@ -3,6 +3,10 @@ package io.swagger.api; import io.swagger.model.User; import java.util.List; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; import javax.ws.rs.*; import javax.ws.rs.core.Response; diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java index f2d34f77367..2b2d460203b 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java @@ -8,9 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = + @XmlType(name = "Category", propOrder = { "id", "name" }) diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java index 3a9cbf3c130..b0babb254e7 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java @@ -8,9 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = + @XmlType(name = "Order", propOrder = { "id", "petId", "quantity", "shipDate", "status", "complete" }) @@ -26,19 +27,24 @@ public class Order { private javax.xml.datatype.XMLGregorianCalendar shipDate = null; -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name="Order") +@XmlType(name="StatusEnum") @XmlEnum -public enum Order { - {values=[placed, approved, delivered], enumVars=[{name=PLACED, value=placed}, {name=APPROVED, value=approved}, {name=DELIVERED, value=delivered}]}, - - public String value() { - return name(); +public enum StatusEnum { + + PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered")); + + + private String value; + + StatusEnum (String v) { + value = v; } - public static Order fromValue(String v) { + public String value() { + return value; + } + + public static StatusEnum fromValue(String v) { return valueOf(v); } } diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java index 707f90a3af8..58a58752122 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java @@ -12,9 +12,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = + @XmlType(name = "Pet", propOrder = { "id", "category", "name", "photoUrls", "tags", "status" }) @@ -32,19 +33,24 @@ public class Pet { private List tags = new ArrayList(); -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name="Pet") +@XmlType(name="StatusEnum") @XmlEnum -public enum Pet { - {values=[available, pending, sold], enumVars=[{name=AVAILABLE, value=available}, {name=PENDING, value=pending}, {name=SOLD, value=sold}]}, - - public String value() { - return name(); +public enum StatusEnum { + + AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold")); + + + private String value; + + StatusEnum (String v) { + value = v; } - public static Pet fromValue(String v) { + public String value() { + return value; + } + + public static StatusEnum fromValue(String v) { return valueOf(v); } } diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java index 1912fa6f731..4e1921add9b 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java @@ -8,9 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = + @XmlType(name = "Tag", propOrder = { "id", "name" }) diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java index c35af076cf6..007344a2687 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java @@ -8,9 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = + @XmlType(name = "User", propOrder = { "id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus" }) diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java index 2a519b09b8b..24a37938400 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java index a7a3a461a1d..48b4d658725 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java @@ -5,7 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class ApiOriginFilter implements javax.servlet.Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java index 07f1fd78fe0..b1b2df77e20 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java @@ -3,7 +3,7 @@ package io.swagger.api; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java index a8a136f8760..77bd497a379 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java index 8beeb2b7a93..11870e95f1e 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java @@ -5,8 +5,8 @@ import io.swagger.api.PetApiService; import io.swagger.api.factories.PetApiServiceFactory; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; import java.util.List; import io.swagger.api.NotFoundException; @@ -22,7 +22,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; @Path("/pet") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class PetApi { private final PetApiService delegate = PetApiServiceFactory.getPetApi(); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java index 4d65977483c..def447f5695 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java @@ -6,8 +6,8 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; import java.util.List; import io.swagger.api.NotFoundException; @@ -17,7 +17,7 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public abstract class PetApiService { public abstract Response addPet(Pet body,SecurityContext securityContext) throws NotFoundException; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApi.java deleted file mode 100644 index 8c742e89268..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApi.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.*; -import io.swagger.api.PettestingByteArraytrueApiService; -import io.swagger.api.factories.PettestingByteArraytrueApiServiceFactory; - - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; - -@Path("/pet?testing_byte_array=true") - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public class PettestingByteArraytrueApi { - private final PettestingByteArraytrueApiService delegate = PettestingByteArraytrueApiServiceFactory.getPettestingByteArraytrueApi(); - - @POST - - @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/json", "application/xml" }) - public Response addPetUsingByteArray( byte[] body,@Context SecurityContext securityContext) - throws NotFoundException { - return delegate.addPetUsingByteArray(body,securityContext); - } -} diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApiService.java deleted file mode 100644 index 08186045b71..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApiService.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.swagger.api; - -import io.swagger.api.*; -import io.swagger.model.*; - - - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public abstract class PettestingByteArraytrueApiService { - - public abstract Response addPetUsingByteArray(byte[] body,SecurityContext securityContext) - throws NotFoundException; - -} diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java index e6ab3511835..dea36a07275 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java @@ -20,7 +20,7 @@ import javax.ws.rs.*; @Path("/store") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class StoreApi { private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi(); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java index c246af6e58e..dc740cd491d 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java @@ -15,7 +15,7 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public abstract class StoreApiService { public abstract Response deleteOrder(String orderId,SecurityContext securityContext) throws NotFoundException; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java index c358c74b469..0cfee024b00 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java index 966965db529..02e6d6b24da 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java @@ -20,7 +20,7 @@ import javax.ws.rs.*; @Path("/user") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class UserApi { private final UserApiService delegate = UserApiServiceFactory.getUserApi(); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java index a656efd6f72..e900b146061 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java @@ -15,7 +15,7 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public abstract class UserApiService { public abstract Response createUser(User body,SecurityContext securityContext) throws NotFoundException; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java index c74992a36ba..bfeecafe689 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class Category { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/InlineResponse200.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/InlineResponse200.java deleted file mode 100644 index 408a4ccdb0e..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/InlineResponse200.java +++ /dev/null @@ -1,166 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.model.Tag; -import java.util.List; - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public class InlineResponse200 { - - private List tags = new ArrayList(); - private Long id = null; - private Object category = null; - - - public enum StatusEnum { - AVAILABLE("available"), - PENDING("pending"), - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - private StatusEnum status = null; - private String name = null; - private List photoUrls = new ArrayList(); - - - /** - **/ - - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - **/ - - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - - @JsonProperty("category") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - - /** - * pet status in the store - **/ - - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - /** - **/ - - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(tags, inlineResponse200.tags) && - Objects.equals(id, inlineResponse200.id) && - Objects.equals(category, inlineResponse200.category) && - Objects.equals(status, inlineResponse200.status) && - Objects.equals(name, inlineResponse200.name) && - Objects.equals(photoUrls, inlineResponse200.photoUrls); - } - - @Override - public int hashCode() { - return Objects.hash(tags, id, category, status, name, photoUrls); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InlineResponse200 {\n"); - - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ApiResponse.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java similarity index 82% rename from samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ApiResponse.java rename to samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java index f67a16b28e6..a46b64b8bbd 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ApiResponse.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -8,8 +8,8 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") -public class ApiResponse { +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") +public class ModelApiResponse { private Integer code = null; private String type = null; @@ -57,10 +57,10 @@ public class ApiResponse { if (o == null || getClass() != o.getClass()) { return false; } - ApiResponse apiResponse = (ApiResponse) o; - return Objects.equals(code, apiResponse.code) && - Objects.equals(type, apiResponse.type) && - Objects.equals(message, apiResponse.message); + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); } @Override @@ -71,7 +71,7 @@ public class ApiResponse { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ApiResponse {\n"); + sb.append("class ModelApiResponse {\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelReturn.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelReturn.java deleted file mode 100644 index a7ab3bb3df6..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelReturn.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public class ModelReturn { - - private Integer _return = null; - - - /** - **/ - - @JsonProperty("return") - public Integer getReturn() { - return _return; - } - public void setReturn(Integer _return) { - this._return = _return; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelReturn _return = (ModelReturn) o; - return Objects.equals(_return, _return._return); - } - - @Override - public int hashCode() { - return Objects.hash(_return); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelReturn {\n"); - - sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Name.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Name.java deleted file mode 100644 index ff879eeb209..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Name.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public class Name { - - private Integer name = null; - - - /** - **/ - - @JsonProperty("name") - public Integer getName() { - return name; - } - public void setName(Integer name) { - this.name = name; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Name name = (Name) o; - return Objects.equals(name, name.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Name {\n"); - - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java index 7d1093ec0e2..e8af2984ef9 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java @@ -9,7 +9,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class Order { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java index c763a801181..740ed352c9d 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java @@ -11,7 +11,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class Pet { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/SpecialModelName.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/SpecialModelName.java deleted file mode 100644 index f5c2edcb253..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/SpecialModelName.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public class SpecialModelName { - - private Long specialPropertyName = null; - - - /** - **/ - - @JsonProperty("$special[property.name]") - public Long getSpecialPropertyName() { - return specialPropertyName; - } - public void setSpecialPropertyName(Long specialPropertyName) { - this.specialPropertyName = specialPropertyName; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SpecialModelName specialModelName = (SpecialModelName) o; - return Objects.equals(specialPropertyName, specialModelName.specialPropertyName); - } - - @Override - public int hashCode() { - return Objects.hash(specialPropertyName); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SpecialModelName {\n"); - - sb.append(" specialPropertyName: ").append(toIndentedString(specialPropertyName)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java index 3046b9ff951..0a7e01df75b 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class Tag { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java index 924d72b9bcc..3c144892193 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class User { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PettestingByteArraytrueApiServiceFactory.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PettestingByteArraytrueApiServiceFactory.java deleted file mode 100644 index 42f4715fad4..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PettestingByteArraytrueApiServiceFactory.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.swagger.api.factories; - -import io.swagger.api.PettestingByteArraytrueApiService; -import io.swagger.api.impl.PettestingByteArraytrueApiServiceImpl; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") -public class PettestingByteArraytrueApiServiceFactory { - - private final static PettestingByteArraytrueApiService service = new PettestingByteArraytrueApiServiceImpl(); - - public static PettestingByteArraytrueApiService getPettestingByteArraytrueApi() - { - return service; - } -} diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PettestingByteArraytrueApiServiceImpl.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PettestingByteArraytrueApiServiceImpl.java deleted file mode 100644 index 5a3c2519b03..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PettestingByteArraytrueApiServiceImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.swagger.api.impl; - -import io.swagger.api.*; -import io.swagger.model.*; - - - - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") - -public class PettestingByteArraytrueApiServiceImpl extends PettestingByteArraytrueApiService { - - @Override - public Response addPetUsingByteArray(byte[] body,SecurityContext securityContext) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - -} - diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java index e439e48d212..6ab33888e61 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java @@ -9,8 +9,8 @@ import io.swagger.annotations.ApiParam; import com.sun.jersey.multipart.FormDataParam; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; import java.util.List; import io.swagger.api.NotFoundException; @@ -169,14 +169,14 @@ public class PetApi { @Path("/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) - @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ApiResponse.class, authorizations = { + @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet" }) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ApiResponse.class) }) + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) public Response uploadFile( @ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId, @FormDataParam("additionalMetadata") String additionalMetadata, diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java index 7a2d8b60585..4cf67d11f3e 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java @@ -6,8 +6,8 @@ import io.swagger.model.*; import com.sun.jersey.multipart.FormDataParam; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; import java.util.List; import io.swagger.api.NotFoundException; diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/ModelApiResponse.java new file mode 100644 index 00000000000..5e3aa82bbee --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -0,0 +1,113 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + + + + + + +public class ModelApiResponse { + + private Integer code = null; + private String type = null; + private String message = null; + + /** + **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + + @ApiModelProperty(value = "") + @JsonProperty("code") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + /** + **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + + @ApiModelProperty(value = "") + @JsonProperty("type") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + + @ApiModelProperty(value = "") + @JsonProperty("message") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java index 74ea4cbc4c7..cdd9e904098 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java index d174ef951f4..1b6e847cc10 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java @@ -5,7 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class ApiOriginFilter implements javax.servlet.Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java index d53fb5b1bf7..52c47326b30 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java @@ -3,7 +3,7 @@ package io.swagger.api; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java index 077573dfcd5..a5bb52fc58b 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java index 3db41f8b7b1..3e79c004237 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java @@ -3,8 +3,8 @@ package io.swagger.api; import io.swagger.model.*; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -32,7 +32,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/pet", description = "the pet API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class PetApi { @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { @@ -206,19 +206,19 @@ public class PetApi { } - @ApiOperation(value = "uploads an image", notes = "", response = ApiResponse.class, authorizations = { + @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ApiResponse.class) }) + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @RequestMapping(value = "/{petId}/uploadImage", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - public ResponseEntity uploadFile( + public ResponseEntity uploadFile( @ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId , @@ -233,7 +233,7 @@ public class PetApi { ) throws NotFoundException { // do some magic! - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.OK); } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PettestingByteArraytrueApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PettestingByteArraytrueApi.java deleted file mode 100644 index f7912cb4d28..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PettestingByteArraytrueApi.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.*; - - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.AuthorizationScope; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; - -import static org.springframework.http.MediaType.*; - -@Controller -@RequestMapping(value = "/pet?testing_byte_array=true", produces = {APPLICATION_JSON_VALUE}) -@Api(value = "/pet?testing_byte_array=true", description = "the pet?testing_byte_array=true API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class PettestingByteArraytrueApi { - - @ApiOperation(value = "Fake endpoint to test byte array in body parameter for adding a new pet to the store", notes = "", response = Void.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "", - produces = { "application/json", "application/xml" }, - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) - public ResponseEntity addPetUsingByteArray( - -@ApiParam(value = "Pet object in the form of byte array" ) @RequestBody byte[] body -) - throws NotFoundException { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java index 916532b6bce..b9b4dc22e47 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java @@ -31,7 +31,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/store", description = "the store API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class StoreApi { @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class) diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java index c7bd55fd05b..777724026c7 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java @@ -31,7 +31,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/user", description = "the user API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class UserApi { @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java index 2e99e717296..0f81ad7d00f 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java @@ -18,7 +18,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @EnableSwagger2 //Loads the spring beans required by the framework @PropertySource("classpath:swagger.properties") @Import(SwaggerUiConfiguration.class) -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class SwaggerConfig { @Bean ApiInfo apiInfo() { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java index e552ecc15fb..b228de3b07c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java @@ -8,7 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @Configuration @EnableWebMvc -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter { private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java index ea9b029ba8d..a505241d556 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java @@ -2,7 +2,7 @@ package io.swagger.configuration; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer { @Override diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java index 61bfeda1555..e1ba8c520a8 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java @@ -3,7 +3,7 @@ package io.swagger.configuration; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class WebMvcConfiguration extends WebMvcConfigurationSupport { @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Animal.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Animal.java deleted file mode 100644 index ff0afdd4f86..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Animal.java +++ /dev/null @@ -1,57 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class Animal { - - private String className = null; - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("className") - public String getClassName() { - return className; - } - public void setClassName(String className) { - this.className = className; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Animal animal = (Animal) o; - return Objects.equals(className, animal.className); - } - - @Override - public int hashCode() { - return Objects.hash(className); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Animal {\n"); - - sb.append(" className: ").append(className).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Cat.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Cat.java deleted file mode 100644 index 884c739d46d..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Cat.java +++ /dev/null @@ -1,72 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Animal; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class Cat extends Animal { - - private String className = null; - private Boolean declawed = null; - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("className") - public String getClassName() { - return className; - } - public void setClassName(String className) { - this.className = className; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("declawed") - public Boolean getDeclawed() { - return declawed; - } - public void setDeclawed(Boolean declawed) { - this.declawed = declawed; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Cat cat = (Cat) o; - return Objects.equals(className, cat.className) && - Objects.equals(declawed, cat.declawed); - } - - @Override - public int hashCode() { - return Objects.hash(className, declawed); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Cat {\n"); - sb.append(" " + super.toString()).append("\n"); - sb.append(" className: ").append(className).append("\n"); - sb.append(" declawed: ").append(declawed).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java index a59702faace..f3e03a8c88f 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java @@ -11,7 +11,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class Category { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Dog.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Dog.java deleted file mode 100644 index 856fb7a0e66..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Dog.java +++ /dev/null @@ -1,72 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Animal; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class Dog extends Animal { - - private String className = null; - private String breed = null; - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("className") - public String getClassName() { - return className; - } - public void setClassName(String className) { - this.className = className; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("breed") - public String getBreed() { - return breed; - } - public void setBreed(String breed) { - this.breed = breed; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Dog dog = (Dog) o; - return Objects.equals(className, dog.className) && - Objects.equals(breed, dog.breed); - } - - @Override - public int hashCode() { - return Objects.hash(className, breed); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Dog {\n"); - sb.append(" " + super.toString()).append("\n"); - sb.append(" className: ").append(className).append("\n"); - sb.append(" breed: ").append(breed).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java deleted file mode 100644 index 309ffd11616..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java +++ /dev/null @@ -1,213 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.math.BigDecimal; -import java.util.Date; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class FormatTest { - - private Integer integer = null; - private Integer int32 = null; - private Long int64 = null; - private BigDecimal number = null; - private Float _float = null; - private Double _double = null; - private String string = null; - private byte[] _byte = null; - private byte[] binary = null; - private Date date = null; - private Date dateTime = null; - private String password = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("integer") - public Integer getInteger() { - return integer; - } - public void setInteger(Integer integer) { - this.integer = integer; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("int32") - public Integer getInt32() { - return int32; - } - public void setInt32(Integer int32) { - this.int32 = int32; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("int64") - public Long getInt64() { - return int64; - } - public void setInt64(Long int64) { - this.int64 = int64; - } - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("number") - public BigDecimal getNumber() { - return number; - } - public void setNumber(BigDecimal number) { - this.number = number; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("float") - public Float getFloat() { - return _float; - } - public void setFloat(Float _float) { - this._float = _float; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("double") - public Double getDouble() { - return _double; - } - public void setDouble(Double _double) { - this._double = _double; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("string") - public String getString() { - return string; - } - public void setString(String string) { - this.string = string; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("byte") - public byte[] getByte() { - return _byte; - } - public void setByte(byte[] _byte) { - this._byte = _byte; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("binary") - public byte[] getBinary() { - return binary; - } - public void setBinary(byte[] binary) { - this.binary = binary; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("date") - public Date getDate() { - return date; - } - public void setDate(Date date) { - this.date = date; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("dateTime") - public Date getDateTime() { - return dateTime; - } - public void setDateTime(Date dateTime) { - this.dateTime = dateTime; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("password") - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FormatTest formatTest = (FormatTest) o; - return Objects.equals(integer, formatTest.integer) && - Objects.equals(int32, formatTest.int32) && - Objects.equals(int64, formatTest.int64) && - Objects.equals(number, formatTest.number) && - Objects.equals(_float, formatTest._float) && - Objects.equals(_double, formatTest._double) && - Objects.equals(string, formatTest.string) && - Objects.equals(_byte, formatTest._byte) && - Objects.equals(binary, formatTest.binary) && - Objects.equals(date, formatTest.date) && - Objects.equals(dateTime, formatTest.dateTime) && - Objects.equals(password, formatTest.password); - } - - @Override - public int hashCode() { - return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, password); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class FormatTest {\n"); - - sb.append(" integer: ").append(integer).append("\n"); - sb.append(" int32: ").append(int32).append("\n"); - sb.append(" int64: ").append(int64).append("\n"); - sb.append(" number: ").append(number).append("\n"); - sb.append(" _float: ").append(_float).append("\n"); - sb.append(" _double: ").append(_double).append("\n"); - sb.append(" string: ").append(string).append("\n"); - sb.append(" _byte: ").append(_byte).append("\n"); - sb.append(" binary: ").append(binary).append("\n"); - sb.append(" date: ").append(date).append("\n"); - sb.append(" dateTime: ").append(dateTime).append("\n"); - sb.append(" password: ").append(password).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/InlineResponse200.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/InlineResponse200.java deleted file mode 100644 index 9b7bd64697e..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/InlineResponse200.java +++ /dev/null @@ -1,136 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Tag; -import java.util.ArrayList; -import java.util.List; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class InlineResponse200 { - - private List tags = new ArrayList(); - private Long id = null; - private Object category = null; - public enum StatusEnum { - available, pending, sold, - }; - - private StatusEnum status = null; - private String name = null; - private List photoUrls = new ArrayList(); - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("category") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(tags, inlineResponse200.tags) && - Objects.equals(id, inlineResponse200.id) && - Objects.equals(category, inlineResponse200.category) && - Objects.equals(status, inlineResponse200.status) && - Objects.equals(name, inlineResponse200.name) && - Objects.equals(photoUrls, inlineResponse200.photoUrls); - } - - @Override - public int hashCode() { - return Objects.hash(tags, id, category, status, name, photoUrls); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InlineResponse200 {\n"); - - sb.append(" tags: ").append(tags).append("\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" category: ").append(category).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append(" photoUrls: ").append(photoUrls).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Model200Response.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Model200Response.java deleted file mode 100644 index d0babbf10ba..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Model200Response.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -/** - * Model for testing model name starting with number - **/ -@ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class Model200Response { - - private Integer name = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("name") - public Integer getName() { - return name; - } - public void setName(Integer name) { - this.name = name; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Model200Response _200Response = (Model200Response) o; - return Objects.equals(name, _200Response.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Model200Response {\n"); - - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ApiResponse.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java similarity index 81% rename from samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ApiResponse.java rename to samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java index 31e09116e3a..327e9bb92d3 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ApiResponse.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java @@ -11,8 +11,8 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") -public class ApiResponse { +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") +public class ModelApiResponse { private Integer code = null; private String type = null; @@ -60,10 +60,10 @@ public class ApiResponse { if (o == null || getClass() != o.getClass()) { return false; } - ApiResponse apiResponse = (ApiResponse) o; - return Objects.equals(code, apiResponse.code) && - Objects.equals(type, apiResponse.type) && - Objects.equals(message, apiResponse.message); + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); } @Override @@ -74,7 +74,7 @@ public class ApiResponse { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ApiResponse {\n"); + sb.append("class ModelApiResponse {\n"); sb.append(" code: ").append(code).append("\n"); sb.append(" type: ").append(type).append("\n"); diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelReturn.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelReturn.java deleted file mode 100644 index 04b1ea734f2..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelReturn.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -/** - * Model for testing reserved words - **/ -@ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class ModelReturn { - - private Integer _return = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("return") - public Integer getReturn() { - return _return; - } - public void setReturn(Integer _return) { - this._return = _return; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelReturn _return = (ModelReturn) o; - return Objects.equals(_return, _return._return); - } - - @Override - public int hashCode() { - return Objects.hash(_return); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelReturn {\n"); - - sb.append(" _return: ").append(_return).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Name.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Name.java deleted file mode 100644 index 475abe42028..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Name.java +++ /dev/null @@ -1,74 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -/** - * Model for testing model name same as property name - **/ -@ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class Name { - - private Integer name = null; - private Integer snakeCase = null; - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("name") - public Integer getName() { - return name; - } - public void setName(Integer name) { - this.name = name; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("snake_case") - public Integer getSnakeCase() { - return snakeCase; - } - public void setSnakeCase(Integer snakeCase) { - this.snakeCase = snakeCase; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Name name = (Name) o; - return Objects.equals(name, name.name) && - Objects.equals(snakeCase, name.snakeCase); - } - - @Override - public int hashCode() { - return Objects.hash(name, snakeCase); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Name {\n"); - - sb.append(" name: ").append(name).append("\n"); - sb.append(" snakeCase: ").append(snakeCase).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java index 9dd2d718ba3..ed04a25a4a9 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java @@ -13,7 +13,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class Order { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java index 2a85f8f23c5..b725b22c44d 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java @@ -16,7 +16,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class Pet { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/SpecialModelName.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/SpecialModelName.java deleted file mode 100644 index 0aaad51d9f3..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/SpecialModelName.java +++ /dev/null @@ -1,57 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class SpecialModelName { - - private Long specialPropertyName = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("$special[property.name]") - public Long getSpecialPropertyName() { - return specialPropertyName; - } - public void setSpecialPropertyName(Long specialPropertyName) { - this.specialPropertyName = specialPropertyName; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SpecialModelName specialModelName = (SpecialModelName) o; - return Objects.equals(specialPropertyName, specialModelName.specialPropertyName); - } - - @Override - public int hashCode() { - return Objects.hash(specialPropertyName); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SpecialModelName {\n"); - - sb.append(" specialPropertyName: ").append(specialPropertyName).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java index 911ea429dc7..97e11f1f5ab 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java @@ -11,7 +11,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class Tag { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java index 1bb2c285432..88615e98517 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java @@ -11,7 +11,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class User { private Long id = null;