diff --git a/.gitignore b/.gitignore index 3118eafbcfd..6384cec8fc8 100644 --- a/.gitignore +++ b/.gitignore @@ -80,12 +80,17 @@ samples/client/petstore/silex/SwaggerServer/venodr/ samples/client/petstore/perl/deep_module_test/ # Objc -samples/client/petstore/objc/PetstoreClient.xcworkspace/xcuserdata -samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata -samples/client/petstore/objc/SwaggerClientTests/Build -samples/client/petstore/objc/SwaggerClientTests/Pods -samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcworkspace -samples/client/petstore/objc/SwaggerClientTests/Podfile.lock +samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata +samples/client/petstore/objc/default/SwaggerClientTests/Build +samples/client/petstore/objc/default/SwaggerClientTests/Pods +samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcworkspace +samples/client/petstore/objc/default/SwaggerClientTests/Podfile.lock + +samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata +samples/client/petstore/objc/core-data/SwaggerClientTests/Build +samples/client/petstore/objc/core-data/SwaggerClientTests/Pods +samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcworkspace +samples/client/petstore/objc/core-data/SwaggerClientTests/Podfile.lock # Swift samples/client/petstore/swift/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata diff --git a/README.md b/README.md index fb1d8501287..6d6c83e7679 100644 --- a/README.md +++ b/README.md @@ -41,19 +41,6 @@ Check out [Swagger-Spec](https://github.com/OAI/OpenAPI-Specification) for addit - [Generating dynamic html api documentation](#generating-dynamic-html-api-documentation) - [Generating static html api documentation](#generating-static-html-api-documentation) - [To build a server stub](#to-build-a-server-stub) - - [Node.js](#nodejs) - - [PHP Slim](#php-slim) - - [PHP Silex](#php-silex) - - [Python Flask (Connexion)](#python-flask-connexion) - - [Ruby Sinatra](#ruby-sinatra) - - [Scala Scalatra](#scala-scalatra) - - [Java JAX-RS (Java JAX-RS (Jersey v1.18)](#java-jax-rs-jersey-v118) - - [Java JAX-RS (Apache CXF 2 / 3)](#java-jax-rs-apache-cxf-2--3) - - [Java JAX-RS (Resteasy)](#java-jax-rs-resteasy) - - [Java Spring MVC](#java-spring-mvc) - - [Java SpringBoot](#java-springboot) - - [Haskell Servant](#haskell-servant) - - [ASP.NET 5 Web API](#aspnet-5-web-api) - [To build the codegen library](#to-build-the-codegen-library) - [Workflow Integration](#workflow-integration) - [Github Integration](#github-integration) @@ -772,6 +759,7 @@ Swaagger Codegen core team members are contributors who have been making signfic | Langauges | Core Team (date joined) | |:------------- |:-------------| | C# ASP.NET5 | @jimschubert (2016/05/01) | +| Go Server | @guohuang (2016/06/13) | | Haskell Servant | | | Java Spring Boot | | | Java SpringMVC | @kolyjjj (2016/05/01) | @@ -808,6 +796,7 @@ Here is a list of template creators: * TypeScript (Angular2): @roni-frantchi * Server Stubs * C# ASP.NET5: @jimschubert + * Go Server: @guohuang * Haskell Servant: @algas * Java Spring Boot: @diyfr * JAX-RS RestEasy: @chameleon82 diff --git a/bin/objc-petstore-coredata.sh b/bin/objc-petstore-coredata.sh new file mode 100755 index 00000000000..8487adfc42b --- /dev/null +++ b/bin/objc-petstore-coredata.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/objc -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -DapiDocs=false,modelDocs=false -o samples/client/petstore/objc/core-data --additional-properties coreData=true" + +java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags diff --git a/bin/objc-petstore.sh b/bin/objc-petstore.sh index df22ea3b595..71480ff1595 100755 --- a/bin/objc-petstore.sh +++ b/bin/objc-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/objc -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -o samples/client/petstore/objc --additional-properties coreData=true" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/objc -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -o samples/client/petstore/objc/default" java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags diff --git a/bin/windows/objc-petstore.bat b/bin/windows/objc-petstore.bat index a26b0dad566..9e64a80ac00 100755 --- a/bin/windows/objc-petstore.bat +++ b/bin/windows/objc-petstore.bat @@ -5,6 +5,6 @@ If Not Exist %executable% ( ) set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -set ags=generate -t modules\swagger-codegen\src\main\resources\objc -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l objc -o samples\client\petstore\objc +set ags=generate -t modules\swagger-codegen\src\main\resources\objc -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l objc -o samples\client\petstore\objc\default java %JAVA_OPTS% -DappName=PetstoreClient -jar %executable% %ags% diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java new file mode 100644 index 00000000000..d8ac36e78bd --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java @@ -0,0 +1,821 @@ +package io.swagger.codegen.languages; + +import com.google.common.base.Strings; +import io.swagger.codegen.*; +import io.swagger.models.Model; +import io.swagger.models.Operation; +import io.swagger.models.Path; +import io.swagger.models.Swagger; +import io.swagger.models.parameters.FormParameter; +import io.swagger.models.parameters.Parameter; +import io.swagger.models.properties.*; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.util.*; +import java.util.regex.Pattern; + + +public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig { + + public static final String FULL_JAVA_UTIL = "fullJavaUtil"; + public static final String DEFAULT_LIBRARY = ""; + public static final String DATE_LIBRARY = "dateLibrary"; + + protected String dateLibrary = "joda"; + protected String invokerPackage = "io.swagger"; + protected String groupId = "io.swagger"; + protected String artifactId = "swagger-java"; + protected String artifactVersion = "1.0.0"; + protected String projectFolder = "src" + File.separator + "main"; + protected String projectTestFolder = "src" + File.separator + "test"; + protected String sourceFolder = projectFolder + File.separator + "java"; + protected String testFolder = projectTestFolder + File.separator + "java"; + protected String localVariablePrefix = ""; + protected boolean fullJavaUtil; + protected String javaUtilPrefix = ""; + protected Boolean serializableModel = false; + protected boolean serializeBigDecimalAsString = false; + protected boolean hideGenerationTimestamp = false; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; + + public AbstractJavaCodegen() { + super(); + modelTemplateFiles.put("model.mustache", ".java"); + apiTemplateFiles.put("api.mustache", ".java"); + apiTestTemplateFiles.put("api_test.mustache", ".java"); + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); + + setReservedWordsLowerCase( + Arrays.asList( + // used as internal variables, can collide with parameter names + "localVarPath", "localVarQueryParams", "localVarHeaderParams", "localVarFormParams", + "localVarPostBody", "localVarAccepts", "localVarAccept", "localVarContentTypes", + "localVarContentType", "localVarAuthNames", "localReturnType", + "ApiClient", "ApiException", "ApiResponse", "Configuration", "StringUtil", + + // language reserved words + "abstract", "continue", "for", "new", "switch", "assert", + "default", "if", "package", "synchronized", "boolean", "do", "goto", "private", + "this", "break", "double", "implements", "protected", "throw", "byte", "else", + "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", + "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", + "void", "class", "finally", "long", "strictfp", "volatile", "const", "float", + "native", "super", "while") + ); + + languageSpecificPrimitives = new HashSet( + Arrays.asList( + "String", + "boolean", + "Boolean", + "Double", + "Integer", + "Long", + "Float", + "Object", + "byte[]") + ); + instantiationTypes.put("array", "ArrayList"); + instantiationTypes.put("map", "HashMap"); + typeMapping.put("date", "Date"); + typeMapping.put("file", "File"); + typeMapping.put("UUID", "String"); + + cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); + cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); + cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); + cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC)); + cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC)); + cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC)); + cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); + cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC)); + cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC)); + cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, CodegenConstants + .SERIALIZE_BIG_DECIMAL_AS_STRING_DESC)); + cliOptions.add(CliOption.newBoolean(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util")); + cliOptions.add(new CliOption("hideGenerationTimestamp", "hides the timestamp when files were generated")); + + CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use"); + Map dateOptions = new HashMap(); + dateOptions.put("java8", "Java 8 native"); + dateOptions.put("java8-localdatetime", "Java 8 using LocalDateTime (for legacy app only)"); + dateOptions.put("joda", "Joda"); + dateOptions.put("legacy", "Legacy java.util.Date"); + dateLibrary.setEnum(dateOptions); + + cliOptions.add(dateLibrary); + + } + + @Override + public void processOpts() { + super.processOpts(); + + if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { + this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); + } else { + //not set, use default to be passed to template + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + } + + if (additionalProperties.containsKey(CodegenConstants.GROUP_ID)) { + this.setGroupId((String) additionalProperties.get(CodegenConstants.GROUP_ID)); + } else { + //not set, use to be passed to template + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + } + + if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_ID)) { + this.setArtifactId((String) additionalProperties.get(CodegenConstants.ARTIFACT_ID)); + } else { + //not set, use to be passed to template + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + } + + if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) { + this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION)); + } else { + //not set, use to be passed to template + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); + } + + if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { + this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); + } + + if (additionalProperties.containsKey(CodegenConstants.LOCAL_VARIABLE_PREFIX)) { + this.setLocalVariablePrefix((String) additionalProperties.get(CodegenConstants.LOCAL_VARIABLE_PREFIX)); + } + + if (additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) { + this.setSerializableModel(Boolean.valueOf(additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL).toString())); + } + + if (additionalProperties.containsKey(CodegenConstants.LIBRARY)) { + this.setLibrary((String) additionalProperties.get(CodegenConstants.LIBRARY)); + } + + if(additionalProperties.containsKey(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING)) { + this.setSerializeBigDecimalAsString(Boolean.valueOf(additionalProperties.get(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING).toString())); + } + + // need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string + additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); + + if (additionalProperties.containsKey(FULL_JAVA_UTIL)) { + this.setFullJavaUtil(Boolean.valueOf(additionalProperties.get(FULL_JAVA_UTIL).toString())); + } + + if (fullJavaUtil) { + javaUtilPrefix = "java.util."; + } + additionalProperties.put(FULL_JAVA_UTIL, fullJavaUtil); + additionalProperties.put("javaUtilPrefix", javaUtilPrefix); + + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + + importMapping.put("List", "java.util.List"); + + if (fullJavaUtil) { + typeMapping.put("array", "java.util.List"); + typeMapping.put("map", "java.util.Map"); + typeMapping.put("DateTime", "java.util.Date"); + typeMapping.remove("List"); + importMapping.remove("Date"); + importMapping.remove("Map"); + importMapping.remove("HashMap"); + importMapping.remove("Array"); + importMapping.remove("ArrayList"); + importMapping.remove("List"); + importMapping.remove("Set"); + importMapping.remove("DateTime"); + instantiationTypes.put("array", "java.util.ArrayList"); + instantiationTypes.put("map", "java.util.HashMap"); + } + + this.sanitizeConfig(); + + // optional jackson mappings for BigDecimal support + importMapping.put("ToStringSerializer", "com.fasterxml.jackson.databind.ser.std.ToStringSerializer"); + importMapping.put("JsonSerialize", "com.fasterxml.jackson.databind.annotation.JsonSerialize"); + + // imports for pojos + importMapping.put("ApiModelProperty", "io.swagger.annotations.ApiModelProperty"); + importMapping.put("ApiModel", "io.swagger.annotations.ApiModel"); + importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty"); + importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue"); + importMapping.put("Objects", "java.util.Objects"); + importMapping.put("StringUtil", invokerPackage + ".StringUtil"); + + if(additionalProperties.containsKey(DATE_LIBRARY)) { + setDateLibrary(additionalProperties.get("dateLibrary").toString()); + additionalProperties.put(dateLibrary, "true"); + } + + if("joda".equals(dateLibrary)) { + typeMapping.put("date", "LocalDate"); + typeMapping.put("DateTime", "DateTime"); + + importMapping.put("LocalDate", "org.joda.time.LocalDate"); + importMapping.put("DateTime", "org.joda.time.DateTime"); + } + else if (dateLibrary.startsWith("java8")) { + additionalProperties.put("java8", "true"); + typeMapping.put("date", "LocalDate"); + importMapping.put("LocalDate", "java.time.LocalDate"); + if ("java8-localdatetime".equals(dateLibrary)) { + typeMapping.put("DateTime", "LocalDateTime"); + importMapping.put("LocalDateTime", "java.time.LocalDateTime"); + } else { + typeMapping.put("DateTime", "OffsetDateTime"); + importMapping.put("OffsetDateTime", "java.time.OffsetDateTime"); + } + } + } + + private void sanitizeConfig() { + // Sanitize any config options here. We also have to update the additionalProperties because + // the whole additionalProperties object is injected into the main object passed to the mustache layer + + this.setApiPackage(sanitizePackageName(apiPackage)); + if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) { + this.additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); + } + + this.setModelPackage(sanitizePackageName(modelPackage)); + if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) { + this.additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); + } + + this.setInvokerPackage(sanitizePackageName(invokerPackage)); + if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { + this.additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + } + } + + @Override + public String escapeReservedWord(String name) { + return "_" + name; + } + + @Override + public String apiFileFolder() { + return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', '/'); + } + + @Override + public String apiTestFileFolder() { + return outputFolder + "/" + testFolder + "/" + apiPackage().replace('.', '/'); + } + + @Override + public String modelFileFolder() { + return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', '/'); + } + + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); + } + + @Override + public String toApiDocFilename(String name) { + return toApiName(name); + } + + @Override + public String toModelDocFilename(String name) { + return toModelName(name); + } + + @Override + public String toApiTestFilename(String name) { + return toApiName(name) + "Test"; + } + + @Override + public String toVarName(String name) { + // sanitize name + name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. + + if ("class".equals(name.toLowerCase())) { + return "PropertyClass"; + } + + if("_".equals(name)) { + name = "_u"; + } + + // if it's all uppper case, do nothing + if (name.matches("^[A-Z_]*$")) { + return name; + } + + // camelize (lower first character) the variable name + // pet_id => petId + name = camelize(name, true); + + // for reserved word or word starting with number, append _ + if (isReservedWord(name) || name.matches("^\\d.*")) { + name = escapeReservedWord(name); + } + + return name; + } + + @Override + public String toParamName(String name) { + // should be the same as variable name + return toVarName(name); + } + + @Override + public String toModelName(final String name) { + final String sanitizedName = sanitizeName(modelNamePrefix + name + modelNameSuffix); + + // camelize the model name + // phone_number => PhoneNumber + final String camelizedName = camelize(sanitizedName); + + // model name cannot use reserved keyword, e.g. return + if (isReservedWord(camelizedName)) { + final String modelName = "Model" + camelizedName; + LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName); + return modelName; + } + + // model name starts with number + if (name.matches("^\\d.*")) { + final String modelName = "Model" + camelizedName; // e.g. 200Response => Model200Response (after camelize) + LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName); + return modelName; + } + + return camelizedName; + } + + @Override + public String toModelFilename(String name) { + // should be the same as the model name + return toModelName(name); + } + + @Override + public String getTypeDeclaration(Property p) { + if (p instanceof ArrayProperty) { + ArrayProperty ap = (ArrayProperty) p; + Property inner = ap.getItems(); + return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">"; + } else if (p instanceof MapProperty) { + MapProperty mp = (MapProperty) p; + Property inner = mp.getAdditionalProperties(); + + return getSwaggerType(p) + ""; + } + return super.getTypeDeclaration(p); + } + + @Override + public String toDefaultValue(Property p) { + if (p instanceof ArrayProperty) { + final ArrayProperty ap = (ArrayProperty) p; + final String pattern; + if (fullJavaUtil) { + pattern = "new java.util.ArrayList<%s>()"; + } else { + pattern = "new ArrayList<%s>()"; + } + return String.format(pattern, getTypeDeclaration(ap.getItems())); + } else if (p instanceof MapProperty) { + final MapProperty ap = (MapProperty) p; + final String pattern; + if (fullJavaUtil) { + pattern = "new java.util.HashMap()"; + } else { + pattern = "new HashMap()"; + } + return String.format(pattern, getTypeDeclaration(ap.getAdditionalProperties())); + } else if (p instanceof IntegerProperty) { + IntegerProperty dp = (IntegerProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + return "null"; + } else if (p instanceof LongProperty) { + LongProperty dp = (LongProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString()+"l"; + } + return "null"; + } else if (p instanceof DoubleProperty) { + DoubleProperty dp = (DoubleProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString() + "d"; + } + return "null"; + } else if (p instanceof FloatProperty) { + FloatProperty dp = (FloatProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString() + "f"; + } + return "null"; + } else if (p instanceof BooleanProperty) { + BooleanProperty bp = (BooleanProperty) p; + if (bp.getDefault() != null) { + return bp.getDefault().toString(); + } + return "null"; + } else if (p instanceof StringProperty) { + StringProperty sp = (StringProperty) p; + if (sp.getDefault() != null) { + String _default = sp.getDefault(); + if (sp.getEnum() == null) { + return "\"" + escapeText(_default) + "\""; + } else { + // convert to enum var name later in postProcessModels + return _default; + } + } + return "null"; + } + return super.toDefaultValue(p); + } + + @Override + public void setParameterExampleValue(CodegenParameter p) { + String example; + + if (p.defaultValue == null) { + example = p.example; + } else { + example = p.defaultValue; + } + + String type = p.baseType; + if (type == null) { + type = p.dataType; + } + + if ("String".equals(type)) { + if (example == null) { + example = p.paramName + "_example"; + } + example = "\"" + escapeText(example) + "\""; + } else if ("Integer".equals(type) || "Short".equals(type)) { + if (example == null) { + example = "56"; + } + } else if ("Long".equals(type)) { + if (example == null) { + example = "56"; + } + example = example + "L"; + } else if ("Float".equals(type)) { + if (example == null) { + example = "3.4"; + } + example = example + "F"; + } else if ("Double".equals(type)) { + example = "3.4"; + example = example + "D"; + } else if ("Boolean".equals(type)) { + if (example == null) { + example = "true"; + } + } else if ("File".equals(type)) { + if (example == null) { + example = "/path/to/file"; + } + example = "new File(\"" + escapeText(example) + "\")"; + } else if ("Date".equals(type)) { + example = "new Date()"; + } else if (!languageSpecificPrimitives.contains(type)) { + // type is a model class, e.g. User + example = "new " + type + "()"; + } + + if (example == null) { + example = "null"; + } else if (Boolean.TRUE.equals(p.isListContainer)) { + example = "Arrays.asList(" + example + ")"; + } else if (Boolean.TRUE.equals(p.isMapContainer)) { + example = "new HashMap()"; + } + + p.example = example; + } + + @Override + public String getSwaggerType(Property p) { + String swaggerType = super.getSwaggerType(p); + String type; + if (typeMapping.containsKey(swaggerType)) { + type = typeMapping.get(swaggerType); + if (languageSpecificPrimitives.contains(type) || type.indexOf(".") >= 0 || + type.equals("Map") || type.equals("List") || + type.equals("File") || type.equals("Date")) { + return type; + } + } else { + type = swaggerType; + } + if (null == type) { + LOGGER.error("No Type defined for Property " + p); + } + return toModelName(type); + } + + @Override + public String toOperationId(String operationId) { + // throw exception if method name is empty + if (StringUtils.isEmpty(operationId)) { + throw new RuntimeException("Empty method/operation name (operationId) not allowed"); + } + + operationId = camelize(sanitizeName(operationId), true); + + // method name cannot use reserved keyword, e.g. return + if (isReservedWord(operationId)) { + String newOperationId = camelize("call_" + operationId, true); + LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId); + return newOperationId; + } + + return operationId; + } + + @Override + public CodegenModel fromModel(String name, Model model, Map allDefinitions) { + CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); + if(codegenModel.description != null) { + codegenModel.imports.add("ApiModel"); + } + if (allDefinitions != null && codegenModel != null && codegenModel.parentSchema != null && codegenModel.hasEnums) { + final Model parentModel = allDefinitions.get(codegenModel.parentSchema); + final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel); + codegenModel = AbstractJavaCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel); + } + + return codegenModel; + } + + @Override + public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { + if(serializeBigDecimalAsString) { + if (property.baseType.equals("BigDecimal")) { + // we serialize BigDecimal as `string` to avoid precision loss + property.vendorExtensions.put("extraAnnotation", "@JsonSerialize(using = ToStringSerializer.class)"); + + // this requires some more imports to be added for this model... + model.imports.add("ToStringSerializer"); + model.imports.add("JsonSerialize"); + } + } + + if ("array".equals(property.containerType)) { + model.imports.add("ArrayList"); + } else if ("map".equals(property.containerType)) { + model.imports.add("HashMap"); + } + + if(!BooleanUtils.toBoolean(model.isEnum)) { + // needed by all pojos, but not enums + model.imports.add("ApiModelProperty"); + model.imports.add("ApiModel"); + } + return; + } + + @Override + public void postProcessParameter(CodegenParameter parameter) { } + + @Override + public Map postProcessModels(Map objs) { + return postProcessModelsEnum(objs); + } + + @Override + public Map postProcessOperations(Map objs) { + // Remove imports of List, ArrayList, Map and HashMap as they are + // imported in the template already. + List> imports = (List>) objs.get("imports"); + Pattern pattern = Pattern.compile("java\\.util\\.(List|ArrayList|Map|HashMap)"); + for (Iterator> itr = imports.iterator(); itr.hasNext();) { + String _import = itr.next().get("import"); + if (pattern.matcher(_import).matches()) { + itr.remove(); + } + } + return objs; + } + + @Override + public void preprocessSwagger(Swagger swagger) { + if (swagger != null && swagger.getPaths() != null) { + for (String pathname : swagger.getPaths().keySet()) { + Path path = swagger.getPath(pathname); + if (path.getOperations() != null) { + for (Operation operation : path.getOperations()) { + boolean hasFormParameters = false; + for (Parameter parameter : operation.getParameters()) { + if (parameter instanceof FormParameter) { + hasFormParameters = true; + } + } + + String defaultContentType = hasFormParameters ? "application/x-www-form-urlencoded" : "application/json"; + String contentType = operation.getConsumes() == null || operation.getConsumes().isEmpty() + ? defaultContentType : operation.getConsumes().get(0); + String accepts = getAccept(operation); + operation.setVendorExtension("x-contentType", contentType); + operation.setVendorExtension("x-accepts", accepts); + } + } + } + } + } + + private static String getAccept(Operation operation) { + String accepts = null; + String defaultContentType = "application/json"; + if (operation.getProduces() != null && !operation.getProduces().isEmpty()) { + StringBuilder sb = new StringBuilder(); + for (String produces : operation.getProduces()) { + if (defaultContentType.equalsIgnoreCase(produces)) { + accepts = defaultContentType; + break; + } else { + if (sb.length() > 0) { + sb.append(","); + } + sb.append(produces); + } + } + if (accepts == null) { + accepts = sb.toString(); + } + } else { + accepts = defaultContentType; + } + + return accepts; + } + + @Override + protected boolean needToImport(String type) { + return super.needToImport(type) && type.indexOf(".") < 0; + } +/* + @Override + public String findCommonPrefixOfVars(List vars) { + String prefix = StringUtils.getCommonPrefix(vars.toArray(new String[vars.size()])); + // exclude trailing characters that should be part of a valid variable + // e.g. ["status-on", "status-off"] => "status-" (not "status-o") + return prefix.replaceAll("[a-zA-Z0-9]+\\z", ""); + } +*/ + + @Override + public String toEnumName(CodegenProperty property) { + return sanitizeName(camelize(property.name)) + "Enum"; + } + + @Override + public String toEnumVarName(String value, String datatype) { + // number + if ("Integer".equals(datatype) || "Long".equals(datatype) || + "Float".equals(datatype) || "Double".equals(datatype)) { + String varName = "NUMBER_" + value; + varName = varName.replaceAll("-", "MINUS_"); + varName = varName.replaceAll("\\+", "PLUS_"); + varName = varName.replaceAll("\\.", "_DOT_"); + return varName; + } + + // string + String var = value.replaceAll("\\W+", "_").replaceAll("_+", "_").toUpperCase(); + if (var.matches("\\d.*")) { + return "_" + var; + } else { + return var; + } + } + + @Override + public String toEnumValue(String value, String datatype) { + if ("Integer".equals(datatype) || "Long".equals(datatype) || + "Float".equals(datatype) || "Double".equals(datatype)) { + return value; + } else { + return "\"" + escapeText(value) + "\""; + } + } + + private static CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) { + // This generator uses inline classes to define enums, which breaks when + // dealing with models that have subTypes. To clean this up, we will analyze + // the parent and child models, look for enums that match, and remove + // them from the child models and leave them in the parent. + // Because the child models extend the parents, the enums will be available via the parent. + + // Only bother with reconciliation if the parent model has enums. + if (parentCodegenModel.hasEnums) { + + // Get the properties for the parent and child models + final List parentModelCodegenProperties = parentCodegenModel.vars; + List codegenProperties = codegenModel.vars; + + // Iterate over all of the parent model properties + boolean removedChildEnum = false; + for (CodegenProperty parentModelCodegenPropery : parentModelCodegenProperties) { + // Look for enums + if (parentModelCodegenPropery.isEnum) { + // Now that we have found an enum in the parent class, + // and search the child class for the same enum. + Iterator iterator = codegenProperties.iterator(); + while (iterator.hasNext()) { + CodegenProperty codegenProperty = iterator.next(); + if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenPropery)) { + // We found an enum in the child class that is + // a duplicate of the one in the parent, so remove it. + iterator.remove(); + removedChildEnum = true; + } + } + } + } + + if(removedChildEnum) { + // If we removed an entry from this model's vars, we need to ensure hasMore is updated + int count = 0, numVars = codegenProperties.size(); + for(CodegenProperty codegenProperty : codegenProperties) { + count += 1; + codegenProperty.hasMore = (count < numVars) ? true : null; + } + codegenModel.vars = codegenProperties; + } + } + + return codegenModel; + } + + private static String sanitizePackageName(String packageName) { + packageName = packageName.trim(); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. + packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_"); + if(Strings.isNullOrEmpty(packageName)) { + return "invalidPackageName"; + } + return packageName; + } + + public void setInvokerPackage(String invokerPackage) { + this.invokerPackage = invokerPackage; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public void setArtifactId(String artifactId) { + this.artifactId = artifactId; + } + + public void setArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + } + + public void setSourceFolder(String sourceFolder) { + this.sourceFolder = sourceFolder; + } + + public void setLocalVariablePrefix(String localVariablePrefix) { + this.localVariablePrefix = localVariablePrefix; + } + + public void setSerializeBigDecimalAsString(boolean s) { + this.serializeBigDecimalAsString = s; + } + + public void setSerializableModel(Boolean serializableModel) { + this.serializableModel = serializableModel; + } + + public void setFullJavaUtil(boolean fullJavaUtil) { + this.fullJavaUtil = fullJavaUtil; + } + + public void setDateLibrary(String library) { + this.dateLibrary = library; + } +} 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 fbb2831ab8b..d1458514256 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 @@ -1,9 +1,6 @@ package io.swagger.codegen.languages; -import io.swagger.codegen.CodegenOperation; -import io.swagger.codegen.CodegenParameter; -import io.swagger.codegen.CodegenResponse; -import io.swagger.codegen.CodegenType; +import io.swagger.codegen.*; import io.swagger.models.Operation; import io.swagger.models.Path; import io.swagger.models.Swagger; @@ -13,7 +10,7 @@ import org.slf4j.LoggerFactory; import java.util.*; -public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen { +public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen { /** * Name of the sub-directory in "src/main/resource" where to find the * Mustache template for the JAX-RS Codegen. @@ -26,28 +23,22 @@ public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen { public AbstractJavaJAXRSServerCodegen() { super(); - dateLibrary = "legacy"; - apiTestTemplateFiles.clear(); // TODO: add test template + + sourceFolder = "src/gen/java"; + invokerPackage = "io.swagger.api"; + artifactId = "swagger-jaxrs-server"; + dateLibrary = "legacy"; //TODO: add joda support to all jax-rs + + apiPackage = "io.swagger.api"; + modelPackage = "io.swagger.model"; + + additionalProperties.put("title", title); + + cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC)); + cliOptions.add(new CliOption("title", "a title describing the application")); + } - @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 - // ================ - - @Override - public abstract String getHelp(); - - @Override - public abstract String getName(); // =============== // COMMONS METHODS @@ -59,6 +50,15 @@ public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen { return CodegenType.SERVER; } + @Override + public void processOpts() { + super.processOpts(); + + if (additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) { + implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER); + } + } + @Override public void preprocessSwagger(Swagger swagger) { if ( "/".equals(swagger.getBasePath()) ) { 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 index 5b26662531f..3f9bfbfc6b3 100644 --- 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 @@ -1,16 +1,13 @@ 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 class GroovyClientCodegen extends AbstractJavaCodegen { public static final String CONFIG_PACKAGE = "configPackage"; protected String title = "Petstore Server"; protected String configPackage = ""; - protected String templateFileName = "api.mustache"; public GroovyClientCodegen() { super(); @@ -18,28 +15,28 @@ public class GroovyClientCodegen extends JavaClientCodegen { sourceFolder = projectFolder + File.separator + "groovy"; outputFolder = "generated-code/groovy"; modelTemplateFiles.put("model.mustache", ".groovy"); - apiTemplateFiles.put(templateFileName, ".groovy"); + apiTemplateFiles.put("api.mustache", ".groovy"); apiTestTemplateFiles.clear(); // TODO: add test template embeddedTemplateDir = templateDir = "Groovy"; + + // clear model and api doc template as this codegen + // does not support auto-generated markdown doc at the moment + //TODO: add doc templates + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); apiPackage = "io.swagger.api"; modelPackage = "io.swagger.model"; configPackage = "io.swagger.configuration"; invokerPackage = "io.swagger.api"; - artifactId = "swagger-spring-mvc-server"; - dateLibrary = "legacy"; + artifactId = "swagger-groovy"; + dateLibrary = "legacy"; //TODO: add joda support to groovy - 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 @@ -61,16 +58,10 @@ public class GroovyClientCodegen 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)); } - 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")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java index 5321e3a59db..c9d558d51ab 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java @@ -2,12 +2,9 @@ package io.swagger.codegen.languages; import java.io.File; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import io.swagger.codegen.CliOption; -import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenModel; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenProperty; @@ -19,56 +16,26 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen { super(); supportsInheritance = true; - sourceFolder = "src/gen/java"; - invokerPackage = "io.swagger.api"; - artifactId = "swagger-jaxrs-server"; + sourceFolder = "gen" + File.separator + "java"; outputFolder = "generated-code/JavaJaxRS-CXF"; + apiTestTemplateFiles.clear(); // TODO: add test template - modelTemplateFiles.put("model.mustache", ".java"); - apiTemplateFiles.put("api.mustache", ".java"); - apiPackage = "io.swagger.api"; - modelPackage = "io.swagger.model"; + // clear model and api doc template as this codegen + // does not support auto-generated markdown doc at the moment + //TODO: add doc templates + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); - additionalProperties.put("title", title); typeMapping.put("date", "LocalDate"); typeMapping.put("DateTime", "javax.xml.datatype.XMLGregorianCalendar"); // Map DateTime fields to Java standart class 'XMLGregorianCalendar' importMapping.put("LocalDate", "org.joda.time.LocalDate"); - super.embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf"; + embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf"; - for ( int i = 0; i < cliOptions.size(); i++ ) { - if ( CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt()) ) { - cliOptions.remove(i); - break; - } - } - - CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); - library.setDefault(DEFAULT_LIBRARY); - - Map supportedLibraries = new LinkedHashMap(); - - supportedLibraries.put(DEFAULT_LIBRARY, "CXF"); - library.setEnum(supportedLibraries); - - cliOptions.add(library); - cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC)); - cliOptions.add(new CliOption("title", "a title describing the application")); } - - @Override - public void processOpts() - { - super.processOpts(); - sourceFolder = "gen" + File.separator + "java"; - supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen - - //TODO - //final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/"); - //supportingFiles.add(new SupportingFile("CXF2InterfaceComparator.mustache", invokerFolder, "CXF2InterfaceComparator.java")); - } + @Override public String getName() @@ -89,8 +56,6 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen model.imports.remove("ApiModel"); model.imports.remove("JsonSerialize"); model.imports.remove("ToStringSerializer"); - model.imports.remove("JsonValue"); - model.imports.remove("JsonProperty"); } @Override 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 ad4750cf8ce..be80900505b 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 @@ -1,115 +1,36 @@ package io.swagger.codegen.languages; -import com.google.common.base.Strings; import io.swagger.codegen.*; -import io.swagger.models.Model; -import io.swagger.models.Operation; -import io.swagger.models.Path; -import io.swagger.models.Swagger; -import io.swagger.models.parameters.FormParameter; -import io.swagger.models.parameters.Parameter; -import io.swagger.models.properties.*; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; -//import org.apache.commons.lang3.WordUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.util.*; -import java.util.regex.Pattern; -public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { +public class JavaClientCodegen extends AbstractJavaCodegen { @SuppressWarnings("hiding") private static final Logger LOGGER = LoggerFactory.getLogger(JavaClientCodegen.class); - public static final String FULL_JAVA_UTIL = "fullJavaUtil"; - public static final String DEFAULT_LIBRARY = ""; - public static final String DATE_LIBRARY = "dateLibrary"; + public static final String USE_RX_JAVA = "useRxJava"; public static final String RETROFIT_1 = "retrofit"; public static final String RETROFIT_2 = "retrofit2"; - protected String dateLibrary = "joda"; - protected String invokerPackage = "io.swagger.client"; - protected String groupId = "io.swagger"; - protected String artifactId = "swagger-java-client"; - protected String artifactVersion = "1.0.0"; - protected String projectFolder = "src" + File.separator + "main"; - protected String projectTestFolder = "src" + File.separator + "test"; - protected String sourceFolder = projectFolder + File.separator + "java"; - protected String testFolder = projectTestFolder + File.separator + "java"; protected String gradleWrapperPackage = "gradle.wrapper"; - protected String localVariablePrefix = ""; - protected boolean fullJavaUtil; - protected String javaUtilPrefix = ""; - protected Boolean serializableModel = false; - protected boolean serializeBigDecimalAsString = false; protected boolean useRxJava = false; - protected boolean hideGenerationTimestamp = false; - protected String apiDocPath = "docs/"; - protected String modelDocPath = "docs/"; public JavaClientCodegen() { super(); outputFolder = "generated-code" + File.separator + "java"; - modelTemplateFiles.put("model.mustache", ".java"); - apiTemplateFiles.put("api.mustache", ".java"); - apiTestTemplateFiles.put("api_test.mustache", ".java"); embeddedTemplateDir = templateDir = "Java"; + invokerPackage = "io.swagger.client"; + artifactId = "swagger-java-client"; apiPackage = "io.swagger.client.api"; modelPackage = "io.swagger.client.model"; - setReservedWordsLowerCase( - Arrays.asList( - // used as internal variables, can collide with parameter names - "localVarPath", "localVarQueryParams", "localVarHeaderParams", "localVarFormParams", - "localVarPostBody", "localVarAccepts", "localVarAccept", "localVarContentTypes", - "localVarContentType", "localVarAuthNames", "localReturnType", - "ApiClient", "ApiException", "ApiResponse", "Configuration", "StringUtil", - - // language reserved words - "abstract", "continue", "for", "new", "switch", "assert", - "default", "if", "package", "synchronized", "boolean", "do", "goto", "private", - "this", "break", "double", "implements", "protected", "throw", "byte", "else", - "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", - "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", - "void", "class", "finally", "long", "strictfp", "volatile", "const", "float", - "native", "super", "while") - ); - - languageSpecificPrimitives = new HashSet( - Arrays.asList( - "String", - "boolean", - "Boolean", - "Double", - "Integer", - "Long", - "Float", - "Object", - "byte[]") - ); - instantiationTypes.put("array", "ArrayList"); - instantiationTypes.put("map", "HashMap"); - typeMapping.put("date", "Date"); - typeMapping.put("file", "File"); - typeMapping.put("UUID", "String"); - - cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); - cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); - cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); - cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC)); - cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC)); - cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC)); - cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); - cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC)); - cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC)); - cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, CodegenConstants - .SERIALIZE_BIG_DECIMAL_AS_STRING_DESC)); - cliOptions.add(CliOption.newBoolean(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util")); cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library.")); - cliOptions.add(new CliOption("hideGenerationTimestamp", "hides the timestamp when files were generated")); supportedLibraries.put(DEFAULT_LIBRARY, "HTTP client: Jersey client 1.19.1. JSON processing: Jackson 2.7.0"); supportedLibraries.put("feign", "HTTP client: Netflix Feign 8.16.0. JSON processing: Jackson 2.7.0"); @@ -124,15 +45,6 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { library.setDefault(DEFAULT_LIBRARY); cliOptions.add(library); - CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use"); - Map dateOptions = new HashMap(); - dateOptions.put("java8", "Java 8 native"); - dateOptions.put("java8-localdatetime", "Java 8 using LocalDateTime (for legacy app only)"); - dateOptions.put("joda", "Joda"); - dateOptions.put("legacy", "Legacy java.util.Date"); - dateLibrary.setEnum(dateOptions); - - cliOptions.add(dateLibrary); } @Override @@ -154,109 +66,14 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { public void processOpts() { super.processOpts(); - if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { - this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); - } else { - //not set, use default to be passed to template - additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); - } - - if (additionalProperties.containsKey(CodegenConstants.GROUP_ID)) { - this.setGroupId((String) additionalProperties.get(CodegenConstants.GROUP_ID)); - } else { - //not set, use to be passed to template - additionalProperties.put(CodegenConstants.GROUP_ID, groupId); - } - - if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_ID)) { - this.setArtifactId((String) additionalProperties.get(CodegenConstants.ARTIFACT_ID)); - } else { - //not set, use to be passed to template - additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); - } - - if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) { - this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION)); - } else { - //not set, use to be passed to template - additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); - } - - if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { - this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); - } - - if (additionalProperties.containsKey(CodegenConstants.LOCAL_VARIABLE_PREFIX)) { - this.setLocalVariablePrefix((String) additionalProperties.get(CodegenConstants.LOCAL_VARIABLE_PREFIX)); - } - - if (additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) { - this.setSerializableModel(Boolean.valueOf(additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL).toString())); - } - - if (additionalProperties.containsKey(CodegenConstants.LIBRARY)) { - this.setLibrary((String) additionalProperties.get(CodegenConstants.LIBRARY)); - } - - if(additionalProperties.containsKey(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING)) { - this.setSerializeBigDecimalAsString(Boolean.valueOf(additionalProperties.get(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING).toString())); - } - - // need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string - additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); - - if (additionalProperties.containsKey(FULL_JAVA_UTIL)) { - this.setFullJavaUtil(Boolean.valueOf(additionalProperties.get(FULL_JAVA_UTIL).toString())); - } - if (additionalProperties.containsKey(USE_RX_JAVA)) { this.setUseRxJava(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA).toString())); } - if (fullJavaUtil) { - javaUtilPrefix = "java.util."; - } - additionalProperties.put(FULL_JAVA_UTIL, fullJavaUtil); - additionalProperties.put("javaUtilPrefix", javaUtilPrefix); - - // make api and model doc path available in mustache template - additionalProperties.put("apiDocPath", apiDocPath); - additionalProperties.put("modelDocPath", modelDocPath); - - importMapping.put("List", "java.util.List"); - - if (fullJavaUtil) { - typeMapping.put("array", "java.util.List"); - typeMapping.put("map", "java.util.Map"); - typeMapping.put("DateTime", "java.util.Date"); - typeMapping.remove("List"); - importMapping.remove("Date"); - importMapping.remove("Map"); - importMapping.remove("HashMap"); - importMapping.remove("Array"); - importMapping.remove("ArrayList"); - importMapping.remove("List"); - importMapping.remove("Set"); - importMapping.remove("DateTime"); - instantiationTypes.put("array", "java.util.ArrayList"); - instantiationTypes.put("map", "java.util.HashMap"); - } - - this.sanitizeConfig(); - - - // optional jackson mappings for BigDecimal support - importMapping.put("ToStringSerializer", "com.fasterxml.jackson.databind.ser.std.ToStringSerializer"); - importMapping.put("JsonSerialize", "com.fasterxml.jackson.databind.annotation.JsonSerialize"); - - // imports for pojos - importMapping.put("ApiModelProperty", "io.swagger.annotations.ApiModelProperty"); - importMapping.put("ApiModel", "io.swagger.annotations.ApiModel"); - importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty"); - importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue"); - importMapping.put("Objects", "java.util.Objects"); - importMapping.put("StringUtil", invokerPackage + ".StringUtil"); final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/"); + final String authFolder = (sourceFolder + '/' + invokerPackage + ".auth").replace(".", "/"); + + //Common files writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml")); writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md")); writeOptional(outputFolder, new SupportingFile("build.gradle.mustache", "", "build.gradle")); @@ -266,25 +83,29 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml")); supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java")); supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java")); - - final String authFolder = (sourceFolder + '/' + invokerPackage + ".auth").replace(".", "/"); - if ("feign".equals(getLibrary())) { - supportingFiles.add(new SupportingFile("FormAwareEncoder.mustache", invokerFolder, "FormAwareEncoder.java")); - - //gradleWrapper files - supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") ); - supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") ); - supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache", - gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") ); - supportingFiles.add( new SupportingFile( "gradle-wrapper.jar", - gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") ); - // "build.sbt" is for development with SBT - supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt")); - } supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java")); supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java")); supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java")); supportingFiles.add(new SupportingFile("auth/OAuthFlow.mustache", authFolder, "OAuthFlow.java")); + supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") ); + supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") ); + supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache", + gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") ); + supportingFiles.add( new SupportingFile( "gradle-wrapper.jar", + gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") ); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + + if (!StringUtils.isEmpty(getLibrary())) { + //TODO: add sbt support to default client + supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt")); + } + + //TODO: add doc to retrofit1 and feign + if ( "feign".equals(getLibrary()) || "retrofit".equals(getLibrary()) ){ + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + } if (!("feign".equals(getLibrary()) || usesAnyRetrofitLibrary())) { supportingFiles.add(new SupportingFile("apiException.mustache", invokerFolder, "ApiException.java")); @@ -293,104 +114,21 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java")); } - // library-specific files - if (StringUtils.isEmpty(getLibrary())) { - // generate markdown docs - modelDocTemplateFiles.put("model_doc.mustache", ".md"); - apiDocTemplateFiles.put("api_doc.mustache", ".md"); - - //gradleWrapper files - supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") ); - supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") ); - supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache", - gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") ); - supportingFiles.add( new SupportingFile( "gradle-wrapper.jar", - gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") ); + if ("feign".equals(getLibrary())) { + supportingFiles.add(new SupportingFile("FormAwareEncoder.mustache", invokerFolder, "FormAwareEncoder.java")); } else if ("okhttp-gson".equals(getLibrary())) { - // generate markdown docs - modelDocTemplateFiles.put("model_doc.mustache", ".md"); - apiDocTemplateFiles.put("api_doc.mustache", ".md"); // the "okhttp-gson" library template requires "ApiCallback.mustache" for async call supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java")); supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java")); supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java")); supportingFiles.add(new SupportingFile("ProgressRequestBody.mustache", invokerFolder, "ProgressRequestBody.java")); supportingFiles.add(new SupportingFile("ProgressResponseBody.mustache", invokerFolder, "ProgressResponseBody.java")); - // "build.sbt" is for development with SBT - supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt")); - - //gradleWrapper files - supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") ); - supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") ); - supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache", - gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") ); - supportingFiles.add( new SupportingFile( "gradle-wrapper.jar", - gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") ); } else if (usesAnyRetrofitLibrary()) { supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java")); supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java")); - - //gradleWrapper files - supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") ); - supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") ); - supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache", - gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") ); - supportingFiles.add( new SupportingFile( "gradle-wrapper.jar", - gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") ); - // "build.sbt" is for development with SBT - supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt")); - - //generate markdown docs for retrofit2 - if ( usesRetrofit2Library() ){ - modelDocTemplateFiles.put("model_doc.mustache", ".md"); - apiDocTemplateFiles.put("api_doc.mustache", ".md"); - } - } else if("jersey2".equals(getLibrary())) { - // generate markdown docs - modelDocTemplateFiles.put("model_doc.mustache", ".md"); - apiDocTemplateFiles.put("api_doc.mustache", ".md"); supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java")); - - //gradleWrapper files - supportingFiles.add( new SupportingFile( "gradlew.mustache", "", "gradlew") ); - supportingFiles.add( new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") ); - supportingFiles.add( new SupportingFile( "gradle-wrapper.properties.mustache", - gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") ); - supportingFiles.add( new SupportingFile( "gradle-wrapper.jar", - gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") ); - // "build.sbt" is for development with SBT - supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt")); } - - if(additionalProperties.containsKey(DATE_LIBRARY)) { - setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString()); - additionalProperties.put(dateLibrary, "true"); - } - - if("joda".equals(dateLibrary)) { - typeMapping.put("date", "LocalDate"); - typeMapping.put("DateTime", "DateTime"); - - importMapping.put("LocalDate", "org.joda.time.LocalDate"); - importMapping.put("DateTime", "org.joda.time.DateTime"); - } - else if (dateLibrary.startsWith("java8")) { - additionalProperties.put("java8", "true"); - typeMapping.put("date", "LocalDate"); - importMapping.put("LocalDate", "java.time.LocalDate"); - if ("java8-localdatetime".equals(dateLibrary)) { - typeMapping.put("DateTime", "LocalDateTime"); - importMapping.put("LocalDateTime", "java.time.LocalDateTime"); - } else { - typeMapping.put("DateTime", "OffsetDateTime"); - importMapping.put("OffsetDateTime", "java.time.OffsetDateTime"); - } - } - - supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); - supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); - } private boolean usesAnyRetrofitLibrary() { @@ -401,416 +139,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { return getLibrary() != null && getLibrary().contains(RETROFIT_2); } - private void sanitizeConfig() { - // Sanitize any config options here. We also have to update the additionalProperties because - // the whole additionalProperties object is injected into the main object passed to the mustache layer - - this.setApiPackage(sanitizePackageName(apiPackage)); - if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) { - this.additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); - } - - this.setModelPackage(sanitizePackageName(modelPackage)); - if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) { - this.additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); - } - - this.setInvokerPackage(sanitizePackageName(invokerPackage)); - if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { - this.additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); - } - } - - @Override - public String escapeReservedWord(String name) { - return "_" + name; - } - - @Override - public String apiFileFolder() { - return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', '/'); - } - - @Override - public String apiTestFileFolder() { - return outputFolder + "/" + testFolder + "/" + apiPackage().replace('.', '/'); - } - - @Override - public String modelFileFolder() { - return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', '/'); - } - - @Override - public String apiDocFileFolder() { - return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); - } - - @Override - public String modelDocFileFolder() { - return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); - } - - @Override - public String toApiDocFilename(String name) { - return toApiName(name); - } - - @Override - public String toModelDocFilename(String name) { - return toModelName(name); - } - - @Override - public String toApiTestFilename(String name) { - return toApiName(name) + "Test"; - } - - @Override - public String toVarName(String name) { - // sanitize name - name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. - - if("_".equals(name)) { - name = "_u"; - } - - // if it's all uppper case, do nothing - if (name.matches("^[A-Z_]*$")) { - return name; - } - - // camelize (lower first character) the variable name - // pet_id => petId - name = camelize(name, true); - - // for reserved word or word starting with number, append _ - if (isReservedWord(name) || name.matches("^\\d.*")) { - name = escapeReservedWord(name); - } - - return name; - } - - @Override - public String toParamName(String name) { - // should be the same as variable name - return toVarName(name); - } - - @Override - public String toModelName(final String name) { - final String sanitizedName = sanitizeName(modelNamePrefix + name + modelNameSuffix); - - // camelize the model name - // phone_number => PhoneNumber - final String camelizedName = camelize(sanitizedName); - - // model name cannot use reserved keyword, e.g. return - if (isReservedWord(camelizedName)) { - final String modelName = "Model" + camelizedName; - LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName); - return modelName; - } - - // model name starts with number - if (name.matches("^\\d.*")) { - final String modelName = "Model" + camelizedName; // e.g. 200Response => Model200Response (after camelize) - LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName); - return modelName; - } - - return camelizedName; - } - - @Override - public String toModelFilename(String name) { - // should be the same as the model name - return toModelName(name); - } - - @Override - public String getTypeDeclaration(Property p) { - if (p instanceof ArrayProperty) { - ArrayProperty ap = (ArrayProperty) p; - Property inner = ap.getItems(); - return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">"; - } else if (p instanceof MapProperty) { - MapProperty mp = (MapProperty) p; - Property inner = mp.getAdditionalProperties(); - - return getSwaggerType(p) + ""; - } - return super.getTypeDeclaration(p); - } - - @Override - public String toDefaultValue(Property p) { - if (p instanceof ArrayProperty) { - final ArrayProperty ap = (ArrayProperty) p; - final String pattern; - if (fullJavaUtil) { - pattern = "new java.util.ArrayList<%s>()"; - } else { - pattern = "new ArrayList<%s>()"; - } - return String.format(pattern, getTypeDeclaration(ap.getItems())); - } else if (p instanceof MapProperty) { - final MapProperty ap = (MapProperty) p; - final String pattern; - if (fullJavaUtil) { - pattern = "new java.util.HashMap()"; - } else { - pattern = "new HashMap()"; - } - return String.format(pattern, getTypeDeclaration(ap.getAdditionalProperties())); - } else if (p instanceof IntegerProperty) { - IntegerProperty dp = (IntegerProperty) p; - if (dp.getDefault() != null) { - return dp.getDefault().toString(); - } - return "null"; - } else if (p instanceof LongProperty) { - LongProperty dp = (LongProperty) p; - if (dp.getDefault() != null) { - return dp.getDefault().toString()+"l"; - } - return "null"; - } else if (p instanceof DoubleProperty) { - DoubleProperty dp = (DoubleProperty) p; - if (dp.getDefault() != null) { - return dp.getDefault().toString() + "d"; - } - return "null"; - } else if (p instanceof FloatProperty) { - FloatProperty dp = (FloatProperty) p; - if (dp.getDefault() != null) { - return dp.getDefault().toString() + "f"; - } - return "null"; - } else if (p instanceof BooleanProperty) { - BooleanProperty bp = (BooleanProperty) p; - if (bp.getDefault() != null) { - return bp.getDefault().toString(); - } - return "null"; - } else if (p instanceof StringProperty) { - StringProperty sp = (StringProperty) p; - if (sp.getDefault() != null) { - String _default = sp.getDefault(); - if (sp.getEnum() == null) { - return "\"" + escapeText(_default) + "\""; - } else { - // convert to enum var name later in postProcessModels - return _default; - } - } - return "null"; - } - return super.toDefaultValue(p); - } - - @Override - public void setParameterExampleValue(CodegenParameter p) { - String example; - - if (p.defaultValue == null) { - example = p.example; - } else { - example = p.defaultValue; - } - - String type = p.baseType; - if (type == null) { - type = p.dataType; - } - - if ("String".equals(type)) { - if (example == null) { - example = p.paramName + "_example"; - } - example = "\"" + escapeText(example) + "\""; - } else if ("Integer".equals(type) || "Short".equals(type)) { - if (example == null) { - example = "56"; - } - } else if ("Long".equals(type)) { - if (example == null) { - example = "56"; - } - example = example + "L"; - } else if ("Float".equals(type)) { - if (example == null) { - example = "3.4"; - } - example = example + "F"; - } else if ("Double".equals(type)) { - example = "3.4"; - example = example + "D"; - } else if ("Boolean".equals(type)) { - if (example == null) { - example = "true"; - } - } else if ("File".equals(type)) { - if (example == null) { - example = "/path/to/file"; - } - example = "new File(\"" + escapeText(example) + "\")"; - } else if ("Date".equals(type)) { - example = "new Date()"; - } else if (!languageSpecificPrimitives.contains(type)) { - // type is a model class, e.g. User - example = "new " + type + "()"; - } - - if (example == null) { - example = "null"; - } else if (Boolean.TRUE.equals(p.isListContainer)) { - example = "Arrays.asList(" + example + ")"; - } else if (Boolean.TRUE.equals(p.isMapContainer)) { - example = "new HashMap()"; - } - - p.example = example; - } - - @Override - public String getSwaggerType(Property p) { - String swaggerType = super.getSwaggerType(p); - String type = null; - if (typeMapping.containsKey(swaggerType)) { - type = typeMapping.get(swaggerType); - if (languageSpecificPrimitives.contains(type) || type.indexOf(".") >= 0 || - type.equals("Map") || type.equals("List") || - type.equals("File") || type.equals("Date")) { - return type; - } - } else { - type = swaggerType; - } - if (null == type) { - LOGGER.error("No Type defined for Property " + p); - } - return toModelName(type); - } - - @Override - public String toOperationId(String operationId) { - // throw exception if method name is empty - if (StringUtils.isEmpty(operationId)) { - throw new RuntimeException("Empty method/operation name (operationId) not allowed"); - } - - operationId = camelize(sanitizeName(operationId), true); - - // method name cannot use reserved keyword, e.g. return - if (isReservedWord(operationId)) { - String newOperationId = camelize("call_" + operationId, true); - LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId); - return newOperationId; - } - - return operationId; - } - - @Override - public CodegenModel fromModel(String name, Model model, Map allDefinitions) { - CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); - if(codegenModel.description != null) { - codegenModel.imports.add("ApiModel"); - } - if (allDefinitions != null && codegenModel != null && codegenModel.parentSchema != null && codegenModel.hasEnums) { - final Model parentModel = allDefinitions.get(codegenModel.parentSchema); - final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel); - codegenModel = JavaClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel); - } - - return codegenModel; - } - - @Override - public Map postProcessModelsEnum(Map objs) { - objs = super.postProcessModelsEnum(objs); - String lib = getLibrary(); - if (StringUtils.isEmpty(lib) || "feign".equals(lib) || "jersey2".equals(lib)) { - List> imports = (List>)objs.get("imports"); - List models = (List) objs.get("models"); - for (Object _mo : models) { - Map mo = (Map) _mo; - CodegenModel cm = (CodegenModel) mo.get("model"); - // for enum model - if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) { - cm.imports.add(importMapping.get("JsonValue")); - Map item = new HashMap(); - item.put("import", importMapping.get("JsonValue")); - imports.add(item); - } - } - } - return objs; - } - - @Override - public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { - if(serializeBigDecimalAsString) { - if (property.baseType.equals("BigDecimal")) { - // we serialize BigDecimal as `string` to avoid precision loss - property.vendorExtensions.put("extraAnnotation", "@JsonSerialize(using = ToStringSerializer.class)"); - - // this requires some more imports to be added for this model... - model.imports.add("ToStringSerializer"); - model.imports.add("JsonSerialize"); - } - } - - if ("array".equals(property.containerType)) { - model.imports.add("ArrayList"); - } else if ("map".equals(property.containerType)) { - model.imports.add("HashMap"); - } - - if(!BooleanUtils.toBoolean(model.isEnum)) { - // needed by all pojos, but not enums - model.imports.add("ApiModelProperty"); - model.imports.add("ApiModel"); - // comment out below as it's in the model template - //model.imports.add("Objects"); - - final String lib = getLibrary(); - if(StringUtils.isEmpty(lib) || "feign".equals(lib) || "jersey2".equals(lib)) { - model.imports.add("JsonProperty"); - - if(BooleanUtils.toBoolean(model.hasEnums)) { - model.imports.add("JsonValue"); - } - } - } - return; - } - - @Override - public void postProcessParameter(CodegenParameter parameter) { - return; - } - - @Override - public Map postProcessModels(Map objs) { - return postProcessModelsEnum(objs); - } - @Override public Map postProcessOperations(Map objs) { - // Remove imports of List, ArrayList, Map and HashMap as they are - // imported in the template already. - List> imports = (List>) objs.get("imports"); - Pattern pattern = Pattern.compile("java\\.util\\.(List|ArrayList|Map|HashMap)"); - for (Iterator> itr = imports.iterator(); itr.hasNext();) { - String _import = itr.next().get("import"); - if (pattern.matcher(_import).matches()) { - itr.remove(); - } - } - + super.postProcessOperations(objs); if(usesAnyRetrofitLibrary()) { Map operations = (Map) objs.get("operations"); if (operations != null) { @@ -836,207 +167,45 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } @Override - public void preprocessSwagger(Swagger swagger) { - if (swagger != null && swagger.getPaths() != null) { - for (String pathname : swagger.getPaths().keySet()) { - Path path = swagger.getPath(pathname); - if (path.getOperations() != null) { - for (Operation operation : path.getOperations()) { - boolean hasFormParameters = false; - for (Parameter parameter : operation.getParameters()) { - if (parameter instanceof FormParameter) { - hasFormParameters = true; - } - } + public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { + super.postProcessModelProperty(model, property); + if(!BooleanUtils.toBoolean(model.isEnum)) { + final String lib = getLibrary(); + //Needed imports for Jackson based libraries + if(StringUtils.isEmpty(lib) || "feign".equals(lib) || "jersey2".equals(lib)) { + model.imports.add("JsonProperty"); - String defaultContentType = hasFormParameters ? "application/x-www-form-urlencoded" : "application/json"; - String contentType = operation.getConsumes() == null || operation.getConsumes().isEmpty() - ? defaultContentType : operation.getConsumes().get(0); - String accepts = getAccept(operation); - operation.setVendorExtension("x-contentType", contentType); - operation.setVendorExtension("x-accepts", accepts); - } + if(BooleanUtils.toBoolean(model.hasEnums)) { + model.imports.add("JsonValue"); } } } } - private static String getAccept(Operation operation) { - String accepts = null; - String defaultContentType = "application/json"; - if (operation.getProduces() != null && !operation.getProduces().isEmpty()) { - StringBuilder sb = new StringBuilder(); - for (String produces : operation.getProduces()) { - if (defaultContentType.equalsIgnoreCase(produces)) { - accepts = defaultContentType; - break; - } else { - if (sb.length() > 0) { - sb.append(","); - } - sb.append(produces); + @Override + public Map postProcessModelsEnum(Map objs) { + objs = super.postProcessModelsEnum(objs); + String lib = getLibrary(); + //Needed imports for Jackson based libraries + if (StringUtils.isEmpty(lib) || "feign".equals(lib) || "jersey2".equals(lib)) { + List> imports = (List>)objs.get("imports"); + List models = (List) objs.get("models"); + for (Object _mo : models) { + Map mo = (Map) _mo; + CodegenModel cm = (CodegenModel) mo.get("model"); + // for enum model + if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) { + cm.imports.add(importMapping.get("JsonValue")); + Map item = new HashMap(); + item.put("import", importMapping.get("JsonValue")); + imports.add(item); } } - if (accepts == null) { - accepts = sb.toString(); - } - } else { - accepts = defaultContentType; } - - return accepts; - } - - @Override - protected boolean needToImport(String type) { - return super.needToImport(type) && type.indexOf(".") < 0; - } -/* - @Override - public String findCommonPrefixOfVars(List vars) { - String prefix = StringUtils.getCommonPrefix(vars.toArray(new String[vars.size()])); - // exclude trailing characters that should be part of a valid variable - // e.g. ["status-on", "status-off"] => "status-" (not "status-o") - return prefix.replaceAll("[a-zA-Z0-9]+\\z", ""); - } -*/ - - @Override - public String toEnumName(CodegenProperty property) { - return sanitizeName(camelize(property.name)) + "Enum"; - } - - @Override - public String toEnumVarName(String value, String datatype) { - // number - if ("Integer".equals(datatype) || "Long".equals(datatype) || - "Float".equals(datatype) || "Double".equals(datatype)) { - String varName = "NUMBER_" + value; - varName = varName.replaceAll("-", "MINUS_"); - varName = varName.replaceAll("\\+", "PLUS_"); - varName = varName.replaceAll("\\.", "_DOT_"); - return varName; - } - - // string - String var = value.replaceAll("\\W+", "_").replaceAll("_+", "_").toUpperCase(); - if (var.matches("\\d.*")) { - return "_" + var; - } else { - return var; - } - } - - @Override - public String toEnumValue(String value, String datatype) { - if ("Integer".equals(datatype) || "Long".equals(datatype) || - "Float".equals(datatype) || "Double".equals(datatype)) { - return value; - } else { - return "\"" + escapeText(value) + "\""; - } - } - - private static CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) { - // This generator uses inline classes to define enums, which breaks when - // dealing with models that have subTypes. To clean this up, we will analyze - // the parent and child models, look for enums that match, and remove - // them from the child models and leave them in the parent. - // Because the child models extend the parents, the enums will be available via the parent. - - // Only bother with reconciliation if the parent model has enums. - if (parentCodegenModel.hasEnums) { - - // Get the properties for the parent and child models - final List parentModelCodegenProperties = parentCodegenModel.vars; - List codegenProperties = codegenModel.vars; - - // Iterate over all of the parent model properties - boolean removedChildEnum = false; - for (CodegenProperty parentModelCodegenPropery : parentModelCodegenProperties) { - // Look for enums - if (parentModelCodegenPropery.isEnum) { - // Now that we have found an enum in the parent class, - // and search the child class for the same enum. - Iterator iterator = codegenProperties.iterator(); - while (iterator.hasNext()) { - CodegenProperty codegenProperty = iterator.next(); - if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenPropery)) { - // We found an enum in the child class that is - // a duplicate of the one in the parent, so remove it. - iterator.remove(); - removedChildEnum = true; - } - } - } - } - - if(removedChildEnum) { - // If we removed an entry from this model's vars, we need to ensure hasMore is updated - int count = 0, numVars = codegenProperties.size(); - for(CodegenProperty codegenProperty : codegenProperties) { - count += 1; - codegenProperty.hasMore = (count < numVars) ? true : null; - } - codegenModel.vars = codegenProperties; - } - } - - return codegenModel; - } - - public void setInvokerPackage(String invokerPackage) { - this.invokerPackage = invokerPackage; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } - - public void setSourceFolder(String sourceFolder) { - this.sourceFolder = sourceFolder; - } - - public void setLocalVariablePrefix(String localVariablePrefix) { - this.localVariablePrefix = localVariablePrefix; - } - - public void setSerializeBigDecimalAsString(boolean s) { - this.serializeBigDecimalAsString = s; - } - - public Boolean getSerializableModel() { - return serializableModel; - } - - public void setSerializableModel(Boolean serializableModel) { - this.serializableModel = serializableModel; - } - - private static String sanitizePackageName(String packageName) { - packageName = packageName.trim(); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. - packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_"); - if(Strings.isNullOrEmpty(packageName)) { - return "invalidPackageName"; - } - return packageName; - } - - public void setFullJavaUtil(boolean fullJavaUtil) { - this.fullJavaUtil = fullJavaUtil; + return objs; } public void setUseRxJava(boolean useRxJava) { this.useRxJava = useRxJava; } - - public void setDateLibrary(String library) { this.dateLibrary = 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 8a08bf758a3..e82c2893d59 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 @@ -4,16 +4,15 @@ import com.fasterxml.jackson.core.JsonProcessingException; import io.swagger.codegen.*; import io.swagger.models.Operation; import io.swagger.models.Swagger; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.MapProperty; -import io.swagger.models.properties.Property; import io.swagger.util.Yaml; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.*; -public class JavaInflectorServerCodegen extends JavaClientCodegen { +public class JavaInflectorServerCodegen extends AbstractJavaCodegen { private static final Logger LOGGER = LoggerFactory.getLogger(JavaInflectorServerCodegen.class); @@ -23,34 +22,23 @@ public class JavaInflectorServerCodegen extends JavaClientCodegen { super(); sourceFolder = "src/gen/java"; - modelTemplateFiles.put("model.mustache", ".java"); - apiTemplateFiles.put("api.mustache", ".java"); apiTestTemplateFiles.clear(); // TODO: add test template embeddedTemplateDir = templateDir = "JavaInflector"; invokerPackage = "io.swagger.handler"; artifactId = "swagger-inflector-server"; - dateLibrary = "legacy"; + dateLibrary = "legacy"; //TODO: add joda support + + // clear model and api doc template as this codegen + // does not support auto-generated markdown doc at the moment + //TODO: add doc templates + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + apiPackage = System.getProperty("swagger.codegen.inflector.apipackage", "io.swagger.handler"); modelPackage = System.getProperty("swagger.codegen.inflector.modelpackage", "io.swagger.model"); - 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); - - languageSpecificPrimitives = new HashSet( - Arrays.asList( - "byte[]", - "String", - "boolean", - "Boolean", - "Double", - "Integer", - "Long", - "Float") - ); } @Override @@ -72,12 +60,6 @@ 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")); writeOptional(outputFolder, new SupportingFile("web.mustache", "src/main/webapp/WEB-INF", "web.xml")); @@ -153,6 +135,42 @@ public class JavaInflectorServerCodegen extends JavaClientCodegen { return objs; } + @Override + public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { + super.postProcessModelProperty(model, property); + + //Add imports for Jackson + if(!BooleanUtils.toBoolean(model.isEnum)) { + model.imports.add("JsonProperty"); + + if(BooleanUtils.toBoolean(model.hasEnums)) { + model.imports.add("JsonValue"); + } + } + } + + @Override + public Map postProcessModelsEnum(Map objs) { + objs = super.postProcessModelsEnum(objs); + + //Add imports for Jackson + List> imports = (List>)objs.get("imports"); + List models = (List) objs.get("models"); + for (Object _mo : models) { + Map mo = (Map) _mo; + CodegenModel cm = (CodegenModel) mo.get("model"); + // for enum model + if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) { + cm.imports.add(importMapping.get("JsonValue")); + Map item = new HashMap(); + item.put("import", importMapping.get("JsonValue")); + imports.add(item); + } + } + + return objs; + } + public String apiFilename(String templateName, String tag) { String result = super.apiFilename(templateName, tag); 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 f6c3f861e49..df43ab822d7 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 @@ -3,40 +3,30 @@ package io.swagger.codegen.languages; import io.swagger.codegen.*; import io.swagger.models.Operation; -import java.io.File; import java.util.*; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { public JavaJerseyServerCodegen() { super(); - sourceFolder = "src/gen/java"; - invokerPackage = "io.swagger.api"; - artifactId = "swagger-jaxrs-server"; outputFolder = "generated-code/JavaJaxRS-Jersey"; - modelTemplateFiles.put("model.mustache", ".java"); - apiTemplateFiles.put("api.mustache", ".java"); apiTemplateFiles.put("apiService.mustache", ".java"); apiTemplateFiles.put("apiServiceImpl.mustache", ".java"); apiTemplateFiles.put("apiServiceFactory.mustache", ".java"); + apiTestTemplateFiles.clear(); // TODO: add test template - apiPackage = "io.swagger.api"; - modelPackage = "io.swagger.model"; - - additionalProperties.put("title", title); + // clear model and api doc template as this codegen + // does not support auto-generated markdown doc at the moment + //TODO: add doc templates + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME; - for ( int i = 0; i < cliOptions.size(); i++ ) { - if ( CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt()) ) { - cliOptions.remove(i); - break; - } - } - CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); supportedLibraries.put("jersey1", "Jersey core 1.x"); @@ -45,8 +35,7 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { library.setDefault("jersey1"); cliOptions.add(library); - cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC)); - cliOptions.add(new CliOption("title", "a title describing the application")); + } @Override @@ -67,6 +56,15 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { if("null".equals(property.example)) { property.example = null; } + + //Add imports for Jackson + if(!BooleanUtils.toBoolean(model.isEnum)) { + model.imports.add("JsonProperty"); + + if(BooleanUtils.toBoolean(model.hasEnums)) { + model.imports.add("JsonValue"); + } + } } @Override @@ -78,13 +76,6 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { setLibrary("jersey2"); } - supportingFiles.clear(); - - // 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); } @@ -109,6 +100,28 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java")); } + @Override + public Map postProcessModelsEnum(Map objs) { + objs = super.postProcessModelsEnum(objs); + + //Add imports for Jackson + List> imports = (List>)objs.get("imports"); + List models = (List) objs.get("models"); + for (Object _mo : models) { + Map mo = (Map) _mo; + CodegenModel cm = (CodegenModel) mo.get("model"); + // for enum model + if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) { + cm.imports.add(importMapping.get("JsonValue")); + Map item = new HashMap(); + item.put("import", importMapping.get("JsonValue")); + imports.add(item); + } + } + + return objs; + } + @Override public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { String basePath = resourcePath; @@ -137,7 +150,4 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { co.baseName = basePath; } - public void hideGenerationTimestamp(boolean hideGenerationTimestamp) { - this.hideGenerationTimestamp = hideGenerationTimestamp; - } } 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 33803b087b8..2aff70422da 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 @@ -2,66 +2,35 @@ package io.swagger.codegen.languages; import io.swagger.codegen.*; import io.swagger.models.Operation; -import io.swagger.models.Path; -import io.swagger.models.Swagger; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import java.io.File; import java.util.*; -public class JavaResteasyServerCodegen extends JavaClientCodegen implements CodegenConfig { - - protected String dateLibrary = "default"; - protected String title = "Swagger Server"; - protected String implFolder = "src/main/java"; - - public static final String DATE_LIBRARY = "dateLibrary"; +public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen { public JavaResteasyServerCodegen() { super(); - sourceFolder = "src/gen/java"; - invokerPackage = "io.swagger.api"; artifactId = "swagger-jaxrs-resteasy-server"; outputFolder = "generated-code/javaJaxRS"; - modelTemplateFiles.put("model.mustache", ".java"); - apiTemplateFiles.put("api.mustache", ".java"); apiTemplateFiles.put("apiService.mustache", ".java"); apiTemplateFiles.put("apiServiceImpl.mustache", ".java"); apiTemplateFiles.put("apiServiceFactory.mustache", ".java"); apiTestTemplateFiles.clear(); // TODO: add test template - apiPackage = "io.swagger.api"; - modelPackage = "io.swagger.model"; - dateLibrary = "legacy"; - additionalProperties.put("title", title); + // clear model and api doc template as AbstractJavaJAXRSServerCodegen + // does not support auto-generated markdown doc at the moment + //TODO: add doc templates + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + + dateLibrary = "legacy";// TODO: change to joda embeddedTemplateDir = templateDir = "JavaJaxRS" + File.separator + "resteasy"; - - for (int i = 0; i < cliOptions.size(); i++) { - if (CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt())) { - cliOptions.remove(i); - break; - } - } - - CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); - library.setDefault(DEFAULT_LIBRARY); - - Map supportedLibraries = new LinkedHashMap(); - - supportedLibraries.put(DEFAULT_LIBRARY, "Resteasy core 3.0.11"); - library.setEnum(supportedLibraries); - - cliOptions.add(library); - cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC)); - } - - @Override - public CodegenType getTag() { - return CodegenType.SERVER; } @Override @@ -78,16 +47,6 @@ 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); - } - - supportingFiles.clear(); writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml")); writeOptional(outputFolder, new SupportingFile("gradle.mustache", "", "build.gradle")); writeOptional(outputFolder, new SupportingFile("settingsGradle.mustache", "", "settings.gradle")); @@ -152,51 +111,6 @@ public class JavaResteasyServerCodegen extends JavaClientCodegen implements Code co.baseName = basePath; } - - @Override - public void preprocessSwagger(Swagger swagger) { - if ("/".equals(swagger.getBasePath())) { - swagger.setBasePath(""); - } - - String host = swagger.getHost(); - String port = "8080"; - if (host != null) { - String[] parts = host.split(":"); - if (parts.length > 1) { - port = parts[1]; - } - } - this.additionalProperties.put("serverPort", port); - if (swagger != null && swagger.getPaths() != null) { - for (String pathname : swagger.getPaths().keySet()) { - Path path = swagger.getPath(pathname); - if (path.getOperations() != null) { - for (Operation operation : path.getOperations()) { - if (operation.getTags() != null) { - List> tags = new ArrayList>(); - for (String tag : operation.getTags()) { - Map value = new HashMap(); - value.put("tag", tag); - value.put("hasMore", "true"); - tags.add(value); - } - if (tags.size() > 0) { - tags.get(tags.size() - 1).remove("hasMore"); - } - if (operation.getTags().size() > 0) { - String tag = operation.getTags().get(0); - operation.setTags(Arrays.asList(tag)); - } - operation.setVendorExtension("x-tags", tags); - } - } - } - } - } - } - - @Override public Map postProcessOperations(Map objs) { @@ -249,77 +163,37 @@ public class JavaResteasyServerCodegen extends JavaClientCodegen implements Code return objs; } - @Override - public String toApiName(String name) { - if (name.length() == 0) { - return "DefaultApi"; - } - name = sanitizeName(name); - return camelize(name) + "Api"; - } - - - @Override - public String apiFilename(String templateName, String tag) { - - String result = super.apiFilename(templateName, tag); - - if (templateName.endsWith("Impl.mustache")) { - int ix = result.lastIndexOf('/'); - result = result.substring(0, ix) + "/impl" + result.substring(ix, result.length() - 5) + "ServiceImpl.java"; - - result = result.replace(apiFileFolder(), implFileFolder(implFolder)); - } else if (templateName.endsWith("Factory.mustache")) { - int ix = result.lastIndexOf('/'); - result = result.substring(0, ix) + "/factories" + result.substring(ix, result.length() - 5) + "ServiceFactory.java"; - - result = result.replace(apiFileFolder(), implFileFolder(implFolder)); - } else if (templateName.endsWith("Service.mustache")) { - int ix = result.lastIndexOf('.'); - result = result.substring(0, ix) + "Service.java"; - } - - return result; - } - - - private String implFileFolder(String output) { - return outputFolder + "/" + output + "/" + apiPackage().replace('.', '/'); - } - - @Override - public boolean shouldOverwrite(String filename) { - return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java"); - } - - public void setDateLibrary(String library) { - this.dateLibrary = library; - } - @Override public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { - if(serializeBigDecimalAsString) { - if (property.baseType.equals("BigDecimal")) { - // we serialize BigDecimal as `string` to avoid precision loss - property.vendorExtensions.put("extraAnnotation", "@JsonSerialize(using = ToStringSerializer.class)"); + //Add imports for Jackson + if(!BooleanUtils.toBoolean(model.isEnum)) { + model.imports.add("JsonProperty"); - // this requires some more imports to be added for this model... - model.imports.add("ToStringSerializer"); - model.imports.add("JsonSerialize"); + if(BooleanUtils.toBoolean(model.hasEnums)) { + model.imports.add("JsonValue"); + } + } + } + + @Override + public Map postProcessModelsEnum(Map objs) { + objs = super.postProcessModelsEnum(objs); + + //Add imports for Jackson + List> imports = (List>)objs.get("imports"); + List models = (List) objs.get("models"); + for (Object _mo : models) { + Map mo = (Map) _mo; + CodegenModel cm = (CodegenModel) mo.get("model"); + // for enum model + if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) { + cm.imports.add(importMapping.get("JsonValue")); + Map item = new HashMap(); + item.put("import", importMapping.get("JsonValue")); + imports.add(item); } } - if(model.isEnum == null || model.isEnum) { - - final String lib = getLibrary(); - if(StringUtils.isEmpty(lib)) { - model.imports.add("JsonProperty"); - - if(model.hasEnums != null || model.hasEnums == true) { - model.imports.add("JsonValue"); - } - } - } - return; + return objs; } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java index 4b30062d799..fb54e1bc779 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java @@ -4,10 +4,12 @@ import io.swagger.codegen.*; import io.swagger.models.Operation; import io.swagger.models.Path; import io.swagger.models.Swagger; +import org.apache.commons.lang3.BooleanUtils; + import java.io.File; import java.util.*; -public class SpringBootServerCodegen extends JavaClientCodegen implements CodegenConfig{ +public class SpringBootServerCodegen extends AbstractJavaCodegen { public static final String CONFIG_PACKAGE = "configPackage"; public static final String BASE_PACKAGE = "basePackage"; public static final String INTERFACE_ONLY = "interfaceOnly"; @@ -15,33 +17,24 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege public static final String JAVA_8 = "java8"; public static final String ASYNC = "async"; protected String title = "Petstore Server"; - protected String configPackage = ""; - protected String basePackage = ""; + protected String configPackage = "io.swagger.configuration"; + protected String basePackage = "io.swagger"; protected boolean interfaceOnly = false; protected boolean singleContentTypes = false; protected boolean java8 = false; protected boolean async = false; - protected String templateFileName = "api.mustache"; public SpringBootServerCodegen() { super(); outputFolder = "generated-code/javaSpringBoot"; - apiTemplateFiles.put(templateFileName, ".java"); apiTestTemplateFiles.clear(); // TODO: add test template embeddedTemplateDir = templateDir = "JavaSpringBoot"; apiPackage = "io.swagger.api"; modelPackage = "io.swagger.model"; - configPackage = "io.swagger.configuration"; invokerPackage = "io.swagger.api"; - basePackage = "io.swagger"; artifactId = "swagger-springboot-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); additionalProperties.put(BASE_PACKAGE, basePackage); @@ -52,11 +45,17 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface")); cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers")); - supportedLibraries.clear(); supportedLibraries.put(DEFAULT_LIBRARY, "Default Spring Boot server stub."); supportedLibraries.put("j8-async", "Use async servlet feature and Java 8's default interface. Generating interface with service " + "declaration is useful when using Maven plugin. Just provide a implementation with @Controller to instantiate service." + "(DEPRECATED: use -Djava8=true,async=true instead)"); + + CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); + library.setDefault(DEFAULT_LIBRARY); + library.setEnum(supportedLibraries); + library.setDefault(DEFAULT_LIBRARY); + cliOptions.add(library); + } @Override @@ -80,6 +79,7 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege // clear model and api doc template as this codegen // does not support auto-generated markdown doc at the moment + //TODO: add doc templates modelDocTemplateFiles.remove("model_doc.mustache"); apiDocTemplateFiles.remove("api_doc.mustache"); @@ -107,7 +107,6 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString())); } - supportingFiles.clear(); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); @@ -309,4 +308,40 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege } return objs; } + + @Override + public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { + super.postProcessModelProperty(model, property); + + //Add imports for Jackson + if(!BooleanUtils.toBoolean(model.isEnum)) { + model.imports.add("JsonProperty"); + + if(BooleanUtils.toBoolean(model.hasEnums)) { + model.imports.add("JsonValue"); + } + } + } + + @Override + public Map postProcessModelsEnum(Map objs) { + objs = super.postProcessModelsEnum(objs); + + //Add imports for Jackson + List> imports = (List>)objs.get("imports"); + List models = (List) objs.get("models"); + for (Object _mo : models) { + Map mo = (Map) _mo; + CodegenModel cm = (CodegenModel) mo.get("model"); + // for enum model + if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) { + cm.imports.add(importMapping.get("JsonValue")); + Map item = new HashMap(); + item.put("import", importMapping.get("JsonValue")); + imports.add(item); + } + } + + return objs; + } } diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1/model.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1/model.mustache index 738fe1c1440..b9512d2b83c 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1/model.mustache @@ -1,8 +1,6 @@ package {{package}}; import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; {{#imports}}import {{import}}; {{/imports}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache index c3b3bb66908..48ac02fed77 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache @@ -1,4 +1,4 @@ -package {{apiPackage}}; +package {{package}}; {{#imports}}import {{import}}; {{/imports}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/apiController.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/apiController.mustache index f9c03faafc1..2540bb75d79 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/apiController.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/apiController.mustache @@ -1,4 +1,4 @@ -package {{apiPackage}}; +package {{package}}; {{^java8}} {{#imports}}import {{import}}; diff --git a/modules/swagger-codegen/src/main/resources/dart/model.mustache b/modules/swagger-codegen/src/main/resources/dart/model.mustache index c0c4789c00b..afd72265646 100644 --- a/modules/swagger-codegen/src/main/resources/dart/model.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/model.mustache @@ -4,6 +4,7 @@ part of api; @Entity() class {{classname}} { {{#vars}}{{#description}}/* {{{description}}} */{{/description}} + @Property(name: '{{baseName}}') {{{datatype}}} {{name}} = {{{defaultValue}}}; {{#allowableValues}}{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{{/allowableValues}} {{/vars}} diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache index 050278b2b5d..c866fc5805c 100644 --- a/modules/swagger-codegen/src/main/resources/python/api.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api.mustache @@ -51,6 +51,40 @@ class {{classname}}(object): >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}callback=callback_function) {{/sortParamsByRequiredFlag}} + :param callback function: The callback function + for asynchronous request. (optional) +{{#allParams}} + :param {{dataType}} {{paramName}}: {{{description}}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} +{{/allParams}} + :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) + else: + (data) = self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) + return data + + def {{operationId}}_with_http_info(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): + """ + {{{summary}}} + {{{notes}}} + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> +{{#sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}callback=callback_function) +{{/sortParamsByRequiredFlag}} +{{^sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}callback=callback_function) +{{/sortParamsByRequiredFlag}} + :param callback function: The callback function for asynchronous request. (optional) {{#allParams}} @@ -63,6 +97,7 @@ class {{classname}}(object): all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -150,7 +185,7 @@ class {{classname}}(object): # Authentication setting auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] - response = self.api_client.call_api(resource_path, '{{httpMethod}}', + return self.api_client.call_api(resource_path, '{{httpMethod}}', path_params, query_params, header_params, @@ -159,7 +194,7 @@ class {{classname}}(object): files=local_var_files, response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) {{/operation}} {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index 2a4732f5afd..170cd05b4aa 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -103,7 +103,7 @@ class ApiClient(object): def __call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, - response_type=None, auth_settings=None, callback=None): + response_type=None, auth_settings=None, callback=None, _return_http_data_only=None): # headers parameters header_params = header_params or {} @@ -157,9 +157,12 @@ class ApiClient(object): deserialized_data = None if callback: - callback(deserialized_data) + callback(deserialized_data) if _return_http_data_only else callback((deserialized_data, response_data.status, response_data.getheaders())) + elif _return_http_data_only: + return ( deserialized_data ); else: - return deserialized_data + return (deserialized_data, response_data.status, response_data.getheaders()) + def to_path_value(self, obj): """ @@ -287,7 +290,7 @@ class ApiClient(object): def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, - response_type=None, auth_settings=None, callback=None): + response_type=None, auth_settings=None, callback=None, _return_http_data_only=None): """ Makes the HTTP request (synchronous) and return the deserialized data. To make an async request, define a function for callback. @@ -308,6 +311,7 @@ class ApiClient(object): :param callback function: Callback function for asynchronous request. If provide this parameter, the request will be called asynchronously. + :param _return_http_data_only: response data without head status code and headers :return: If provide parameter callback, the request will be called asynchronously. @@ -319,7 +323,7 @@ class ApiClient(object): return self.__call_api(resource_path, method, path_params, query_params, header_params, body, post_params, files, - response_type, auth_settings, callback) + response_type, auth_settings, callback, _return_http_data_only) else: thread = threading.Thread(target=self.__call_api, args=(resource_path, method, @@ -327,7 +331,7 @@ class ApiClient(object): header_params, body, post_params, files, response_type, auth_settings, - callback)) + callback,_return_http_data_only)) thread.start() return thread diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/inflector/JavaInflectorServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/inflector/JavaInflectorServerOptionsTest.java index 0987a0d236e..4d020f0591b 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/inflector/JavaInflectorServerOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/inflector/JavaInflectorServerOptionsTest.java @@ -1,5 +1,6 @@ package io.swagger.codegen.inflector; +import io.swagger.codegen.AbstractOptionsTest; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.java.JavaClientOptionsTest; import io.swagger.codegen.languages.JavaInflectorServerCodegen; @@ -7,7 +8,7 @@ import io.swagger.codegen.options.JavaInflectorServerOptionsProvider; import mockit.Expectations; import mockit.Tested; -public class JavaInflectorServerOptionsTest extends JavaClientOptionsTest { +public class JavaInflectorServerOptionsTest extends AbstractOptionsTest { @Tested private JavaInflectorServerCodegen clientCodegen; @@ -45,8 +46,6 @@ public class JavaInflectorServerOptionsTest extends JavaClientOptionsTest { times = 1; clientCodegen.setSerializableModel(Boolean.valueOf(JavaInflectorServerOptionsProvider.SERIALIZABLE_MODEL_VALUE)); times = 1; - clientCodegen.setLibrary(JavaInflectorServerOptionsProvider.DEFAULT_LIBRARY_VALUE); - times = 1; clientCodegen.setFullJavaUtil(Boolean.valueOf(JavaInflectorServerOptionsProvider.FULL_JAVA_UTIL_VALUE)); times = 1; clientCodegen.setSerializeBigDecimalAsString(true); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java index 701f9586eec..aea42d72401 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java @@ -2,6 +2,7 @@ package io.swagger.codegen.java; import io.swagger.codegen.AbstractOptionsTest; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.options.JavaClientOptionsProvider; import io.swagger.codegen.options.JavaOptionsProvider; import io.swagger.codegen.languages.JavaClientCodegen; import io.swagger.codegen.options.OptionsProvider; @@ -15,7 +16,7 @@ public class JavaClientOptionsTest extends AbstractOptionsTest { private JavaClientCodegen clientCodegen; public JavaClientOptionsTest() { - super(new JavaOptionsProvider()); + super(new JavaClientOptionsProvider()); } protected JavaClientOptionsTest(OptionsProvider optionsProvider) { @@ -51,7 +52,7 @@ public class JavaClientOptionsTest extends AbstractOptionsTest { times = 1; clientCodegen.setSerializableModel(Boolean.valueOf(JavaOptionsProvider.SERIALIZABLE_MODEL_VALUE)); times = 1; - clientCodegen.setLibrary(JavaOptionsProvider.DEFAULT_LIBRARY_VALUE); + clientCodegen.setLibrary(JavaClientOptionsProvider.DEFAULT_LIBRARY_VALUE); times = 1; clientCodegen.setFullJavaUtil(Boolean.valueOf(JavaOptionsProvider.FULL_JAVA_UTIL_VALUE)); times = 1; diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java index 51dcd5fc90d..7753c8e45da 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java @@ -1,5 +1,6 @@ package io.swagger.codegen.jaxrs; +import io.swagger.codegen.AbstractOptionsTest; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.java.JavaClientOptionsTest; import io.swagger.codegen.languages.JavaJerseyServerCodegen; @@ -8,7 +9,7 @@ import io.swagger.codegen.options.JaxRSServerOptionsProvider; import mockit.Expectations; import mockit.Tested; -public class JaxRSServerOptionsTest extends JavaClientOptionsTest { +public class JaxRSServerOptionsTest extends AbstractOptionsTest { @Tested private JavaJerseyServerCodegen clientCodegen; diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java new file mode 100644 index 00000000000..53cfe826d36 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java @@ -0,0 +1,23 @@ +package io.swagger.codegen.options; + +import com.google.common.collect.ImmutableMap; +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.JavaClientCodegen; + +import java.util.HashMap; +import java.util.Map; + +public class JavaClientOptionsProvider extends JavaOptionsProvider { + + public static final String DEFAULT_LIBRARY_VALUE = "jersey2"; + + @Override + public Map createOptions() { + Map options = new HashMap(super.createOptions()); + options.put(CodegenConstants.LIBRARY, DEFAULT_LIBRARY_VALUE); + options.put(JavaClientCodegen.USE_RX_JAVA, "false"); + + return options; + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaOptionsProvider.java index d2b51b06fe4..468eb5c972f 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaOptionsProvider.java @@ -16,7 +16,6 @@ public class JavaOptionsProvider implements OptionsProvider { public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT"; public static final String SOURCE_FOLDER_VALUE = "src/main/java/test"; public static final String LOCAL_PREFIX_VALUE = "tst"; - public static final String DEFAULT_LIBRARY_VALUE = "jersey2"; public static final String SERIALIZABLE_MODEL_VALUE = "false"; public static final String FULL_JAVA_UTIL_VALUE = "true"; public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true"; @@ -40,9 +39,7 @@ public class JavaOptionsProvider implements OptionsProvider { .put(CodegenConstants.LOCAL_VARIABLE_PREFIX, LOCAL_PREFIX_VALUE) .put(CodegenConstants.SERIALIZABLE_MODEL, SERIALIZABLE_MODEL_VALUE) .put(JavaClientCodegen.FULL_JAVA_UTIL, FULL_JAVA_UTIL_VALUE) - .put(CodegenConstants.LIBRARY, DEFAULT_LIBRARY_VALUE) .put(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, "true") - .put(JavaClientCodegen.USE_RX_JAVA, "false") .put(JavaClientCodegen.DATE_LIBRARY, "joda") .put("hideGenerationTimestamp", "true") .build(); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JaxRSServerOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JaxRSServerOptionsProvider.java index 3006ed396c9..230084c2ec9 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JaxRSServerOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JaxRSServerOptionsProvider.java @@ -54,7 +54,6 @@ public class JaxRSServerOptionsProvider implements OptionsProvider { .put(JavaClientCodegen.FULL_JAVA_UTIL, FULL_JAVA_UTIL_VALUE) .put(CodegenConstants.LIBRARY, JAXRS_DEFAULT_LIBRARY_VALUE) .put(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, "true") - .put(JavaClientCodegen.USE_RX_JAVA, "false") //.put(JavaClientCodegen.DATE_LIBRARY, "joda") .put("hideGenerationTimestamp", "true"); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringMVCServerOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringMVCServerOptionsProvider.java index a9d77c40393..0755b4380f6 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringMVCServerOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringMVCServerOptionsProvider.java @@ -20,6 +20,8 @@ public class SpringMVCServerOptionsProvider extends JavaOptionsProvider { Map options = new HashMap(super.createOptions()); options.put(SpringMVCServerCodegen.CONFIG_PACKAGE, CONFIG_PACKAGE_VALUE); options.put(CodegenConstants.LIBRARY, LIBRARY_VALUE); + options.put(SpringMVCServerCodegen.USE_RX_JAVA, "false"); + return options; } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/springboot/SpringBootServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/springboot/SpringBootServerOptionsTest.java index 376a44a60b8..90610924bfa 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/springboot/SpringBootServerOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/springboot/SpringBootServerOptionsTest.java @@ -1,14 +1,14 @@ package io.swagger.codegen.springboot; +import io.swagger.codegen.AbstractOptionsTest; import io.swagger.codegen.CodegenConfig; -import io.swagger.codegen.java.JavaClientOptionsTest; import io.swagger.codegen.languages.SpringBootServerCodegen; import io.swagger.codegen.options.SpringBootServerOptionsProvider; import mockit.Expectations; import mockit.Tested; -public class SpringBootServerOptionsTest extends JavaClientOptionsTest { +public class SpringBootServerOptionsTest extends AbstractOptionsTest { @Tested private SpringBootServerCodegen clientCodegen; diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/springmvc/SpringMVCServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/springmvc/SpringMVCServerOptionsTest.java index c24162c1a3c..c53a4e4941c 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/springmvc/SpringMVCServerOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/springmvc/SpringMVCServerOptionsTest.java @@ -1,5 +1,6 @@ package io.swagger.codegen.springmvc; +import io.swagger.codegen.AbstractOptionsTest; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.java.JavaClientOptionsTest; import io.swagger.codegen.languages.SpringMVCServerCodegen; @@ -8,7 +9,7 @@ import io.swagger.codegen.options.SpringMVCServerOptionsProvider; import mockit.Expectations; import mockit.Tested; -public class SpringMVCServerOptionsTest extends JavaClientOptionsTest { +public class SpringMVCServerOptionsTest extends AbstractOptionsTest { @Tested private SpringMVCServerCodegen clientCodegen; 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 109feba388e..615cb5a10fe 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 @@ -834,6 +834,8 @@ definitions: name: type: integer format: int32 + class: + type: string xml: name: Name Dog: diff --git a/pom.xml b/pom.xml index 40ebc9bb85f..195d49aa889 100644 --- a/pom.xml +++ b/pom.xml @@ -399,7 +399,7 @@ - samples/client/petstore/objc/SwaggerClientTests + samples/client/petstore/objc/default/SwaggerClientTests diff --git a/samples/client/petstore/objc/LICENSE b/samples/client/petstore/dart/LICENSE similarity index 100% rename from samples/client/petstore/objc/LICENSE rename to samples/client/petstore/dart/LICENSE diff --git a/samples/client/petstore/dart/git_push.sh b/samples/client/petstore/dart/git_push.sh index 1a36388db02..ed374619b13 100644 --- a/samples/client/petstore/dart/git_push.sh +++ b/samples/client/petstore/dart/git_push.sh @@ -8,12 +8,12 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="GIT_USER_ID" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="GIT_REPO_ID" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi diff --git a/samples/client/petstore/dart/lib/api_client.dart b/samples/client/petstore/dart/lib/api_client.dart index 7cd93d13e61..c4e9a5b1d46 100644 --- a/samples/client/petstore/dart/lib/api_client.dart +++ b/samples/client/petstore/dart/lib/api_client.dart @@ -10,8 +10,8 @@ class ApiClient { ApiClient() { // Setup authentications (key: authentication name, value: authentication). - _authentications['api_key'] = new ApiKeyAuth("header", "api_key"); _authentications['petstore_auth'] = new OAuth(); + _authentications['api_key'] = new ApiKeyAuth("header", "api_key"); } void addDefaultHeader(String key, String value) { diff --git a/samples/client/petstore/dart/lib/model/api_response.dart b/samples/client/petstore/dart/lib/model/api_response.dart index e9746c587b0..e8ffe737861 100644 --- a/samples/client/petstore/dart/lib/model/api_response.dart +++ b/samples/client/petstore/dart/lib/model/api_response.dart @@ -4,12 +4,15 @@ part of api; @Entity() class ApiResponse { + @Property(name: 'code') int code = null; + @Property(name: 'type') String type = null; + @Property(name: 'message') String message = null; ApiResponse(); diff --git a/samples/client/petstore/dart/lib/model/category.dart b/samples/client/petstore/dart/lib/model/category.dart index 8b4c9b47f8b..e39966555fb 100644 --- a/samples/client/petstore/dart/lib/model/category.dart +++ b/samples/client/petstore/dart/lib/model/category.dart @@ -4,9 +4,11 @@ part of api; @Entity() class Category { + @Property(name: 'id') int id = null; + @Property(name: 'name') String name = null; Category(); diff --git a/samples/client/petstore/dart/lib/model/order.dart b/samples/client/petstore/dart/lib/model/order.dart index a3c37e839d6..1d908629b06 100644 --- a/samples/client/petstore/dart/lib/model/order.dart +++ b/samples/client/petstore/dart/lib/model/order.dart @@ -4,21 +4,27 @@ part of api; @Entity() class Order { + @Property(name: 'id') int id = null; + @Property(name: 'petId') int petId = null; + @Property(name: 'quantity') int quantity = null; + @Property(name: 'shipDate') DateTime shipDate = null; /* Order Status */ + @Property(name: 'status') String status = null; //enum statusEnum { placed, approved, delivered, }; + @Property(name: 'complete') bool complete = null; Order(); diff --git a/samples/client/petstore/dart/lib/model/pet.dart b/samples/client/petstore/dart/lib/model/pet.dart index 649e99527dd..8ad328b78be 100644 --- a/samples/client/petstore/dart/lib/model/pet.dart +++ b/samples/client/petstore/dart/lib/model/pet.dart @@ -4,21 +4,27 @@ part of api; @Entity() class Pet { + @Property(name: 'id') int id = null; + @Property(name: 'category') Category category = null; + @Property(name: 'name') String name = null; + @Property(name: 'photoUrls') List photoUrls = []; + @Property(name: 'tags') List tags = []; /* pet status in the store */ + @Property(name: 'status') String status = null; //enum statusEnum { available, pending, sold, }; Pet(); diff --git a/samples/client/petstore/dart/lib/model/tag.dart b/samples/client/petstore/dart/lib/model/tag.dart index 68214cd49f5..0541e12fb6f 100644 --- a/samples/client/petstore/dart/lib/model/tag.dart +++ b/samples/client/petstore/dart/lib/model/tag.dart @@ -4,9 +4,11 @@ part of api; @Entity() class Tag { + @Property(name: 'id') int id = null; + @Property(name: 'name') String name = null; Tag(); diff --git a/samples/client/petstore/dart/lib/model/user.dart b/samples/client/petstore/dart/lib/model/user.dart index 7cd314f7b25..fd99a51ee58 100644 --- a/samples/client/petstore/dart/lib/model/user.dart +++ b/samples/client/petstore/dart/lib/model/user.dart @@ -4,27 +4,35 @@ part of api; @Entity() class User { + @Property(name: 'id') int id = null; + @Property(name: 'username') String username = null; + @Property(name: 'firstName') String firstName = null; + @Property(name: 'lastName') String lastName = null; + @Property(name: 'email') String email = null; + @Property(name: 'password') String password = null; + @Property(name: 'phone') String phone = null; /* User Status */ + @Property(name: 'userStatus') int userStatus = null; User(); diff --git a/samples/client/petstore/objc/.swagger-codegen-ignore b/samples/client/petstore/groovy/.swagger-codegen-ignore similarity index 100% rename from samples/client/petstore/objc/.swagger-codegen-ignore rename to samples/client/petstore/groovy/.swagger-codegen-ignore diff --git a/samples/client/petstore/groovy/LICENSE b/samples/client/petstore/groovy/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/samples/client/petstore/groovy/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. 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 index 5aae4924239..d0779e65c25 100644 --- 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 @@ -6,8 +6,8 @@ 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.io.File import java.util.*; 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 index 29509e64e54..752328f71ea 100644 --- 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 @@ -1,7 +1,6 @@ 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 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 index 505752a6dc3..21b0185787b 100644 --- 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 @@ -1,7 +1,6 @@ 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 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 index 815c72846d9..afc35651173 100644 --- 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 @@ -1,8 +1,6 @@ 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; 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 index 667ce9430f4..53f113424cd 100644 --- 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 @@ -1,8 +1,6 @@ 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; 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 index 5c30c04a5ff..4160f03a718 100644 --- 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 @@ -1,7 +1,6 @@ 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 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 index 6889661e9e5..142a4afd0da 100644 --- 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 @@ -1,7 +1,6 @@ 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 diff --git a/samples/client/petstore/java/default/docs/Model200Response.md b/samples/client/petstore/java/default/docs/Model200Response.md index 0819b88c4f4..b47618b28cc 100644 --- a/samples/client/petstore/java/default/docs/Model200Response.md +++ b/samples/client/petstore/java/default/docs/Model200Response.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | [optional] +**PropertyClass** | **String** | | [optional] diff --git a/samples/client/petstore/java/default/hello.txt b/samples/client/petstore/java/default/hello.txt deleted file mode 100644 index 6769dd60bdf..00000000000 --- a/samples/client/petstore/java/default/hello.txt +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Model200Response.java index b2809525c7f..eed3902b922 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Model200Response.java @@ -15,6 +15,7 @@ import io.swagger.annotations.ApiModelProperty; public class Model200Response { private Integer name = null; + private String PropertyClass = null; /** @@ -34,6 +35,23 @@ public class Model200Response { } + /** + **/ + public Model200Response PropertyClass(String PropertyClass) { + this.PropertyClass = PropertyClass; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("class") + public String getPropertyClass() { + return PropertyClass; + } + public void setPropertyClass(String PropertyClass) { + this.PropertyClass = PropertyClass; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -43,12 +61,13 @@ public class Model200Response { return false; } Model200Response _200Response = (Model200Response) o; - return Objects.equals(this.name, _200Response.name); + return Objects.equals(this.name, _200Response.name) && + Objects.equals(this.PropertyClass, _200Response.PropertyClass); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, PropertyClass); } @Override @@ -57,6 +76,7 @@ public class Model200Response { sb.append("class Model200Response {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" PropertyClass: ").append(toIndentedString(PropertyClass)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/feign/.gitignore b/samples/client/petstore/java/feign/.gitignore index 7cf39af816c..a530464afa1 100644 --- a/samples/client/petstore/java/feign/.gitignore +++ b/samples/client/petstore/java/feign/.gitignore @@ -13,3 +13,9 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java index 75b3a96f2c7..e21bded5212 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java @@ -41,10 +41,10 @@ public class ApiClient { this(); for(String authName : authNames) { RequestInterceptor auth; - if (authName == "petstore_auth") { - auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "api_key") { + if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "petstore_auth") { + auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } 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 1383dd0decb..03c6c81e434 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,3 +1,28 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package io.swagger.client; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java index dbabdc64995..8296c7e4d78 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java @@ -3,8 +3,8 @@ package io.swagger.client.api; import io.swagger.client.ApiClient; import org.joda.time.LocalDate; -import java.math.BigDecimal; import org.joda.time.DateTime; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; 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 e486495c5a9..4d4cc14f625 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; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/auth/OAuthFlow.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/auth/OAuthFlow.java index 597ec99b48b..ec1f942b0f2 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/auth/OAuthFlow.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/auth/OAuthFlow.java @@ -1,5 +1,30 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package io.swagger.client.auth; public enum OAuthFlow { accessCode, implicit, password, application -} \ No newline at end of file +} 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 b2809525c7f..eed3902b922 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 @@ -15,6 +15,7 @@ import io.swagger.annotations.ApiModelProperty; public class Model200Response { private Integer name = null; + private String PropertyClass = null; /** @@ -34,6 +35,23 @@ public class Model200Response { } + /** + **/ + public Model200Response PropertyClass(String PropertyClass) { + this.PropertyClass = PropertyClass; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("class") + public String getPropertyClass() { + return PropertyClass; + } + public void setPropertyClass(String PropertyClass) { + this.PropertyClass = PropertyClass; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -43,12 +61,13 @@ public class Model200Response { return false; } Model200Response _200Response = (Model200Response) o; - return Objects.equals(this.name, _200Response.name); + return Objects.equals(this.name, _200Response.name) && + Objects.equals(this.PropertyClass, _200Response.PropertyClass); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, PropertyClass); } @Override @@ -57,6 +76,7 @@ public class Model200Response { sb.append("class Model200Response {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" PropertyClass: ").append(toIndentedString(PropertyClass)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/jersey2/docs/Model200Response.md b/samples/client/petstore/java/jersey2/docs/Model200Response.md index 0819b88c4f4..b47618b28cc 100644 --- a/samples/client/petstore/java/jersey2/docs/Model200Response.md +++ b/samples/client/petstore/java/jersey2/docs/Model200Response.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | [optional] +**PropertyClass** | **String** | | [optional] 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 b2809525c7f..eed3902b922 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 @@ -15,6 +15,7 @@ import io.swagger.annotations.ApiModelProperty; public class Model200Response { private Integer name = null; + private String PropertyClass = null; /** @@ -34,6 +35,23 @@ public class Model200Response { } + /** + **/ + public Model200Response PropertyClass(String PropertyClass) { + this.PropertyClass = PropertyClass; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("class") + public String getPropertyClass() { + return PropertyClass; + } + public void setPropertyClass(String PropertyClass) { + this.PropertyClass = PropertyClass; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -43,12 +61,13 @@ public class Model200Response { return false; } Model200Response _200Response = (Model200Response) o; - return Objects.equals(this.name, _200Response.name); + return Objects.equals(this.name, _200Response.name) && + Objects.equals(this.PropertyClass, _200Response.PropertyClass); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, PropertyClass); } @Override @@ -57,6 +76,7 @@ public class Model200Response { sb.append("class Model200Response {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" PropertyClass: ").append(toIndentedString(PropertyClass)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/okhttp-gson/.gitignore b/samples/client/petstore/java/okhttp-gson/.gitignore index 7cf39af816c..a530464afa1 100644 --- a/samples/client/petstore/java/okhttp-gson/.gitignore +++ b/samples/client/petstore/java/okhttp-gson/.gitignore @@ -13,3 +13,9 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/samples/client/petstore/java/okhttp-gson/.swagger-codegen-ignore b/samples/client/petstore/java/okhttp-gson/.swagger-codegen-ignore index 19d3377182e..c5fa491b4c5 100644 --- a/samples/client/petstore/java/okhttp-gson/.swagger-codegen-ignore +++ b/samples/client/petstore/java/okhttp-gson/.swagger-codegen-ignore @@ -14,7 +14,7 @@ # You can recursively match patterns against a directory, file or extension with a double asterisk (**): #foo/**/qux -# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux # You can also negate patterns with an exclamation (!). # For example, you can ignore all files in a docs folder with the file extension .md: diff --git a/samples/client/petstore/java/okhttp-gson/docs/Model200Response.md b/samples/client/petstore/java/okhttp-gson/docs/Model200Response.md index 0819b88c4f4..b47618b28cc 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/Model200Response.md +++ b/samples/client/petstore/java/okhttp-gson/docs/Model200Response.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | [optional] +**PropertyClass** | **String** | | [optional] diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java index 374a185a599..34af59510c2 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java @@ -173,8 +173,8 @@ public class ApiClient { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); - authentications.put("petstore_auth", new OAuth()); authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("petstore_auth", new OAuth()); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java index e502060d682..c8fdd0942c3 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java @@ -39,8 +39,8 @@ import com.google.gson.reflect.TypeToken; import java.io.IOException; import org.joda.time.LocalDate; -import java.math.BigDecimal; import org.joda.time.DateTime; +import java.math.BigDecimal; import java.lang.reflect.Type; import java.util.ArrayList; 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 d453504215c..765754a3b09 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 @@ -39,8 +39,8 @@ import com.google.gson.reflect.TypeToken; 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/model/Model200Response.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Model200Response.java index 8c7227f3f4e..cb0a88f0861 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Model200Response.java @@ -39,6 +39,8 @@ import com.google.gson.annotations.SerializedName; public class Model200Response { @SerializedName("name") private Integer name = null; + @SerializedName("class") + private String PropertyClass = null; /** * Get name @@ -58,6 +60,24 @@ public class Model200Response { this.name = name; } + /** + * Get PropertyClass + * @return PropertyClass + **/ + @ApiModelProperty(value = "") + public String getPropertyClass() { + return PropertyClass; + } + + /** + * Set PropertyClass + * + * @param PropertyClass PropertyClass + */ + public void setPropertyClass(String PropertyClass) { + this.PropertyClass = PropertyClass; + } + @Override public boolean equals(Object o) { @@ -68,12 +88,13 @@ public class Model200Response { return false; } Model200Response _200Response = (Model200Response) o; - return Objects.equals(this.name, _200Response.name); + return Objects.equals(this.name, _200Response.name) && + Objects.equals(this.PropertyClass, _200Response.PropertyClass); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, PropertyClass); } @Override @@ -82,6 +103,7 @@ public class Model200Response { sb.append("class Model200Response {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" PropertyClass: ").append(toIndentedString(PropertyClass)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/retrofit/.gitignore b/samples/client/petstore/java/retrofit/.gitignore index 7cf39af816c..a530464afa1 100644 --- a/samples/client/petstore/java/retrofit/.gitignore +++ b/samples/client/petstore/java/retrofit/.gitignore @@ -13,3 +13,9 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/samples/client/petstore/java/retrofit/.swagger-codegen-ignore b/samples/client/petstore/java/retrofit/.swagger-codegen-ignore index 19d3377182e..c5fa491b4c5 100644 --- a/samples/client/petstore/java/retrofit/.swagger-codegen-ignore +++ b/samples/client/petstore/java/retrofit/.swagger-codegen-ignore @@ -14,7 +14,7 @@ # You can recursively match patterns against a directory, file or extension with a double asterisk (**): #foo/**/qux -# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux # You can also negate patterns with an exclamation (!). # For example, you can ignore all files in a docs folder with the file extension .md: diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java index fe5ad9b37fe..0453c60ae01 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java @@ -54,10 +54,10 @@ public class ApiClient { this(); for(String authName : authNames) { Interceptor auth; - if (authName == "petstore_auth") { - auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "api_key") { + if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "petstore_auth") { + auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java index 02b97c10bf8..99df18ed71f 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java @@ -7,8 +7,8 @@ import retrofit.http.*; import retrofit.mime.*; import org.joda.time.LocalDate; -import java.math.BigDecimal; import org.joda.time.DateTime; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; 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/Model200Response.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Model200Response.java index 3cbb15006fb..22d2bbd763d 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Model200Response.java @@ -18,6 +18,9 @@ public class Model200Response { @SerializedName("name") private Integer name = null; + @SerializedName("class") + private String PropertyClass = null; + /** **/ @ApiModelProperty(value = "") @@ -28,6 +31,16 @@ public class Model200Response { this.name = name; } + /** + **/ + @ApiModelProperty(value = "") + public String getPropertyClass() { + return PropertyClass; + } + public void setPropertyClass(String PropertyClass) { + this.PropertyClass = PropertyClass; + } + @Override public boolean equals(Object o) { @@ -38,12 +51,13 @@ public class Model200Response { return false; } Model200Response _200Response = (Model200Response) o; - return Objects.equals(name, _200Response.name); + return Objects.equals(name, _200Response.name) && + Objects.equals(PropertyClass, _200Response.PropertyClass); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, PropertyClass); } @Override @@ -52,6 +66,7 @@ public class Model200Response { sb.append("class Model200Response {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" PropertyClass: ").append(toIndentedString(PropertyClass)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/retrofit2/.gitignore b/samples/client/petstore/java/retrofit2/.gitignore index 7cf39af816c..a530464afa1 100644 --- a/samples/client/petstore/java/retrofit2/.gitignore +++ b/samples/client/petstore/java/retrofit2/.gitignore @@ -13,3 +13,9 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/samples/client/petstore/java/retrofit2/docs/Model200Response.md b/samples/client/petstore/java/retrofit2/docs/Model200Response.md index 0819b88c4f4..b47618b28cc 100644 --- a/samples/client/petstore/java/retrofit2/docs/Model200Response.md +++ b/samples/client/petstore/java/retrofit2/docs/Model200Response.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | [optional] +**PropertyClass** | **String** | | [optional] diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java index 305b8b783e4..97a6048f95f 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java @@ -54,10 +54,10 @@ public class ApiClient { this(); for(String authName : authNames) { Interceptor auth; - if (authName == "petstore_auth") { - auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "api_key") { + if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "petstore_auth") { + auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } 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 index 91bd85c1b33..2a9b639511c 100644 --- 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 @@ -9,8 +9,8 @@ import retrofit2.http.*; import okhttp3.RequestBody; import org.joda.time.LocalDate; -import java.math.BigDecimal; import org.joda.time.DateTime; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java index ec9d67a7449..dd39a864f06 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java @@ -9,8 +9,8 @@ import retrofit2.http.*; import okhttp3.RequestBody; 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/retrofit2/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Model200Response.java index 3cbb15006fb..22d2bbd763d 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Model200Response.java @@ -18,6 +18,9 @@ public class Model200Response { @SerializedName("name") private Integer name = null; + @SerializedName("class") + private String PropertyClass = null; + /** **/ @ApiModelProperty(value = "") @@ -28,6 +31,16 @@ public class Model200Response { this.name = name; } + /** + **/ + @ApiModelProperty(value = "") + public String getPropertyClass() { + return PropertyClass; + } + public void setPropertyClass(String PropertyClass) { + this.PropertyClass = PropertyClass; + } + @Override public boolean equals(Object o) { @@ -38,12 +51,13 @@ public class Model200Response { return false; } Model200Response _200Response = (Model200Response) o; - return Objects.equals(name, _200Response.name); + return Objects.equals(name, _200Response.name) && + Objects.equals(PropertyClass, _200Response.PropertyClass); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, PropertyClass); } @Override @@ -52,6 +66,7 @@ public class Model200Response { sb.append("class Model200Response {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" PropertyClass: ").append(toIndentedString(PropertyClass)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/retrofit2rx/.gitignore b/samples/client/petstore/java/retrofit2rx/.gitignore index 7cf39af816c..a530464afa1 100644 --- a/samples/client/petstore/java/retrofit2rx/.gitignore +++ b/samples/client/petstore/java/retrofit2rx/.gitignore @@ -13,3 +13,9 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/samples/client/petstore/java/retrofit2rx/docs/Model200Response.md b/samples/client/petstore/java/retrofit2rx/docs/Model200Response.md index 0819b88c4f4..b47618b28cc 100644 --- a/samples/client/petstore/java/retrofit2rx/docs/Model200Response.md +++ b/samples/client/petstore/java/retrofit2rx/docs/Model200Response.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | [optional] +**PropertyClass** | **String** | | [optional] diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java index 9e424881cbd..0315ae62751 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java @@ -54,10 +54,10 @@ public class ApiClient { this(); for(String authName : authNames) { Interceptor auth; - if (authName == "petstore_auth") { - auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "api_key") { + if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "petstore_auth") { + auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } 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 index 5e0511922fb..0276255f68b 100644 --- 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 @@ -9,8 +9,8 @@ import retrofit2.http.*; import okhttp3.RequestBody; import org.joda.time.LocalDate; -import java.math.BigDecimal; import org.joda.time.DateTime; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java index 4a2e64b726e..304ea7a29a8 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java @@ -9,8 +9,8 @@ import retrofit2.http.*; import okhttp3.RequestBody; 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/retrofit2rx/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Model200Response.java index 3cbb15006fb..22d2bbd763d 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Model200Response.java @@ -18,6 +18,9 @@ public class Model200Response { @SerializedName("name") private Integer name = null; + @SerializedName("class") + private String PropertyClass = null; + /** **/ @ApiModelProperty(value = "") @@ -28,6 +31,16 @@ public class Model200Response { this.name = name; } + /** + **/ + @ApiModelProperty(value = "") + public String getPropertyClass() { + return PropertyClass; + } + public void setPropertyClass(String PropertyClass) { + this.PropertyClass = PropertyClass; + } + @Override public boolean equals(Object o) { @@ -38,12 +51,13 @@ public class Model200Response { return false; } Model200Response _200Response = (Model200Response) o; - return Objects.equals(name, _200Response.name); + return Objects.equals(name, _200Response.name) && + Objects.equals(PropertyClass, _200Response.PropertyClass); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, PropertyClass); } @Override @@ -52,6 +66,7 @@ public class Model200Response { sb.append("class Model200Response {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" PropertyClass: ").append(toIndentedString(PropertyClass)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/xcshareddata/SwaggerClient.xccheckout b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/xcshareddata/SwaggerClient.xccheckout deleted file mode 100644 index 879945048b3..00000000000 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/xcshareddata/SwaggerClient.xccheckout +++ /dev/null @@ -1,41 +0,0 @@ - - - - - IDESourceControlProjectFavoriteDictionaryKey - - IDESourceControlProjectIdentifier - 303FE0A9-4715-4C57-8D01-F604EF82CF6D - IDESourceControlProjectName - SwaggerClient - IDESourceControlProjectOriginsDictionary - - E5BBF0AA85077C865C95437976D06D819733A208 - https://github.com/geekerzp/swagger-codegen.git - - IDESourceControlProjectPath - samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj - IDESourceControlProjectRelativeInstallPathDictionary - - E5BBF0AA85077C865C95437976D06D819733A208 - ../../../../../../.. - - IDESourceControlProjectURL - https://github.com/geekerzp/swagger-codegen.git - IDESourceControlProjectVersion - 111 - IDESourceControlProjectWCCIdentifier - E5BBF0AA85077C865C95437976D06D819733A208 - IDESourceControlProjectWCConfigurations - - - IDESourceControlRepositoryExtensionIdentifierKey - public.vcs.git - IDESourceControlWCCIdentifierKey - E5BBF0AA85077C865C95437976D06D819733A208 - IDESourceControlWCCName - swagger-codegen - - - - diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/xcuserdata/geekerzp.xcuserdatad/UserInterfaceState.xcuserstate b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/xcuserdata/geekerzp.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index 4b91a2c5500..00000000000 Binary files a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/xcuserdata/geekerzp.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata/geekerzp.xcuserdatad/xcschemes/xcschememanagement.plist b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata/geekerzp.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index adfa137d3e3..00000000000 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata/geekerzp.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,19 +0,0 @@ - - - - - SuppressBuildableAutocreation - - 6003F589195388D20070C39A - - primary - - - 6003F5AD195388D20070C39A - - primary - - - - - diff --git a/samples/client/petstore/objc/.gitignore b/samples/client/petstore/objc/core-data/.gitignore similarity index 100% rename from samples/client/petstore/objc/.gitignore rename to samples/client/petstore/objc/core-data/.gitignore diff --git a/samples/client/petstore/objc/core-data/.swagger-codegen-ignore b/samples/client/petstore/objc/core-data/.swagger-codegen-ignore new file mode 100644 index 00000000000..19d3377182e --- /dev/null +++ b/samples/client/petstore/objc/core-data/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/objc/core-data/LICENSE b/samples/client/petstore/objc/core-data/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/samples/client/petstore/objc/core-data/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/samples/client/petstore/objc/README.md b/samples/client/petstore/objc/core-data/README.md similarity index 99% rename from samples/client/petstore/objc/README.md rename to samples/client/petstore/objc/core-data/README.md index dbaa3b6af1c..151ffe96225 100644 --- a/samples/client/petstore/objc/README.md +++ b/samples/client/petstore/objc/core-data/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-06-13T18:11:50.695+02:00 +- Build date: 2016-06-16T11:33:34.619+02:00 - Build package: class io.swagger.codegen.languages.ObjcClientCodegen ## Requirements diff --git a/samples/client/petstore/objc/SwaggerClient.podspec b/samples/client/petstore/objc/core-data/SwaggerClient.podspec similarity index 100% rename from samples/client/petstore/objc/SwaggerClient.podspec rename to samples/client/petstore/objc/core-data/SwaggerClient.podspec diff --git a/samples/client/petstore/objc/SwaggerClient/Api/SWGPetApi.h b/samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGPetApi.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Api/SWGPetApi.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGPetApi.h diff --git a/samples/client/petstore/objc/SwaggerClient/Api/SWGPetApi.m b/samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGPetApi.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Api/SWGPetApi.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGPetApi.m diff --git a/samples/client/petstore/objc/SwaggerClient/Api/SWGStoreApi.h b/samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGStoreApi.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Api/SWGStoreApi.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGStoreApi.h diff --git a/samples/client/petstore/objc/SwaggerClient/Api/SWGStoreApi.m b/samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGStoreApi.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Api/SWGStoreApi.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGStoreApi.m diff --git a/samples/client/petstore/objc/SwaggerClient/Api/SWGUserApi.h b/samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGUserApi.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Api/SWGUserApi.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGUserApi.h diff --git a/samples/client/petstore/objc/SwaggerClient/Api/SWGUserApi.m b/samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGUserApi.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Api/SWGUserApi.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGUserApi.m diff --git a/samples/client/petstore/objc/SwaggerClient/Core/JSONValueTransformer+ISO8601.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/JSONValueTransformer+ISO8601.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/JSONValueTransformer+ISO8601.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/JSONValueTransformer+ISO8601.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/JSONValueTransformer+ISO8601.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/JSONValueTransformer+ISO8601.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/JSONValueTransformer+ISO8601.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/JSONValueTransformer+ISO8601.m diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGApi.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGApi.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGApi.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGApi.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGApiClient.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGApiClient.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGApiClient.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGApiClient.m diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGConfiguration.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGConfiguration.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGConfiguration.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGConfiguration.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGConfiguration.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGConfiguration.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGConfiguration.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGConfiguration.m diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGJSONRequestSerializer.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGJSONRequestSerializer.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGJSONRequestSerializer.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGJSONRequestSerializer.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGJSONRequestSerializer.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGJSONRequestSerializer.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGJSONRequestSerializer.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGJSONRequestSerializer.m diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGJSONResponseSerializer.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGJSONResponseSerializer.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGJSONResponseSerializer.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGJSONResponseSerializer.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGJSONResponseSerializer.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGJSONResponseSerializer.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGJSONResponseSerializer.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGJSONResponseSerializer.m diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGLogger.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGLogger.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGLogger.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGLogger.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGLogger.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGLogger.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGLogger.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGLogger.m diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGObject.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGObject.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGObject.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGObject.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGObject.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGObject.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGObject.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGObject.m diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGQueryParamCollection.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGQueryParamCollection.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGQueryParamCollection.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGQueryParamCollection.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGQueryParamCollection.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGQueryParamCollection.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGQueryParamCollection.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGQueryParamCollection.m diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGResponseDeserializer.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGResponseDeserializer.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGResponseDeserializer.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGResponseDeserializer.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGResponseDeserializer.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGResponseDeserializer.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGResponseDeserializer.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGResponseDeserializer.m diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGSanitizer.h b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGSanitizer.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGSanitizer.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGSanitizer.h diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGSanitizer.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGSanitizer.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Core/SWGSanitizer.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGSanitizer.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategory.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategory.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGCategory.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategory.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategory.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategory.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGCategory.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategory.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategoryManagedObject.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategoryManagedObject.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategoryManagedObject.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategoryManagedObject.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGModel.xcdatamodeld/.xccurrentversion b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGModel.xcdatamodeld/.xccurrentversion similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGModel.xcdatamodeld/.xccurrentversion rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGModel.xcdatamodeld/.xccurrentversion diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGModel.xcdatamodeld/SWGModel.xcdatamodel/contents b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGModel.xcdatamodeld/SWGModel.xcdatamodel/contents similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGModel.xcdatamodeld/SWGModel.xcdatamodel/contents rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGModel.xcdatamodeld/SWGModel.xcdatamodel/contents diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrder.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrder.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGOrder.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrder.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrder.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrder.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGOrder.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrder.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrderManagedObject.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrderManagedObject.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrderManagedObject.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrderManagedObject.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrderManagedObjectBuilder.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrderManagedObjectBuilder.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrderManagedObjectBuilder.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGOrderManagedObjectBuilder.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGPet.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPet.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGPet.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPet.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGPet.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPet.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGPet.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPet.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPetManagedObject.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPetManagedObject.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPetManagedObject.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPetManagedObject.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPetManagedObjectBuilder.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPetManagedObjectBuilder.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPetManagedObjectBuilder.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGPetManagedObjectBuilder.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGTag.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTag.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGTag.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTag.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGTag.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTag.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGTag.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTag.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTagManagedObject.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTagManagedObject.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTagManagedObject.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTagManagedObject.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTagManagedObjectBuilder.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTagManagedObjectBuilder.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTagManagedObjectBuilder.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGTagManagedObjectBuilder.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGUser.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUser.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGUser.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUser.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGUser.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUser.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGUser.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUser.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUserManagedObject.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUserManagedObject.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUserManagedObject.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUserManagedObject.m diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.h b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUserManagedObjectBuilder.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.h rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUserManagedObjectBuilder.h diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.m b/samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUserManagedObjectBuilder.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.m rename to samples/client/petstore/objc/core-data/SwaggerClient/Model/SWGUserManagedObjectBuilder.m diff --git a/samples/client/petstore/objc/SwaggerClientTests/Podfile b/samples/client/petstore/objc/core-data/SwaggerClientTests/Podfile similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Podfile rename to samples/client/petstore/objc/core-data/SwaggerClientTests/Podfile diff --git a/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..b69c907b161 --- /dev/null +++ b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj @@ -0,0 +1,621 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 158CE3AA214CB1B31C7ADC48 /* libPods-SwaggerClient_Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FDEF5BA3CF9CFFDEB5A47DB4 /* libPods-SwaggerClient_Tests.a */; }; + 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; + 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; }; + 6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; + 6003F598195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F596195388D20070C39A /* InfoPlist.strings */; }; + 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 */; }; + 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 */; }; + 94BE6BE84795B5034A811E61 /* libPods-SwaggerClient_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D46325ECAD48245C07F6733 /* libPods-SwaggerClient_Example.a */; }; + B2ADC0B1C8A60A05C48B4DF7 /* DatabaseHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = B2ADC55130D5E329ED945E8F /* DatabaseHelper.m */; }; + B2ADC17C287DCABF329BA8AC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC7027D4B025ABCA7999F /* Main.storyboard */; }; + B2ADC2D632658A5F73C6CE66 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC65E342ADA697322D68C /* Images.xcassets */; }; + B2ADC3C7634D15595DD14814 /* BuildersTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B2ADC838FCC22F4BC6C41106 /* BuildersTest.m */; }; + B2ADC56977372855A63F4E4D /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC084A2C0BDF217832B03 /* Launch Screen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 6003F5B3195388D20070C39A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 6003F582195388D10070C39A /* Project object */; + proxyType = 1; + remoteGlobalIDString = 6003F589195388D20070C39A; + remoteInfo = SwaggerClient; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 1A81C3BE3E54961CD827EAE3 /* Pods-SwaggerClient_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwaggerClient_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwaggerClient_Tests/Pods-SwaggerClient_Tests.release.xcconfig"; sourceTree = ""; }; + 4CCE21315897B7D544C83242 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; + 6003F58A195388D20070C39A /* SwaggerClient_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwaggerClient_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 6003F58F195388D20070C39A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 6003F591195388D20070C39A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 6003F595195388D20070C39A /* SwaggerClient-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SwaggerClient-Info.plist"; sourceTree = ""; }; + 6003F597195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 6003F599195388D20070C39A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 6003F59B195388D20070C39A /* SwaggerClient-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SwaggerClient-Prefix.pch"; sourceTree = ""; }; + 6003F59C195388D20070C39A /* SWGAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SWGAppDelegate.h; sourceTree = ""; }; + 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 = ""; }; + 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 = ""; }; + 6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; 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 = ""; }; + 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 = ""; }; + B2ADC2F3483B3117A00FA91C /* DatabaseHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseHelper.h; sourceTree = ""; }; + B2ADC55130D5E329ED945E8F /* DatabaseHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DatabaseHelper.m; 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 = ""; }; + B2ADC838FCC22F4BC6C41106 /* BuildersTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BuildersTest.m; 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 = ""; }; + E445A633FA767F207D7EE6CE /* Pods-SwaggerClient_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwaggerClient_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwaggerClient_Example/Pods-SwaggerClient_Example.debug.xcconfig"; sourceTree = ""; }; + E9675D953C6DCDE71A1BDFD4 /* SwaggerClient.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SwaggerClient.podspec; path = ../SwaggerClient.podspec; sourceTree = ""; }; + FDEF5BA3CF9CFFDEB5A47DB4 /* libPods-SwaggerClient_Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SwaggerClient_Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6003F587195388D20070C39A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */, + 6003F592195388D20070C39A /* UIKit.framework in Frameworks */, + 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */, + 94BE6BE84795B5034A811E61 /* libPods-SwaggerClient_Example.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 6003F5AB195388D20070C39A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */, + 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */, + 6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */, + 158CE3AA214CB1B31C7ADC48 /* libPods-SwaggerClient_Tests.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 6003F581195388D10070C39A = { + isa = PBXGroup; + children = ( + 60FF7A9C1954A5C5007DD14C /* Podspec Metadata */, + 6003F593195388D20070C39A /* Example for SwaggerClient */, + 6003F5B5195388D20070C39A /* Tests */, + 6003F58C195388D20070C39A /* Frameworks */, + 6003F58B195388D20070C39A /* Products */, + CCE77F10C6D41F74B075ECD0 /* Pods */, + ); + sourceTree = ""; + }; + 6003F58B195388D20070C39A /* Products */ = { + isa = PBXGroup; + children = ( + 6003F58A195388D20070C39A /* SwaggerClient_Example.app */, + 6003F5AE195388D20070C39A /* SwaggerClient_Tests.xctest */, + B2ADC084A2C0BDF217832B03 /* Launch Screen.storyboard */, + ); + name = Products; + sourceTree = ""; + }; + 6003F58C195388D20070C39A /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6003F58D195388D20070C39A /* Foundation.framework */, + 6003F58F195388D20070C39A /* CoreGraphics.framework */, + 6003F591195388D20070C39A /* UIKit.framework */, + 6003F5AF195388D20070C39A /* XCTest.framework */, + 8D46325ECAD48245C07F6733 /* libPods-SwaggerClient_Example.a */, + FDEF5BA3CF9CFFDEB5A47DB4 /* libPods-SwaggerClient_Tests.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 6003F593195388D20070C39A /* Example for SwaggerClient */ = { + isa = PBXGroup; + children = ( + 6003F59C195388D20070C39A /* SWGAppDelegate.h */, + 6003F59D195388D20070C39A /* SWGAppDelegate.m */, + 6003F5A5195388D20070C39A /* SWGViewController.h */, + 6003F5A6195388D20070C39A /* SWGViewController.m */, + 6003F594195388D20070C39A /* Supporting Files */, + ); + name = "Example for SwaggerClient"; + path = SwaggerClient; + sourceTree = ""; + }; + 6003F594195388D20070C39A /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 6003F595195388D20070C39A /* SwaggerClient-Info.plist */, + 6003F596195388D20070C39A /* InfoPlist.strings */, + 6003F599195388D20070C39A /* main.m */, + 6003F59B195388D20070C39A /* SwaggerClient-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 6003F5B5195388D20070C39A /* Tests */ = { + isa = PBXGroup; + children = ( + 6003F5B6195388D20070C39A /* Supporting Files */, + B2ADC838FCC22F4BC6C41106 /* BuildersTest.m */, + B2ADCA62DE4AC0F5BAB42208 /* Helpers */, + ); + path = Tests; + sourceTree = ""; + }; + 6003F5B6195388D20070C39A /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 6003F5B7195388D20070C39A /* Tests-Info.plist */, + 6003F5B8195388D20070C39A /* InfoPlist.strings */, + 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 60FF7A9C1954A5C5007DD14C /* Podspec Metadata */ = { + isa = PBXGroup; + children = ( + E9675D953C6DCDE71A1BDFD4 /* SwaggerClient.podspec */, + 4CCE21315897B7D544C83242 /* README.md */, + B2ADC7027D4B025ABCA7999F /* Main.storyboard */, + B2ADC65E342ADA697322D68C /* Images.xcassets */, + ); + name = "Podspec Metadata"; + sourceTree = ""; + }; + B2ADCA62DE4AC0F5BAB42208 /* Helpers */ = { + isa = PBXGroup; + children = ( + B2ADC2F3483B3117A00FA91C /* DatabaseHelper.h */, + B2ADC55130D5E329ED945E8F /* DatabaseHelper.m */, + ); + path = Helpers; + sourceTree = ""; + }; + CCE77F10C6D41F74B075ECD0 /* Pods */ = { + isa = PBXGroup; + children = ( + E445A633FA767F207D7EE6CE /* Pods-SwaggerClient_Example.debug.xcconfig */, + BFB4BE760737508B3CFC23B2 /* Pods-SwaggerClient_Example.release.xcconfig */, + 73CCD82196AABD64F2807C7B /* Pods-SwaggerClient_Tests.debug.xcconfig */, + 1A81C3BE3E54961CD827EAE3 /* Pods-SwaggerClient_Tests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6003F589195388D20070C39A /* SwaggerClient_Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "SwaggerClient_Example" */; + buildPhases = ( + 799E7E29D924C30424DFBA28 /* Check Pods Manifest.lock */, + 6003F586195388D20070C39A /* Sources */, + 6003F587195388D20070C39A /* Frameworks */, + 6003F588195388D20070C39A /* Resources */, + 429AF5C69E165ED75311B4B0 /* Copy Pods Resources */, + 183E54C09C54DAEB54B2546F /* Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SwaggerClient_Example; + productName = SwaggerClient; + productReference = 6003F58A195388D20070C39A /* SwaggerClient_Example.app */; + productType = "com.apple.product-type.application"; + }; + 6003F5AD195388D20070C39A /* SwaggerClient_Tests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "SwaggerClient_Tests" */; + buildPhases = ( + 7B069562A9F91E498732474F /* Check Pods Manifest.lock */, + 6003F5AA195388D20070C39A /* Sources */, + 6003F5AB195388D20070C39A /* Frameworks */, + 6003F5AC195388D20070C39A /* Resources */, + E337D7E459CCFFDF27046FFC /* Copy Pods Resources */, + 111D7956304BD6E860AA8709 /* Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 6003F5B4195388D20070C39A /* PBXTargetDependency */, + ); + name = SwaggerClient_Tests; + productName = SwaggerClientTests; + productReference = 6003F5AE195388D20070C39A /* SwaggerClient_Tests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 6003F582195388D10070C39A /* Project object */ = { + isa = PBXProject; + attributes = { + CLASSPREFIX = SWG; + LastUpgradeCheck = 0510; + ORGANIZATIONNAME = geekerzp; + }; + buildConfigurationList = 6003F585195388D10070C39A /* Build configuration list for PBXProject "SwaggerClient" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 6003F581195388D10070C39A; + productRefGroup = 6003F58B195388D20070C39A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6003F589195388D20070C39A /* SwaggerClient_Example */, + 6003F5AD195388D20070C39A /* SwaggerClient_Tests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 6003F588195388D20070C39A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6003F598195388D20070C39A /* InfoPlist.strings in Resources */, + B2ADC17C287DCABF329BA8AC /* Main.storyboard in Resources */, + B2ADC2D632658A5F73C6CE66 /* Images.xcassets in Resources */, + B2ADC56977372855A63F4E4D /* Launch Screen.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 6003F5AC195388D20070C39A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 111D7956304BD6E860AA8709 /* Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient_Tests/Pods-SwaggerClient_Tests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 183E54C09C54DAEB54B2546F /* Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient_Example/Pods-SwaggerClient_Example-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 429AF5C69E165ED75311B4B0 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient_Example/Pods-SwaggerClient_Example-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 799E7E29D924C30424DFBA28 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 7B069562A9F91E498732474F /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + E337D7E459CCFFDF27046FFC /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient_Tests/Pods-SwaggerClient_Tests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 6003F586195388D20070C39A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6003F59E195388D20070C39A /* SWGAppDelegate.m in Sources */, + 6003F5A7195388D20070C39A /* SWGViewController.m in Sources */, + 6003F59A195388D20070C39A /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 6003F5AA195388D20070C39A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B2ADC3C7634D15595DD14814 /* BuildersTest.m in Sources */, + B2ADC0B1C8A60A05C48B4DF7 /* DatabaseHelper.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 6003F5B4195388D20070C39A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 6003F589195388D20070C39A /* SwaggerClient_Example */; + targetProxy = 6003F5B3195388D20070C39A /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 6003F596195388D20070C39A /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 6003F597195388D20070C39A /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 6003F5B8195388D20070C39A /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 6003F5B9195388D20070C39A /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 6003F5BD195388D20070C39A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 6003F5BE195388D20070C39A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 6003F5C0195388D20070C39A /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E445A633FA767F207D7EE6CE /* Pods-SwaggerClient_Example.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "SwaggerClient/SwaggerClient-Prefix.pch"; + INFOPLIST_FILE = "SwaggerClient/SwaggerClient-Info.plist"; + MODULE_NAME = ExampleApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 6003F5C1195388D20070C39A /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = BFB4BE760737508B3CFC23B2 /* Pods-SwaggerClient_Example.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "SwaggerClient/SwaggerClient-Prefix.pch"; + INFOPLIST_FILE = "SwaggerClient/SwaggerClient-Info.plist"; + MODULE_NAME = ExampleApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + 6003F5C3195388D20070C39A /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 73CCD82196AABD64F2807C7B /* Pods-SwaggerClient_Tests.debug.xcconfig */; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = "Tests/Tests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = xctest; + }; + name = Debug; + }; + 6003F5C4195388D20070C39A /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 1A81C3BE3E54961CD827EAE3 /* Pods-SwaggerClient_Tests.release.xcconfig */; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch"; + INFOPLIST_FILE = "Tests/Tests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = xctest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6003F585195388D10070C39A /* Build configuration list for PBXProject "SwaggerClient" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6003F5BD195388D20070C39A /* Debug */, + 6003F5BE195388D20070C39A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "SwaggerClient_Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6003F5C0195388D20070C39A /* Debug */, + 6003F5C1195388D20070C39A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "SwaggerClient_Tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6003F5C3195388D20070C39A /* Debug */, + 6003F5C4195388D20070C39A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 6003F582195388D10070C39A /* Project object */; +} diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/All Tests.xcscheme b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/All Tests.xcscheme new file mode 100644 index 00000000000..5c68411bb2d --- /dev/null +++ b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/All Tests.xcscheme @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/SwaggerClient-Example.xcscheme b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/SwaggerClient-Example.xcscheme similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/SwaggerClient-Example.xcscheme rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/SwaggerClient-Example.xcscheme diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Images.xcassets/AppIcon.appiconset/Contents.json b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/Images.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Images.xcassets/AppIcon.appiconset/Contents.json rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/Images.xcassets/AppIcon.appiconset/Contents.json diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Images.xcassets/LaunchImage.launchimage/Contents.json b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/Images.xcassets/LaunchImage.launchimage/Contents.json similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Images.xcassets/LaunchImage.launchimage/Contents.json rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/Images.xcassets/LaunchImage.launchimage/Contents.json diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Main.storyboard b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/Main.storyboard similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Main.storyboard rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/Main.storyboard diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGAppDelegate.h b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SWGAppDelegate.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGAppDelegate.h rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SWGAppDelegate.h diff --git a/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SWGAppDelegate.m b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SWGAppDelegate.m new file mode 100644 index 00000000000..25ad44a411e --- /dev/null +++ b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SWGAppDelegate.m @@ -0,0 +1,19 @@ +// +// SWGAppDelegate.m +// SwaggerClient +// +// Created by CocoaPods on 06/26/2015. +// Copyright (c) 2014 geekerzp. All rights reserved. +// + +#import "SWGAppDelegate.h" + +@implementation SWGAppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + return YES; +} + + +@end diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.h b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SWGViewController.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.h rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SWGViewController.h diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SWGViewController.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SWGViewController.m diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Prefix.pch b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SwaggerClient-Prefix.pch similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Prefix.pch rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/SwaggerClient-Prefix.pch diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/en.lproj/InfoPlist.strings b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/en.lproj/InfoPlist.strings similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/en.lproj/InfoPlist.strings rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/en.lproj/InfoPlist.strings diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/main.m b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/main.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/main.m rename to samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient/main.m diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/BuildersTest.m b/samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/BuildersTest.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/BuildersTest.m rename to samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/BuildersTest.m diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/Helpers/DatabaseHelper.h b/samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/Helpers/DatabaseHelper.h similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/Helpers/DatabaseHelper.h rename to samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/Helpers/DatabaseHelper.h diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/Helpers/DatabaseHelper.m b/samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/Helpers/DatabaseHelper.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/Helpers/DatabaseHelper.m rename to samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/Helpers/DatabaseHelper.m diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/Tests-Info.plist b/samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/Tests-Info.plist similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/Tests-Info.plist rename to samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/Tests-Info.plist diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/Tests-Prefix.pch b/samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/Tests-Prefix.pch similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/Tests-Prefix.pch rename to samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/Tests-Prefix.pch diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/en.lproj/InfoPlist.strings b/samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/en.lproj/InfoPlist.strings similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/en.lproj/InfoPlist.strings rename to samples/client/petstore/objc/core-data/SwaggerClientTests/Tests/en.lproj/InfoPlist.strings diff --git a/samples/client/petstore/objc/SwaggerClientTests/pom.xml b/samples/client/petstore/objc/core-data/SwaggerClientTests/pom.xml similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/pom.xml rename to samples/client/petstore/objc/core-data/SwaggerClientTests/pom.xml diff --git a/samples/client/petstore/objc/git_push.sh b/samples/client/petstore/objc/core-data/git_push.sh similarity index 100% rename from samples/client/petstore/objc/git_push.sh rename to samples/client/petstore/objc/core-data/git_push.sh diff --git a/samples/client/petstore/objc/default/.gitignore b/samples/client/petstore/objc/default/.gitignore new file mode 100644 index 00000000000..79d9331b6d4 --- /dev/null +++ b/samples/client/petstore/objc/default/.gitignore @@ -0,0 +1,53 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md + +fastlane/report.xml +fastlane/screenshots diff --git a/samples/client/petstore/objc/default/.swagger-codegen-ignore b/samples/client/petstore/objc/default/.swagger-codegen-ignore new file mode 100644 index 00000000000..19d3377182e --- /dev/null +++ b/samples/client/petstore/objc/default/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/objc/default/LICENSE b/samples/client/petstore/objc/default/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/samples/client/petstore/objc/default/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/samples/client/petstore/objc/default/README.md b/samples/client/petstore/objc/default/README.md new file mode 100644 index 00000000000..c27432d29cc --- /dev/null +++ b/samples/client/petstore/objc/default/README.md @@ -0,0 +1,147 @@ +# SwaggerClient + +This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + +This ObjC package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: 1.0.0 +- Package version: +- Build date: 2016-06-16T11:33:30.448+02:00 +- Build package: class io.swagger.codegen.languages.ObjcClientCodegen + +## Requirements + +The SDK requires [**ARC (Automatic Reference Counting)**](http://stackoverflow.com/questions/7778356/how-to-enable-disable-automatic-reference-counting) to be enabled in the Xcode project. + +## Installation & Usage +### Install from Github using [CocoaPods](https://cocoapods.org/) + +Add the following to the Podfile: + +```ruby +pod 'SwaggerClient', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git' +``` + +To specify a particular branch, append `, :branch => 'branch-name-here'` + +To specify a particular commit, append `, :commit => '11aa22'` + +### Install from local path using [CocoaPods](https://cocoapods.org/) + +Put the SDK under your project folder (e.g. /path/to/objc_project/Vendor/SwaggerClient) and then add the following to the Podfile: + +```ruby +pod 'SwaggerClient', :path => 'Vendor/SwaggerClient' +``` + +### Usage + +Import the following: + +```objc +#import +#import +// load models +#import +#import +#import +#import +#import +// load API classes for accessing endpoints +#import +#import +#import + +``` + +## Recommendation + +It's recommended to create an instance of ApiClient per thread in a multi-threaded environment to avoid any potential issue. + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```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) + +SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Add a new pet to the store +[apiInstance addPetWithBody:body + completionHandler: ^(NSError* error)) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; + +``` + +## Documentation for API Endpoints + +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* | [**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* | [**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* | [**getInventory**](docs/SWGStoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*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 +*SWGUserApi* | [**createUsersWithArrayInput**](docs/SWGUserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*SWGUserApi* | [**createUsersWithListInput**](docs/SWGUserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*SWGUserApi* | [**deleteUser**](docs/SWGUserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*SWGUserApi* | [**getUserByName**](docs/SWGUserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*SWGUserApi* | [**loginUser**](docs/SWGUserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*SWGUserApi* | [**logoutUser**](docs/SWGUserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*SWGUserApi* | [**updateUser**](docs/SWGUserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [SWGCategory](docs/SWGCategory.md) + - [SWGOrder](docs/SWGOrder.md) + - [SWGPet](docs/SWGPet.md) + - [SWGTag](docs/SWGTag.md) + - [SWGUser](docs/SWGUser.md) + + +## Documentation For Authorization + + +## petstore_auth + +- **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 + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +## Author + +apiteam@wordnik.com + + diff --git a/samples/client/petstore/objc/default/SwaggerClient.podspec b/samples/client/petstore/objc/default/SwaggerClient.podspec new file mode 100644 index 00000000000..934e35a2a6b --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient.podspec @@ -0,0 +1,37 @@ +# +# Be sure to run `pod lib lint SwaggerClient.podspec' to ensure this is a +# valid spec and remove all comments before submitting the spec. +# +# Any lines starting with a # are optional, but encouraged +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html +# + +Pod::Spec.new do |s| + s.name = "SwaggerClient" + s.version = "1.0.0" + + s.summary = "Swagger Petstore" + s.description = <<-DESC + This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + DESC + + s.platform = :ios, '7.0' + s.requires_arc = true + + s.framework = 'SystemConfiguration' + + s.homepage = "https://github.com/swagger-api/swagger-codegen" + s.license = "Apache License, Version 2.0" + s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" } + s.author = { "Swagger" => "apiteam@swagger.io" } + + s.source_files = 'SwaggerClient/**/*.{m,h}' + s.public_header_files = 'SwaggerClient/**/*.h' + + + s.dependency 'AFNetworking', '~> 3' + s.dependency 'JSONModel', '~> 1.2' + s.dependency 'ISO8601', '~> 0.5' +end + diff --git a/samples/client/petstore/objc/default/SwaggerClient/Api/SWGPetApi.h b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGPetApi.h new file mode 100644 index 00000000000..97f914a627e --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGPetApi.h @@ -0,0 +1,150 @@ +#import +#import "SWGPet.h" +#import "SWGApi.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +@interface SWGPetApi: NSObject + +extern NSString* kSWGPetApiErrorDomain; +extern NSInteger kSWGPetApiMissingParamErrorCode; + ++(instancetype) sharedAPI; + +/// Add a new pet to the store +/// +/// +/// @param body Pet object that needs to be added to the store (optional) +/// +/// code:405 message:"Invalid input" +/// +/// @return +-(NSNumber*) addPetWithBody: (SWGPet*) body + completionHandler: (void (^)(NSError* error)) handler; + + +/// Deletes a pet +/// +/// +/// @param petId Pet id to delete +/// @param apiKey (optional) +/// +/// code:400 message:"Invalid pet value" +/// +/// @return +-(NSNumber*) deletePetWithPetId: (NSNumber*) petId + apiKey: (NSString*) apiKey + completionHandler: (void (^)(NSError* error)) handler; + + +/// Finds Pets by status +/// 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) +/// +/// code:200 message:"successful operation", +/// code:400 message:"Invalid status value" +/// +/// @return NSArray* +-(NSNumber*) findPetsByStatusWithStatus: (NSArray*) status + 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. +/// +/// @param tags Tags to filter by (optional) +/// +/// code:200 message:"successful operation", +/// code:400 message:"Invalid tag value" +/// +/// @return NSArray* +-(NSNumber*) findPetsByTagsWithTags: (NSArray*) tags + completionHandler: (void (^)(NSArray* output, NSError* error)) handler; + + +/// 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 +/// +/// code:200 message:"successful operation", +/// code:400 message:"Invalid ID supplied", +/// code:404 message:"Pet not found" +/// +/// @return SWGPet* +-(NSNumber*) getPetByIdWithPetId: (NSNumber*) petId + completionHandler: (void (^)(SWGPet* output, NSError* error)) handler; + + +/// Update an existing pet +/// +/// +/// @param body Pet object that needs to be added to the store (optional) +/// +/// code:400 message:"Invalid ID supplied", +/// code:404 message:"Pet not found", +/// code:405 message:"Validation exception" +/// +/// @return +-(NSNumber*) updatePetWithBody: (SWGPet*) body + completionHandler: (void (^)(NSError* error)) handler; + + +/// Updates a pet in the store with form data +/// +/// +/// @param petId ID of pet that needs to be updated +/// @param name Updated name of the pet (optional) +/// @param status Updated status of the pet (optional) +/// +/// code:405 message:"Invalid input" +/// +/// @return +-(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId + name: (NSString*) name + status: (NSString*) status + completionHandler: (void (^)(NSError* error)) handler; + + +/// uploads an image +/// +/// +/// @param petId ID of pet to update +/// @param additionalMetadata Additional data to pass to server (optional) +/// @param file file to upload (optional) +/// +/// code:0 message:"successful operation" +/// +/// @return +-(NSNumber*) uploadFileWithPetId: (NSNumber*) petId + additionalMetadata: (NSString*) additionalMetadata + file: (NSURL*) file + completionHandler: (void (^)(NSError* error)) handler; + + + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Api/SWGPetApi.m b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGPetApi.m new file mode 100644 index 00000000000..409f5b86655 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGPetApi.m @@ -0,0 +1,632 @@ +#import "SWGPetApi.h" +#import "SWGQueryParamCollection.h" +#import "SWGPet.h" + + +@interface SWGPetApi () + +@property (nonatomic, strong) NSMutableDictionary *defaultHeaders; + +@end + +@implementation SWGPetApi + +NSString* kSWGPetApiErrorDomain = @"SWGPetApiErrorDomain"; +NSInteger kSWGPetApiMissingParamErrorCode = 234513; + +@synthesize apiClient = _apiClient; + +#pragma mark - Initialize methods + +- (instancetype) init { + self = [super init]; + if (self) { + SWGConfiguration *config = [SWGConfiguration sharedConfig]; + if (config.apiClient == nil) { + config.apiClient = [[SWGApiClient alloc] init]; + } + _apiClient = config.apiClient; + _defaultHeaders = [NSMutableDictionary dictionary]; + } + return self; +} + +- (id) initWithApiClient:(SWGApiClient *)apiClient { + self = [super init]; + if (self) { + _apiClient = apiClient; + _defaultHeaders = [NSMutableDictionary dictionary]; + } + return self; +} + +#pragma mark - + ++ (instancetype)sharedAPI { + static SWGPetApi *sharedAPI; + static dispatch_once_t once; + dispatch_once(&once, ^{ + sharedAPI = [[self alloc] init]; + }); + return sharedAPI; +} + +-(NSString*) defaultHeaderForKey:(NSString*)key { + return self.defaultHeaders[key]; +} + +-(void) addHeader:(NSString*)value forKey:(NSString*)key { + [self setDefaultHeaderValue:value forKey:key]; +} + +-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key { + [self.defaultHeaders setValue:value forKey:key]; +} + +-(NSUInteger) requestQueueSize { + return [SWGApiClient requestQueueSize]; +} + +#pragma mark - Api Methods + +/// +/// Add a new pet to the store +/// +/// @param body Pet object that needs to be added to the store (optional) +/// +/// @returns void +/// +-(NSNumber*) addPetWithBody: (SWGPet*) body + completionHandler: (void (^)(NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer 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) { + if(handler) { + handler(error); + } + } + ]; +} + +/// +/// Deletes a pet +/// +/// @param petId Pet id to delete +/// +/// @param apiKey (optional) +/// +/// @returns void +/// +-(NSNumber*) deletePetWithPetId: (NSNumber*) petId + apiKey: (NSString*) apiKey + completionHandler: (void (^)(NSError* error)) handler { + // verify the required parameter 'petId' is set + if (petId == nil) { + NSParameterAssert(petId); + if(handler) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : [NSString stringWithFormat:NSLocalizedString(@"Missing required parameter '%@'", nil),@"petId"] }; + NSError* error = [NSError errorWithDomain:kSWGPetApiErrorDomain code:kSWGPetApiMissingParamErrorCode userInfo:userInfo]; + handler(error); + } + return nil; + } + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + if (apiKey != nil) { + headerParams[@"api_key"] = apiKey; + } + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + + return [self.apiClient requestWithPath: resourcePath + method: @"DELETE" + 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) { + if(handler) { + handler(error); + } + } + ]; +} + +/// +/// Finds Pets by status +/// 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* +/// +-(NSNumber*) findPetsByStatusWithStatus: (NSArray*) status + completionHandler: (void (^)(NSArray* output, NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/findByStatus"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if (status != nil) { + queryParams[@"status"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: status format: @"multi"]; + + } + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[@"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: @"NSArray*" + completionBlock: ^(id data, NSError *error) { + if(handler) { + handler((NSArray*)data, error); + } + } + ]; +} + +/// +/// Finds Pets by tags +/// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. +/// @param tags Tags to filter by (optional) +/// +/// @returns NSArray* +/// +-(NSNumber*) findPetsByTagsWithTags: (NSArray*) tags + completionHandler: (void (^)(NSArray* output, NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/findByTags"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if (tags != nil) { + queryParams[@"tags"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: tags format: @"multi"]; + + } + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[@"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: @"NSArray*" + completionBlock: ^(id data, NSError *error) { + if(handler) { + handler((NSArray*)data, error); + } + } + ]; +} + +/// +/// 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 SWGPet* +/// +-(NSNumber*) getPetByIdWithPetId: (NSNumber*) petId + completionHandler: (void (^)(SWGPet* output, NSError* error)) handler { + // verify the required parameter 'petId' is set + if (petId == nil) { + NSParameterAssert(petId); + if(handler) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : [NSString stringWithFormat:NSLocalizedString(@"Missing required parameter '%@'", nil),@"petId"] }; + NSError* error = [NSError errorWithDomain:kSWGPetApiErrorDomain code:kSWGPetApiMissingParamErrorCode userInfo:userInfo]; + handler(nil, error); + } + return nil; + } + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[@"petstore_auth", @"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: @"SWGPet*" + completionBlock: ^(id data, NSError *error) { + if(handler) { + handler((SWGPet*)data, error); + } + } + ]; +} + +/// +/// Update an existing pet +/// +/// @param body Pet object that needs to be added to the store (optional) +/// +/// @returns void +/// +-(NSNumber*) updatePetWithBody: (SWGPet*) body + completionHandler: (void (^)(NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer 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: @"PUT" + 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) { + if(handler) { + handler(error); + } + } + ]; +} + +/// +/// Updates a pet in the store with form data +/// +/// @param petId ID of pet that needs to be updated +/// +/// @param name Updated name of the pet (optional) +/// +/// @param status Updated status of the pet (optional) +/// +/// @returns void +/// +-(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId + name: (NSString*) name + status: (NSString*) status + completionHandler: (void (^)(NSError* error)) handler { + // verify the required parameter 'petId' is set + if (petId == nil) { + NSParameterAssert(petId); + if(handler) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : [NSString stringWithFormat:NSLocalizedString(@"Missing required parameter '%@'", nil),@"petId"] }; + NSError* error = [NSError errorWithDomain:kSWGPetApiErrorDomain code:kSWGPetApiMissingParamErrorCode userInfo:userInfo]; + handler(error); + } + return nil; + } + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[@"application/x-www-form-urlencoded"]]; + + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + if (name) { + formParams[@"name"] = name; + } + if (status) { + formParams[@"status"] = status; + } + + 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) { + if(handler) { + handler(error); + } + } + ]; +} + +/// +/// uploads an image +/// +/// @param petId ID of pet to update +/// +/// @param additionalMetadata Additional data to pass to server (optional) +/// +/// @param file file to upload (optional) +/// +/// @returns void +/// +-(NSNumber*) uploadFileWithPetId: (NSNumber*) petId + additionalMetadata: (NSString*) additionalMetadata + file: (NSURL*) file + completionHandler: (void (^)(NSError* error)) handler { + // verify the required parameter 'petId' is set + if (petId == nil) { + NSParameterAssert(petId); + if(handler) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : [NSString stringWithFormat:NSLocalizedString(@"Missing required parameter '%@'", nil),@"petId"] }; + NSError* error = [NSError errorWithDomain:kSWGPetApiErrorDomain code:kSWGPetApiMissingParamErrorCode userInfo:userInfo]; + handler(error); + } + return nil; + } + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}/uploadImage"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[@"multipart/form-data"]]; + + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + if (additionalMetadata) { + formParams[@"additionalMetadata"] = additionalMetadata; + } + localVarFiles[@"file"] = file; + + 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) { + if(handler) { + handler(error); + } + } + ]; +} + + + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Api/SWGStoreApi.h b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGStoreApi.h new file mode 100644 index 00000000000..bbd588dba25 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGStoreApi.h @@ -0,0 +1,89 @@ +#import +#import "SWGOrder.h" +#import "SWGApi.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +@interface SWGStoreApi: NSObject + +extern NSString* kSWGStoreApiErrorDomain; +extern NSInteger kSWGStoreApiMissingParamErrorCode; + ++(instancetype) sharedAPI; + +/// Delete purchase order by ID +/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +/// +/// @param orderId ID of the order that needs to be deleted +/// +/// code:400 message:"Invalid ID supplied", +/// code:404 message:"Order not found" +/// +/// @return +-(NSNumber*) deleteOrderWithOrderId: (NSString*) orderId + completionHandler: (void (^)(NSError* error)) handler; + + +/// Returns pet inventories by status +/// Returns a map of status codes to quantities +/// +/// +/// code:200 message:"successful operation" +/// +/// @return NSDictionary* +-(NSNumber*) getInventoryWithCompletionHandler: + (void (^)(NSDictionary* 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 +/// +/// @param orderId ID of pet that needs to be fetched +/// +/// code:200 message:"successful operation", +/// code:400 message:"Invalid ID supplied", +/// code:404 message:"Order not found" +/// +/// @return SWGOrder* +-(NSNumber*) getOrderByIdWithOrderId: (NSString*) orderId + completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler; + + +/// Place an order for a pet +/// +/// +/// @param body order placed for purchasing the pet (optional) +/// +/// code:200 message:"successful operation", +/// code:400 message:"Invalid Order" +/// +/// @return SWGOrder* +-(NSNumber*) placeOrderWithBody: (SWGOrder*) body + completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler; + + + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Api/SWGStoreApi.m b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGStoreApi.m new file mode 100644 index 00000000000..e5964200f20 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGStoreApi.m @@ -0,0 +1,333 @@ +#import "SWGStoreApi.h" +#import "SWGQueryParamCollection.h" +#import "SWGOrder.h" + + +@interface SWGStoreApi () + +@property (nonatomic, strong) NSMutableDictionary *defaultHeaders; + +@end + +@implementation SWGStoreApi + +NSString* kSWGStoreApiErrorDomain = @"SWGStoreApiErrorDomain"; +NSInteger kSWGStoreApiMissingParamErrorCode = 234513; + +@synthesize apiClient = _apiClient; + +#pragma mark - Initialize methods + +- (instancetype) init { + self = [super init]; + if (self) { + SWGConfiguration *config = [SWGConfiguration sharedConfig]; + if (config.apiClient == nil) { + config.apiClient = [[SWGApiClient alloc] init]; + } + _apiClient = config.apiClient; + _defaultHeaders = [NSMutableDictionary dictionary]; + } + return self; +} + +- (id) initWithApiClient:(SWGApiClient *)apiClient { + self = [super init]; + if (self) { + _apiClient = apiClient; + _defaultHeaders = [NSMutableDictionary dictionary]; + } + return self; +} + +#pragma mark - + ++ (instancetype)sharedAPI { + static SWGStoreApi *sharedAPI; + static dispatch_once_t once; + dispatch_once(&once, ^{ + sharedAPI = [[self alloc] init]; + }); + return sharedAPI; +} + +-(NSString*) defaultHeaderForKey:(NSString*)key { + return self.defaultHeaders[key]; +} + +-(void) addHeader:(NSString*)value forKey:(NSString*)key { + [self setDefaultHeaderValue:value forKey:key]; +} + +-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key { + [self.defaultHeaders setValue:value forKey:key]; +} + +-(NSUInteger) requestQueueSize { + return [SWGApiClient requestQueueSize]; +} + +#pragma mark - Api Methods + +/// +/// Delete purchase order by ID +/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +/// @param orderId ID of the order that needs to be deleted +/// +/// @returns void +/// +-(NSNumber*) deleteOrderWithOrderId: (NSString*) orderId + completionHandler: (void (^)(NSError* error)) handler { + // verify the required parameter 'orderId' is set + if (orderId == nil) { + NSParameterAssert(orderId); + if(handler) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : [NSString stringWithFormat:NSLocalizedString(@"Missing required parameter '%@'", nil),@"orderId"] }; + NSError* error = [NSError errorWithDomain:kSWGStoreApiErrorDomain code:kSWGStoreApiMissingParamErrorCode userInfo:userInfo]; + handler(error); + } + return nil; + } + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/order/{orderId}"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (orderId != nil) { + pathParams[@"orderId"] = orderId; + } + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + + return [self.apiClient requestWithPath: resourcePath + method: @"DELETE" + 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) { + if(handler) { + handler(error); + } + } + ]; +} + +/// +/// Returns pet inventories by status +/// Returns a map of status codes to quantities +/// @returns NSDictionary* +/// +-(NSNumber*) getInventoryWithCompletionHandler: + (void (^)(NSDictionary* output, NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/inventory"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer 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: @"NSDictionary*" + completionBlock: ^(id data, NSError *error) { + if(handler) { + handler((NSDictionary*)data, error); + } + } + ]; +} + +/// +/// Find purchase order by ID +/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions +/// @param orderId ID of pet that needs to be fetched +/// +/// @returns SWGOrder* +/// +-(NSNumber*) getOrderByIdWithOrderId: (NSString*) orderId + completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler { + // verify the required parameter 'orderId' is set + if (orderId == nil) { + NSParameterAssert(orderId); + if(handler) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : [NSString stringWithFormat:NSLocalizedString(@"Missing required parameter '%@'", nil),@"orderId"] }; + NSError* error = [NSError errorWithDomain:kSWGStoreApiErrorDomain code:kSWGStoreApiMissingParamErrorCode userInfo:userInfo]; + handler(nil, error); + } + return nil; + } + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/order/{orderId}"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (orderId != nil) { + pathParams[@"orderId"] = orderId; + } + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + 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: @"SWGOrder*" + completionBlock: ^(id data, NSError *error) { + if(handler) { + handler((SWGOrder*)data, error); + } + } + ]; +} + +/// +/// Place an order for a pet +/// +/// @param body order placed for purchasing the pet (optional) +/// +/// @returns SWGOrder* +/// +-(NSNumber*) placeOrderWithBody: (SWGOrder*) body + completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/order"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + 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: @"SWGOrder*" + completionBlock: ^(id data, NSError *error) { + if(handler) { + handler((SWGOrder*)data, error); + } + } + ]; +} + + + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Api/SWGUserApi.h b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGUserApi.h new file mode 100644 index 00000000000..67f8ec9cbb2 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGUserApi.h @@ -0,0 +1,142 @@ +#import +#import "SWGUser.h" +#import "SWGApi.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +@interface SWGUserApi: NSObject + +extern NSString* kSWGUserApiErrorDomain; +extern NSInteger kSWGUserApiMissingParamErrorCode; + ++(instancetype) sharedAPI; + +/// Create user +/// This can only be done by the logged in user. +/// +/// @param body Created user object (optional) +/// +/// code:0 message:"successful operation" +/// +/// @return +-(NSNumber*) createUserWithBody: (SWGUser*) body + completionHandler: (void (^)(NSError* error)) handler; + + +/// Creates list of users with given input array +/// +/// +/// @param body List of user object (optional) +/// +/// code:0 message:"successful operation" +/// +/// @return +-(NSNumber*) createUsersWithArrayInputWithBody: (NSArray*) body + completionHandler: (void (^)(NSError* error)) handler; + + +/// Creates list of users with given input array +/// +/// +/// @param body List of user object (optional) +/// +/// code:0 message:"successful operation" +/// +/// @return +-(NSNumber*) createUsersWithListInputWithBody: (NSArray*) body + completionHandler: (void (^)(NSError* error)) handler; + + +/// Delete user +/// This can only be done by the logged in user. +/// +/// @param username The name that needs to be deleted +/// +/// code:400 message:"Invalid username supplied", +/// code:404 message:"User not found" +/// +/// @return +-(NSNumber*) deleteUserWithUsername: (NSString*) username + completionHandler: (void (^)(NSError* error)) handler; + + +/// Get user by user name +/// +/// +/// @param username The name that needs to be fetched. Use user1 for testing. +/// +/// code:200 message:"successful operation", +/// code:400 message:"Invalid username supplied", +/// code:404 message:"User not found" +/// +/// @return SWGUser* +-(NSNumber*) getUserByNameWithUsername: (NSString*) username + completionHandler: (void (^)(SWGUser* output, NSError* error)) handler; + + +/// Logs user into the system +/// +/// +/// @param username The user name for login (optional) +/// @param password The password for login in clear text (optional) +/// +/// code:200 message:"successful operation", +/// code:400 message:"Invalid username/password supplied" +/// +/// @return NSString* +-(NSNumber*) loginUserWithUsername: (NSString*) username + password: (NSString*) password + completionHandler: (void (^)(NSString* output, NSError* error)) handler; + + +/// Logs out current logged in user session +/// +/// +/// +/// code:0 message:"successful operation" +/// +/// @return +-(NSNumber*) logoutUserWithCompletionHandler: + (void (^)(NSError* error)) handler; + + +/// Updated user +/// This can only be done by the logged in user. +/// +/// @param username name that need to be deleted +/// @param body Updated user object (optional) +/// +/// code:400 message:"Invalid user supplied", +/// code:404 message:"User not found" +/// +/// @return +-(NSNumber*) updateUserWithUsername: (NSString*) username + body: (SWGUser*) body + completionHandler: (void (^)(NSError* error)) handler; + + + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Api/SWGUserApi.m b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGUserApi.m new file mode 100644 index 00000000000..6ffb578ed76 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Api/SWGUserApi.m @@ -0,0 +1,594 @@ +#import "SWGUserApi.h" +#import "SWGQueryParamCollection.h" +#import "SWGUser.h" + + +@interface SWGUserApi () + +@property (nonatomic, strong) NSMutableDictionary *defaultHeaders; + +@end + +@implementation SWGUserApi + +NSString* kSWGUserApiErrorDomain = @"SWGUserApiErrorDomain"; +NSInteger kSWGUserApiMissingParamErrorCode = 234513; + +@synthesize apiClient = _apiClient; + +#pragma mark - Initialize methods + +- (instancetype) init { + self = [super init]; + if (self) { + SWGConfiguration *config = [SWGConfiguration sharedConfig]; + if (config.apiClient == nil) { + config.apiClient = [[SWGApiClient alloc] init]; + } + _apiClient = config.apiClient; + _defaultHeaders = [NSMutableDictionary dictionary]; + } + return self; +} + +- (id) initWithApiClient:(SWGApiClient *)apiClient { + self = [super init]; + if (self) { + _apiClient = apiClient; + _defaultHeaders = [NSMutableDictionary dictionary]; + } + return self; +} + +#pragma mark - + ++ (instancetype)sharedAPI { + static SWGUserApi *sharedAPI; + static dispatch_once_t once; + dispatch_once(&once, ^{ + sharedAPI = [[self alloc] init]; + }); + return sharedAPI; +} + +-(NSString*) defaultHeaderForKey:(NSString*)key { + return self.defaultHeaders[key]; +} + +-(void) addHeader:(NSString*)value forKey:(NSString*)key { + [self setDefaultHeaderValue:value forKey:key]; +} + +-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key { + [self.defaultHeaders setValue:value forKey:key]; +} + +-(NSUInteger) requestQueueSize { + return [SWGApiClient requestQueueSize]; +} + +#pragma mark - Api Methods + +/// +/// Create user +/// This can only be done by the logged in user. +/// @param body Created user object (optional) +/// +/// @returns void +/// +-(NSNumber*) createUserWithBody: (SWGUser*) body + completionHandler: (void (^)(NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + 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) { + if(handler) { + handler(error); + } + } + ]; +} + +/// +/// Creates list of users with given input array +/// +/// @param body List of user object (optional) +/// +/// @returns void +/// +-(NSNumber*) createUsersWithArrayInputWithBody: (NSArray*) body + completionHandler: (void (^)(NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/createWithArray"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + 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) { + if(handler) { + handler(error); + } + } + ]; +} + +/// +/// Creates list of users with given input array +/// +/// @param body List of user object (optional) +/// +/// @returns void +/// +-(NSNumber*) createUsersWithListInputWithBody: (NSArray*) body + completionHandler: (void (^)(NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/createWithList"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + 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) { + if(handler) { + handler(error); + } + } + ]; +} + +/// +/// Delete user +/// This can only be done by the logged in user. +/// @param username The name that needs to be deleted +/// +/// @returns void +/// +-(NSNumber*) deleteUserWithUsername: (NSString*) username + completionHandler: (void (^)(NSError* error)) handler { + // verify the required parameter 'username' is set + if (username == nil) { + NSParameterAssert(username); + if(handler) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : [NSString stringWithFormat:NSLocalizedString(@"Missing required parameter '%@'", nil),@"username"] }; + NSError* error = [NSError errorWithDomain:kSWGUserApiErrorDomain code:kSWGUserApiMissingParamErrorCode userInfo:userInfo]; + handler(error); + } + return nil; + } + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/{username}"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + + return [self.apiClient requestWithPath: resourcePath + method: @"DELETE" + 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) { + if(handler) { + handler(error); + } + } + ]; +} + +/// +/// Get user by user name +/// +/// @param username The name that needs to be fetched. Use user1 for testing. +/// +/// @returns SWGUser* +/// +-(NSNumber*) getUserByNameWithUsername: (NSString*) username + completionHandler: (void (^)(SWGUser* output, NSError* error)) handler { + // verify the required parameter 'username' is set + if (username == nil) { + NSParameterAssert(username); + if(handler) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : [NSString stringWithFormat:NSLocalizedString(@"Missing required parameter '%@'", nil),@"username"] }; + NSError* error = [NSError errorWithDomain:kSWGUserApiErrorDomain code:kSWGUserApiMissingParamErrorCode userInfo:userInfo]; + handler(nil, error); + } + return nil; + } + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/{username}"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + 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: @"SWGUser*" + completionBlock: ^(id data, NSError *error) { + if(handler) { + handler((SWGUser*)data, error); + } + } + ]; +} + +/// +/// Logs user into the system +/// +/// @param username The user name for login (optional) +/// +/// @param password The password for login in clear text (optional) +/// +/// @returns NSString* +/// +-(NSNumber*) loginUserWithUsername: (NSString*) username + password: (NSString*) password + completionHandler: (void (^)(NSString* output, NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/login"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + queryParams[@"username"] = username; + } + if (password != nil) { + queryParams[@"password"] = password; + } + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + 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) { + if(handler) { + handler((NSString*)data, error); + } + } + ]; +} + +/// +/// Logs out current logged in user session +/// +/// @returns void +/// +-(NSNumber*) logoutUserWithCompletionHandler: + (void (^)(NSError* error)) handler { + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/logout"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + 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: nil + completionBlock: ^(id data, NSError *error) { + if(handler) { + handler(error); + } + } + ]; +} + +/// +/// Updated user +/// This can only be done by the logged in user. +/// @param username name that need to be deleted +/// +/// @param body Updated user object (optional) +/// +/// @returns void +/// +-(NSNumber*) updateUserWithUsername: (NSString*) username + body: (SWGUser*) body + completionHandler: (void (^)(NSError* error)) handler { + // verify the required parameter 'username' is set + if (username == nil) { + NSParameterAssert(username); + if(handler) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : [NSString stringWithFormat:NSLocalizedString(@"Missing required parameter '%@'", nil),@"username"] }; + NSError* error = [NSError errorWithDomain:kSWGUserApiErrorDomain code:kSWGUserApiMissingParamErrorCode userInfo:userInfo]; + handler(error); + } + return nil; + } + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/{username}"]; + + // remove format in URL if needed + [resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; + [headerParams addEntriesFromDictionary:self.defaultHeaders]; + // HTTP header `Accept` + NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if(acceptHeader.length > 0) { + headerParams[@"Accept"] = acceptHeader; + } + + // response content type + NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; + + // request content type + NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + bodyParam = body; + + return [self.apiClient requestWithPath: resourcePath + method: @"PUT" + 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) { + if(handler) { + handler(error); + } + } + ]; +} + + + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/JSONValueTransformer+ISO8601.h b/samples/client/petstore/objc/default/SwaggerClient/Core/JSONValueTransformer+ISO8601.h new file mode 100644 index 00000000000..dd8e721b3b9 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/JSONValueTransformer+ISO8601.h @@ -0,0 +1,31 @@ +#import +#import +#import + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +@interface JSONValueTransformer (ISO8601) + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/JSONValueTransformer+ISO8601.m b/samples/client/petstore/objc/default/SwaggerClient/Core/JSONValueTransformer+ISO8601.m new file mode 100644 index 00000000000..cec8bdeea27 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/JSONValueTransformer+ISO8601.m @@ -0,0 +1,10 @@ +#import "JSONValueTransformer+ISO8601.h" + +@implementation JSONValueTransformer (ISO8601) + +- (NSDate *) NSDateFromNSString:(NSString *)string +{ + return [NSDate dateWithISO8601String:string]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGApi.h b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGApi.h new file mode 100644 index 00000000000..93b564be3d1 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGApi.h @@ -0,0 +1,42 @@ +#import +#import "SWGObject.h" +#import "SWGApiClient.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +@protocol SWGApi + +@property(nonatomic, assign) SWGApiClient *apiClient; + +-(id) initWithApiClient:(SWGApiClient *)apiClient; + +-(void) addHeader:(NSString*)value forKey:(NSString*)key DEPRECATED_MSG_ATTRIBUTE("setDefaultHeaderValue:forKey:"); + +-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key; +-(NSString*) defaultHeaderForKey:(NSString*)key; + +-(NSUInteger) requestQueueSize; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGApiClient.h b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGApiClient.h new file mode 100644 index 00000000000..2ec5c9b0fcc --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGApiClient.h @@ -0,0 +1,210 @@ +#import +#import +#import +#import "SWGJSONResponseSerializer.h" +#import "SWGJSONRequestSerializer.h" +#import "SWGQueryParamCollection.h" +#import "SWGConfiguration.h" +#import "SWGResponseDeserializer.h" +#import "SWGSanitizer.h" +#import "SWGLogger.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#import "SWGCategory.h" +#import "SWGOrder.h" +#import "SWGPet.h" +#import "SWGTag.h" +#import "SWGUser.h" + + + +@class SWGConfiguration; + +/** + * A key for `NSError` user info dictionaries. + * + * The corresponding value is the parsed response body for an HTTP error. + */ +extern NSString *const SWGResponseObjectErrorKey; + +@interface SWGApiClient : AFHTTPSessionManager + +@property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy; +@property(nonatomic, assign) NSTimeInterval timeoutInterval; +@property(nonatomic, readonly) NSOperationQueue* queue; + +/// In order to ensure the HTTPResponseHeaders are correct, it is recommended to initialize one SWGApiClient instance per thread. +@property(nonatomic, readonly) NSDictionary* HTTPResponseHeaders; + +@property(nonatomic, strong) id responseDeserializer; + +@property(nonatomic, strong) id sanitizer; +/** + * Clears Cache + */ ++(void)clearCache; + +/** + * Turns on cache + * + * @param enabled If the cached is enable, must be `YES` or `NO` + */ ++(void)setCacheEnabled:(BOOL) enabled; + +/** + * Gets the request queue size + * + * @return The size of `queuedRequests` static variable. + */ ++(NSUInteger)requestQueueSize; + +/** + * Sets the client unreachable + * + * @param state off line state, must be `YES` or `NO` + */ ++(void) setOfflineState:(BOOL) state; + +/** + * Gets if the client is unreachable + * + * @return The client offline state + */ ++(BOOL) getOfflineState; + +/** + * Sets the client reachability, this may be overridden by the reachability manager if reachability changes + * + * @param The client reachability. + */ ++(void) setReachabilityStatus:(AFNetworkReachabilityStatus) status; + +/** + * Gets the client reachability + * + * @return The client reachability. + */ ++(AFNetworkReachabilityStatus) getReachabilityStatus; + +/** + * Gets the next request id + * + * @return The next executed request id. + */ ++(NSNumber*) nextRequestId; + +/** + * Generates request id and add it to the queue + * + * @return The next executed request id. + */ ++(NSNumber*) queueRequest; + +/** + * Removes request id from the queue + * + * @param requestId The request which will be removed. + */ ++(void) cancelRequest:(NSNumber*)requestId; + +/** + * Customizes the behavior when the reachability changed + * + * @param changeBlock The block will be executed when the reachability changed. + */ ++(void) setReachabilityChangeBlock:(void(^)(int))changeBlock; + +/** + * Sets the api client reachability strategy + */ +- (void)configureCacheReachibility; + +/** + * Sets header for request + * + * @param value The header value + * @param forKey The header key + */ +-(void)setHeaderValue:(NSString*) value + forKey:(NSString*) forKey; + +/** + * Updates header parameters and query parameters for authentication + * + * @param headers The header parameter will be udpated, passed by pointer to pointer. + * @param querys The query parameters will be updated, passed by pointer to pointer. + * @param authSettings The authentication names NSArray. + */ +- (void) updateHeaderParams:(NSDictionary **)headers + queryParams:(NSDictionary **)querys + WithAuthSettings:(NSArray *)authSettings; + +/** + * Performs request + * + * @param path Request url. + * @param method Request method. + * @param pathParams Request path parameters. + * @param queryParams Request query parameters. + * @param body Request body. + * @param headerParams Request header parameters. + * @param authSettings Request authentication names. + * @param requestContentType Request content-type. + * @param responseContentType Response content-type. + * @param completionBlock The block will be executed when the request completed. + * + * @return The request id. + */ +-(NSNumber*) requestWithPath:(NSString*) path + method:(NSString*) method + pathParams:(NSDictionary *) pathParams + queryParams:(NSDictionary*) queryParams + formParams:(NSDictionary *) formParams + files:(NSDictionary *) files + body:(id) body + headerParams:(NSDictionary*) headerParams + authSettings:(NSArray *) authSettings + requestContentType:(NSString*) requestContentType + responseContentType:(NSString*) responseContentType + responseType:(NSString *) responseType + completionBlock:(void (^)(id, NSError *))completionBlock; + +/** + * Custom security policy + * + * @return AFSecurityPolicy + */ +- (AFSecurityPolicy *) customSecurityPolicy; + +/** + * SWGConfiguration return sharedConfig + * + * @return SWGConfiguration + */ +- (SWGConfiguration*) configuration; + + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGApiClient.m b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGApiClient.m new file mode 100644 index 00000000000..f004200b2eb --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGApiClient.m @@ -0,0 +1,504 @@ +#import "SWGApiClient.h" + +NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject"; + +static NSUInteger requestId = 0; +static bool offlineState = false; +static NSMutableSet * queuedRequests = nil; +static bool cacheEnabled = false; +static AFNetworkReachabilityStatus reachabilityStatus = AFNetworkReachabilityStatusNotReachable; +static void (^reachabilityChangeBlock)(int); + + +static NSDictionary * SWG__headerFieldsForResponse(NSURLResponse *response) { + if(![response isKindOfClass:[NSHTTPURLResponse class]]) { + return nil; + } + return ((NSHTTPURLResponse*)response).allHeaderFields; +} + +static NSString * SWG__fileNameForResponse(NSURLResponse *response) { + NSDictionary * headers = SWG__headerFieldsForResponse(response); + if(!headers[@"Content-Disposition"]) { + return [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]]; + } + NSString *pattern = @"filename=['\"]?([^'\"\\s]+)['\"]?"; + NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:pattern + options:NSRegularExpressionCaseInsensitive + error:nil]; + NSString *contentDispositionHeader = headers[@"Content-Disposition"]; + NSTextCheckingResult *match = [regexp firstMatchInString:contentDispositionHeader + options:0 + range:NSMakeRange(0, [contentDispositionHeader length])]; + return [contentDispositionHeader substringWithRange:[match rangeAtIndex:1]]; +} + + +@interface SWGApiClient () + +@property (nonatomic, strong) NSDictionary* HTTPResponseHeaders; + +@end + +@implementation SWGApiClient + +- (instancetype)init { + NSString *baseUrl = [[SWGConfiguration sharedConfig] host]; + return [self initWithBaseURL:[NSURL URLWithString:baseUrl]]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + self = [super initWithBaseURL:url]; + if (self) { + self.timeoutInterval = 60; + self.requestSerializer = [AFJSONRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + self.securityPolicy = [self customSecurityPolicy]; + self.responseDeserializer = [[SWGResponseDeserializer alloc] init]; + self.sanitizer = [[SWGSanitizer alloc] init]; + // configure reachability + [self configureCacheReachibility]; + } + return self; +} + ++ (void)initialize { + if (self == [SWGApiClient class]) { + queuedRequests = [[NSMutableSet alloc] init]; + // initialize URL cache + [self configureCacheWithMemoryAndDiskCapacity:4*1024*1024 diskSize:32*1024*1024]; + } +} + +#pragma mark - Setter Methods + ++ (void) setOfflineState:(BOOL) state { + offlineState = state; +} + ++ (void) setCacheEnabled:(BOOL)enabled { + cacheEnabled = enabled; +} + ++(void) setReachabilityStatus:(AFNetworkReachabilityStatus)status { + reachabilityStatus = status; +} + +- (void)setHeaderValue:(NSString*) value forKey:(NSString*) forKey { + [self.requestSerializer setValue:value forHTTPHeaderField:forKey]; +} + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + [super setRequestSerializer:requestSerializer]; + requestSerializer.timeoutInterval = self.timeoutInterval; +} + +#pragma mark - Cache Methods + ++(void)clearCache { + [[NSURLCache sharedURLCache] removeAllCachedResponses]; +} + ++(void)configureCacheWithMemoryAndDiskCapacity: (unsigned long) memorySize + diskSize: (unsigned long) diskSize { + NSAssert(memorySize > 0, @"invalid in-memory cache size"); + NSAssert(diskSize >= 0, @"invalid disk cache size"); + + NSURLCache *cache = + [[NSURLCache alloc] + initWithMemoryCapacity:memorySize + diskCapacity:diskSize + diskPath:@"swagger_url_cache"]; + + [NSURLCache setSharedURLCache:cache]; +} + +#pragma mark - Request Methods + ++(NSUInteger)requestQueueSize { + return [queuedRequests count]; +} + ++(NSNumber*) nextRequestId { + @synchronized(self) { + return @(++requestId); + } +} + ++(NSNumber*) queueRequest { + NSNumber* requestId = [[self class] nextRequestId]; + SWGDebugLog(@"added %@ to request queue", requestId); + [queuedRequests addObject:requestId]; + return requestId; +} + ++(void) cancelRequest:(NSNumber*)requestId { + [queuedRequests removeObject:requestId]; +} + +-(Boolean) executeRequestWithId:(NSNumber*) requestId { + NSSet* matchingItems = [queuedRequests objectsPassingTest:^BOOL(id obj, BOOL *stop) { + return [obj intValue] == [requestId intValue]; + }]; + + if (matchingItems.count == 1) { + SWGDebugLog(@"removed request id %@", requestId); + [queuedRequests removeObject:requestId]; + return YES; + } else { + return NO; + } +} + +#pragma mark - Reachability Methods + ++(AFNetworkReachabilityStatus) getReachabilityStatus { + return reachabilityStatus; +} + ++(BOOL) getOfflineState { + return offlineState; +} + ++(void) setReachabilityChangeBlock:(void(^)(int))changeBlock { + reachabilityChangeBlock = changeBlock; +} + +- (void) configureCacheReachibility { + [self.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + reachabilityStatus = status; + SWGDebugLog(@"reachability changed to %@",AFStringFromNetworkReachabilityStatus(status)); + [SWGApiClient setOfflineState:status == AFNetworkReachabilityStatusUnknown || status == AFNetworkReachabilityStatusNotReachable]; + + // call the reachability block, if configured + if (reachabilityChangeBlock != nil) { + reachabilityChangeBlock(status); + } + }]; + + [self.reachabilityManager startMonitoring]; +} + +#pragma mark - Operation Methods + +- (void) operationWithCompletionBlock: (NSURLRequest *)request + requestId: (NSNumber *) requestId + completionBlock: (void (^)(id, NSError *))completionBlock { + __weak __typeof(self)weakSelf = self; + NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if (![strongSelf executeRequestWithId:requestId]) { + return; + } + SWGDebugLogResponse(response, responseObject,request,error); + strongSelf.HTTPResponseHeaders = SWG__headerFieldsForResponse(response); + if(!error) { + completionBlock(responseObject, nil); + return; + } + NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; + if (responseObject) { + // Add in the (parsed) response body. + userInfo[SWGResponseObjectErrorKey] = responseObject; + } + NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; + completionBlock(nil, augmentedError); + }]; + [op resume]; +} + +- (void) downloadOperationWithCompletionBlock: (NSURLRequest *)request + requestId: (NSNumber *) requestId + completionBlock: (void (^)(id, NSError *))completionBlock { + __weak __typeof(self)weakSelf = self; + NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if (![strongSelf executeRequestWithId:requestId]) { + return; + } + strongSelf.HTTPResponseHeaders = SWG__headerFieldsForResponse(response); + SWGDebugLogResponse(response, responseObject,request,error); + if(error) { + NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; + if (responseObject) { + userInfo[SWGResponseObjectErrorKey] = responseObject; + } + NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; + completionBlock(nil, augmentedError); + } + NSString *directory = [self configuration].tempFolderPath ?: NSTemporaryDirectory(); + NSString * filename = SWG__fileNameForResponse(response); + + NSString *filepath = [directory stringByAppendingPathComponent:filename]; + NSURL *file = [NSURL fileURLWithPath:filepath]; + + [responseObject writeToURL:file atomically:YES]; + + completionBlock(file, nil); + }]; + [op resume]; +} + +#pragma mark - Perform Request Methods + +-(NSNumber*) requestWithPath: (NSString*) path + method: (NSString*) method + pathParams: (NSDictionary *) pathParams + queryParams: (NSDictionary*) queryParams + formParams: (NSDictionary *) formParams + files: (NSDictionary *) files + body: (id) body + headerParams: (NSDictionary*) headerParams + authSettings: (NSArray *) authSettings + requestContentType: (NSString*) requestContentType + responseContentType: (NSString*) responseContentType + responseType: (NSString *) responseType + completionBlock: (void (^)(id, NSError *))completionBlock { + // setting request serializer + if ([requestContentType isEqualToString:@"application/json"]) { + self.requestSerializer = [SWGJSONRequestSerializer serializer]; + } + else if ([requestContentType isEqualToString:@"application/x-www-form-urlencoded"]) { + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + } + else if ([requestContentType isEqualToString:@"multipart/form-data"]) { + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + } + else { + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + NSAssert(NO, @"Unsupported request type %@", requestContentType); + } + + // setting response serializer + if ([responseContentType isEqualToString:@"application/json"]) { + self.responseSerializer = [SWGJSONResponseSerializer serializer]; + } else { + self.responseSerializer = [AFHTTPResponseSerializer serializer]; + } + + // sanitize parameters + pathParams = [self.sanitizer sanitizeForSerialization:pathParams]; + queryParams = [self.sanitizer sanitizeForSerialization:queryParams]; + headerParams = [self.sanitizer sanitizeForSerialization:headerParams]; + formParams = [self.sanitizer sanitizeForSerialization:formParams]; + if(![body isKindOfClass:[NSData class]]) { + body = [self.sanitizer sanitizeForSerialization:body]; + } + + // auth setting + [self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings]; + + NSMutableString *resourcePath = [NSMutableString stringWithString:path]; + [pathParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + NSString * safeString = ([obj isKindOfClass:[NSString class]]) ? obj : [NSString stringWithFormat:@"%@", obj]; + safeString = SWGPercentEscapedStringFromString(safeString); + [resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"{%@}", key]] withString:safeString]; + }]; + + NSMutableURLRequest * request = nil; + + NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams]; + if ([pathWithQueryParams hasPrefix:@"/"]) { + pathWithQueryParams = [pathWithQueryParams substringFromIndex:1]; + } + + NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString]; + if (files.count > 0) { + __weak __typeof(self)weakSelf = self; + request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" + URLString:urlString + parameters:nil + constructingBodyWithBlock:^(id formData) { + [formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + NSString *objString = [weakSelf.sanitizer parameterToString:obj]; + NSData *data = [objString dataUsingEncoding:NSUTF8StringEncoding]; + [formData appendPartWithFormData:data name:key]; + }]; + [files enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + NSURL *filePath = (NSURL *)obj; + [formData appendPartWithFileURL:filePath name:key error:nil]; + }]; + } error:nil]; + } + else { + if (formParams) { + request = [self.requestSerializer requestWithMethod:method + URLString:urlString + parameters:formParams + error:nil]; + } + if (body) { + request = [self.requestSerializer requestWithMethod:method + URLString:urlString + parameters:body + error:nil]; + } + } + + // request cache + BOOL hasHeaderParams = [headerParams count] > 0; + if (offlineState) { + SWGDebugLog(@"%@ cache forced", resourcePath); + [request setCachePolicy:NSURLRequestReturnCacheDataDontLoad]; + } + else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) { + SWGDebugLog(@"%@ cache enabled", resourcePath); + [request setCachePolicy:NSURLRequestUseProtocolCachePolicy]; + } + else { + SWGDebugLog(@"%@ cache disabled", resourcePath); + [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; + } + + if (hasHeaderParams){ + for(NSString * key in [headerParams keyEnumerator]){ + [request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key]; + } + } + [self.requestSerializer setValue:responseContentType forHTTPHeaderField:@"Accept"]; + + [self postProcessRequest:request]; + + NSNumber* requestId = [SWGApiClient queueRequest]; + if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) { + [self downloadOperationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { + completionBlock(data, error); + }]; + } + else { + [self operationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { + NSError * serializationError; + id response = [self.responseDeserializer deserialize:data class:responseType error:&serializationError]; + if(!response && !error){ + error = serializationError; + } + completionBlock(response, error); + }]; + } + return requestId; +} + +//Added for easier override to modify request +-(void)postProcessRequest:(NSMutableURLRequest *)request { + // Always disable cookies! + [request setHTTPShouldHandleCookies:NO]; +} + +#pragma mark - + +- (NSString*) pathWithQueryParamsToString:(NSString*) path + queryParams:(NSDictionary*) queryParams { + if(queryParams.count == 0) { + return path; + } + NSString * separator = nil; + NSUInteger counter = 0; + + NSMutableString * requestUrl = [NSMutableString stringWithFormat:@"%@", path]; + + NSDictionary *separatorStyles = @{@"csv" : @",", + @"tsv" : @"\t", + @"pipes": @"|" + }; + for(NSString * key in [queryParams keyEnumerator]){ + if (counter == 0) { + separator = @"?"; + } else { + separator = @"&"; + } + id queryParam = [queryParams valueForKey:key]; + if(!queryParam) { + continue; + } + NSString *safeKey = SWGPercentEscapedStringFromString(key); + if ([queryParam isKindOfClass:[NSString class]]){ + [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, SWGPercentEscapedStringFromString(queryParam)]]; + + } else if ([queryParam isKindOfClass:[SWGQueryParamCollection class]]){ + SWGQueryParamCollection * coll = (SWGQueryParamCollection*) queryParam; + NSArray* values = [coll values]; + NSString* format = [coll format]; + + if([format isEqualToString:@"multi"]) { + for(id obj in values) { + if (counter > 0) { + separator = @"&"; + } + NSString * safeValue = SWGPercentEscapedStringFromString([NSString stringWithFormat:@"%@",obj]); + [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, safeValue]]; + counter += 1; + } + continue; + } + NSString * separatorStyle = separatorStyles[format]; + NSString * safeValue = SWGPercentEscapedStringFromString([values componentsJoinedByString:separatorStyle]); + [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, safeValue]]; + } else { + NSString * safeValue = SWGPercentEscapedStringFromString([NSString stringWithFormat:@"%@",queryParam]); + [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, safeKey, safeValue]]; + } + counter += 1; + } + return requestUrl; +} + +/** + * Update header and query params based on authentication settings + */ +- (void) updateHeaderParams:(NSDictionary *__autoreleasing *)headers + queryParams:(NSDictionary *__autoreleasing *)querys + WithAuthSettings:(NSArray *)authSettings { + + if ([authSettings count] == 0) { + return; + } + + NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers]; + NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys]; + + NSDictionary* configurationAuthSettings = [[self configuration] authSettings]; + for (NSString *auth in authSettings) { + NSDictionary *authSetting = configurationAuthSettings[auth]; + if(!authSetting) { // auth setting is set only if the key is non-empty + continue; + } + NSString *type = authSetting[@"in"]; + NSString *key = authSetting[@"key"]; + NSString *value = authSetting[@"value"]; + if ([type isEqualToString:@"header"] && [key length] > 0 ) { + headersWithAuth[key] = value; + } else if ([type isEqualToString:@"query"] && [key length] != 0) { + querysWithAuth[key] = value; + } + } + + *headers = [NSDictionary dictionaryWithDictionary:headersWithAuth]; + *querys = [NSDictionary dictionaryWithDictionary:querysWithAuth]; +} + +- (AFSecurityPolicy *) customSecurityPolicy { + AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone]; + + SWGConfiguration *config = [self configuration]; + + if (config.sslCaCert) { + NSData *certData = [NSData dataWithContentsOfFile:config.sslCaCert]; + [securityPolicy setPinnedCertificates:@[certData]]; + } + + if (config.verifySSL) { + [securityPolicy setAllowInvalidCertificates:NO]; + } + else { + [securityPolicy setAllowInvalidCertificates:YES]; + [securityPolicy setValidatesDomainName:NO]; + } + + return securityPolicy; +} + +- (SWGConfiguration*) configuration { + return [SWGConfiguration sharedConfig]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGConfiguration.h b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGConfiguration.h new file mode 100644 index 00000000000..b6c37405ca2 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGConfiguration.h @@ -0,0 +1,182 @@ +#import +#import "SWGApiClient.h" +#import "SWGLogger.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +@class SWGApiClient; + +@interface SWGConfiguration : NSObject + +/** + * Default api logger + */ +@property (nonatomic, strong) SWGLogger * logger; + +/** + * Default api client + */ +@property (nonatomic) SWGApiClient *apiClient; + +/** + * Default base url + */ +@property (nonatomic) NSString *host; + +/** + * Api key values for Api Key type Authentication + * + * To add or remove api key, use `setApiKey:forApiKeyIdentifier:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *apiKey; + +/** + * Api key prefix values to be prepend to the respective api key + * + * To add or remove prefix, use `setApiKeyPrefix:forApiKeyPrefixIdentifier:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix; + +/** + * Username for HTTP Basic Authentication + */ + @property (nonatomic) NSString *username; + +/** + * Password for HTTP Basic Authentication + */ +@property (nonatomic) NSString *password; + +/** + * Access token for OAuth + */ +@property (nonatomic) NSString *accessToken; + +/** + * Temp folder for file download + */ +@property (nonatomic) NSString *tempFolderPath; + +/** + * Debug switch, default false + */ +@property (nonatomic) BOOL debug; + +/** + * Gets configuration singleton instance + */ ++ (instancetype) sharedConfig; + +/** + * SSL/TLS verification + * Set this to NO to skip verifying SSL certificate when calling API from https server + */ +@property (nonatomic) BOOL verifySSL; + +/** + * SSL/TLS verification + * Set this to customize the certificate file to verify the peer + */ +@property (nonatomic) NSString *sslCaCert; + +/** + * Sets API key + * + * To remove a apiKey for an identifier, just set the apiKey to nil. + * + * @param apiKey API key or token. + * @param identifier API key identifier (authentication schema). + * + */ +- (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString*)identifier; + +/** + * Removes api key + * + * @param identifier API key identifier. + */ +- (void) removeApiKey:(NSString *)identifier; + +/** + * Sets the prefix for API key + * + * @param apiKeyPrefix API key prefix. + * @param identifier API key identifier. + */ +- (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier; + +/** + * Removes api key prefix + * + * @param identifier API key identifier. + */ +- (void) removeApiKeyPrefix:(NSString *)identifier; + +/** + * Gets API key (with prefix if set) + */ +- (NSString *) getApiKeyWithPrefix:(NSString *) key; + +/** + * Gets Basic Auth token + */ +- (NSString *) getBasicAuthToken; + +/** + * Gets OAuth access token + */ +- (NSString *) getAccessToken; + +/** + * Gets Authentication Settings + */ +- (NSDictionary *) authSettings; + +/** +* Default headers for all services +*/ +@property (readonly, nonatomic, strong) NSDictionary *defaultHeaders; + +/** +* Removes header from defaultHeaders +* +* @param Header name. +*/ +-(void) removeDefaultHeaderForKey:(NSString*)key; + +/** +* Sets the header for key +* +* @param value Value for header name +* @param key Header name +*/ +-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key; + +/** +* @param Header key name. +*/ +-(NSString*) defaultHeaderForKey:(NSString*)key; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGConfiguration.m b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGConfiguration.m new file mode 100644 index 00000000000..24172638bba --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGConfiguration.m @@ -0,0 +1,160 @@ +#import "SWGConfiguration.h" + +@interface SWGConfiguration () + +@property (nonatomic, strong) NSMutableDictionary *mutableDefaultHeaders; +@property (nonatomic, strong) NSMutableDictionary *mutableApiKey; +@property (nonatomic, strong) NSMutableDictionary *mutableApiKeyPrefix; + +@end + +@implementation SWGConfiguration + +#pragma mark - Singleton Methods + ++ (instancetype) sharedConfig { + static SWGConfiguration *shardConfig = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + shardConfig = [[self alloc] init]; + }); + return shardConfig; +} + +#pragma mark - Initialize Methods + +- (instancetype) init { + self = [super init]; + if (self) { + self.apiClient = nil; + self.host = @"http://petstore.swagger.io/v2"; + self.username = @""; + self.password = @""; + self.accessToken= @""; + self.verifySSL = YES; + self.mutableApiKey = [NSMutableDictionary dictionary]; + self.mutableApiKeyPrefix = [NSMutableDictionary dictionary]; + self.mutableDefaultHeaders = [NSMutableDictionary dictionary]; + self.mutableDefaultHeaders[@"User-Agent"] = [NSString stringWithFormat:@"Swagger-Codegen/1.0.0/objc (%@; iOS %@; Scale/%0.2f)",[[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; + self.logger = [SWGLogger sharedLogger]; + } + return self; +} + +#pragma mark - Instance Methods + +- (NSString *) getApiKeyWithPrefix:(NSString *)key { + NSString *prefix = self.apiKeyPrefix[key]; + NSString *apiKey = self.apiKey[key]; + if (prefix && apiKey != (id)[NSNull null] && apiKey.length > 0) { // both api key prefix and api key are set + return [NSString stringWithFormat:@"%@ %@", prefix, apiKey]; + } + else if (apiKey != (id)[NSNull null] && apiKey.length > 0) { // only api key, no api key prefix + return [NSString stringWithFormat:@"%@", self.apiKey[key]]; + } + else { // return empty string if nothing is set + return @""; + } +} + +- (NSString *) getBasicAuthToken { + // return empty string if username and password are empty + if (self.username.length == 0 && self.password.length == 0){ + return @""; + } + + NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password]; + NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding]; + basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]]; + + return basicAuthCredentials; +} + +- (NSString *) getAccessToken { + if (self.accessToken.length == 0) { // token not set, return empty string + return @""; + } else { + return [NSString stringWithFormat:@"Bearer %@", self.accessToken]; + } +} + +#pragma mark - Setter Methods + +- (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString *)identifier { + [self.mutableApiKey setValue:apiKey forKey:identifier]; +} + +- (void) removeApiKey:(NSString *)identifier { + [self.mutableApiKey removeObjectForKey:identifier]; +} + +- (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier { + [self.mutableApiKeyPrefix setValue:prefix forKey:identifier]; +} + +- (void) removeApiKeyPrefix:(NSString *)identifier { + [self.mutableApiKeyPrefix removeObjectForKey:identifier]; +} + +#pragma mark - Getter Methods + +- (NSDictionary *) apiKey { + return [NSDictionary dictionaryWithDictionary:self.mutableApiKey]; +} + +- (NSDictionary *) apiKeyPrefix { + return [NSDictionary dictionaryWithDictionary:self.mutableApiKeyPrefix]; +} + +#pragma mark - + +- (NSDictionary *) authSettings { + return @{ + @"petstore_auth": + @{ + @"type": @"oauth", + @"in": @"header", + @"key": @"Authorization", + @"value": [self getAccessToken] + }, + @"api_key": + @{ + @"type": @"api_key", + @"in": @"header", + @"key": @"api_key", + @"value": [self getApiKeyWithPrefix:@"api_key"] + }, + }; +} + +-(BOOL)debug { + return self.logger.isEnabled; +} + +-(void)setDebug:(BOOL)debug { + self.logger.enabled = debug; +} + + + +- (void)setDefaultHeaderValue:(NSString *)value forKey:(NSString *)key { + if(!value) { + [self.mutableDefaultHeaders removeObjectForKey:key]; + return; + } + self.mutableDefaultHeaders[key] = value; +} + +-(void) removeDefaultHeaderForKey:(NSString*)key { + [self.mutableDefaultHeaders removeObjectForKey:key]; +} + +- (NSString *)defaultHeaderForKey:(NSString *)key { + return self.mutableDefaultHeaders[key]; +} + +- (NSDictionary *)defaultHeaders { + return [self.mutableDefaultHeaders copy]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONRequestSerializer.h b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONRequestSerializer.h new file mode 100644 index 00000000000..d9c4d4ad060 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONRequestSerializer.h @@ -0,0 +1,29 @@ +#import +#import + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +@interface SWGJSONRequestSerializer : AFJSONRequestSerializer +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONRequestSerializer.m b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONRequestSerializer.m new file mode 100644 index 00000000000..221765e4839 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONRequestSerializer.m @@ -0,0 +1,37 @@ +#import "SWGJSONRequestSerializer.h" + +@implementation SWGJSONRequestSerializer + +/// +/// When customize a request serializer, +/// the serializer must conform the protocol `AFURLRequestSerialization` +/// and implements the protocol method `requestBySerializingRequest:withParameters:error:` +/// +/// @param request The original request. +/// @param parameters The parameters to be encoded. +/// @param error The error that occurred while attempting to encode the request parameters. +/// +/// @return A serialized request. +/// +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + if (!parameters) { + return request; + } + // If the body data which will be serialized isn't NSArray or NSDictionary + // then put the data in the http request body directly. + if ([parameters isKindOfClass:[NSArray class]] || [parameters isKindOfClass:[NSDictionary class]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + if([parameters isKindOfClass:[NSData class]]) { + [mutableRequest setHTTPBody:parameters]; + } else { + [mutableRequest setHTTPBody:[parameters dataUsingEncoding:self.stringEncoding]]; + } + return mutableRequest; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONResponseSerializer.h b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONResponseSerializer.h new file mode 100644 index 00000000000..20535a6b92e --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONResponseSerializer.h @@ -0,0 +1,30 @@ +#import +#import + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +@interface SWGJSONResponseSerializer : AFJSONResponseSerializer + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONResponseSerializer.m b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONResponseSerializer.m new file mode 100644 index 00000000000..73c696d341a --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONResponseSerializer.m @@ -0,0 +1,39 @@ +#import "SWGJSONResponseSerializer.h" + +@implementation SWGJSONResponseSerializer + +/// +/// When customize a response serializer, +/// the serializer must conform the protocol `AFURLResponseSerialization` +/// and implements the protocol method `responseObjectForResponse:error:` +/// +/// @param response The response to be processed. +/// @param data The response data to be decoded. +/// @param error The error that occurred while attempting to decode the response data. +/// +/// @return The object decoded from the specified response data. +/// +- (id) responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error { + NSDictionary *responseJson = [super responseObjectForResponse:response data:data error:error]; + + // if response data is not a valid json, return string of data. + if ([self isParseError:*error]) { + *error = nil; + NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + return responseString; + } + + return responseJson; +} + +-(BOOL)isParseError:(NSError *)error { + return [error.domain isEqualToString:NSCocoaErrorDomain] && error.code == 3840; +} + ++ (instancetype)serializer { + return [self serializerWithReadingOptions:NSJSONReadingAllowFragments]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGLogger.h b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGLogger.h new file mode 100644 index 00000000000..cb4279f182b --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGLogger.h @@ -0,0 +1,72 @@ +#import + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef SWGDebugLogResponse +#define SWGDebugLogResponse(response, responseObject,request, error) [[SWGLogger sharedLogger] logResponse:response responseObject:responseObject request:request error:error]; +#endif + +/** + * Log debug message macro + */ +#ifndef SWGDebugLog +#define SWGDebugLog(format, ...) [[SWGLogger sharedLogger] debugLog:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__] message: format, ##__VA_ARGS__]; +#endif + +@interface SWGLogger : NSObject + ++(instancetype)sharedLogger; + +/** + * Enabled switch, default NO - default set by SWGConfiguration debug property + */ +@property (nonatomic, assign, getter=isEnabled) BOOL enabled; + +/** + * Debug file location, default log in console + */ +@property (nonatomic, strong) NSString *loggingFile; + +/** + * Log file handler, this property is used by sdk internally. + */ +@property (nonatomic, strong, readonly) NSFileHandle *loggingFileHandler; + +/** + * Log debug message + */ +-(void)debugLog:(NSString *)method message:(NSString *)format, ...; + +/** + * Logs request and response + * + * @param response NSURLResponse for the HTTP request. + * @param responseObject response object of the HTTP request. + * @param request The HTTP request. + * @param error The error of the HTTP request. + */ +- (void)logResponse:(NSURLResponse *)response responseObject:(id)responseObject request:(NSURLRequest *)request error:(NSError *)error; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGLogger.m b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGLogger.m new file mode 100644 index 00000000000..322ae9678d7 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGLogger.m @@ -0,0 +1,74 @@ +#import "SWGLogger.h" + +@interface SWGLogger () + +@end + +@implementation SWGLogger + ++ (instancetype) sharedLogger { + static SWGLogger *shardLogger = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + shardLogger = [[self alloc] init]; + }); + return shardLogger; +} + +#pragma mark - Log Methods + +- (void)debugLog:(NSString *)method + message:(NSString *)format, ... { + if (!self.isEnabled) { + return; + } + + NSMutableString *message = [NSMutableString stringWithCapacity:1]; + + if (method) { + [message appendFormat:@"%@: ", method]; + } + + va_list args; + va_start(args, format); + + [message appendString:[[NSString alloc] initWithFormat:format arguments:args]]; + + // If set logging file handler, log into file, + // otherwise log into console. + if (self.loggingFileHandler) { + [self.loggingFileHandler seekToEndOfFile]; + [self.loggingFileHandler writeData:[message dataUsingEncoding:NSUTF8StringEncoding]]; + } else { + NSLog(@"%@", message); + } + + va_end(args); +} + +- (void)logResponse:(NSURLResponse *)response responseObject:(id)responseObject request:(NSURLRequest *)request error:(NSError *)error { + NSString *message = [NSString stringWithFormat:@"\n[DEBUG] HTTP request body \n~BEGIN~\n %@\n~END~\n"\ + "[DEBUG] HTTP response body \n~BEGIN~\n %@\n~END~\n", + [[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding], + responseObject]; + + SWGDebugLog(message); +} + +- (void) setLoggingFile:(NSString *)loggingFile { + if(_loggingFile == loggingFile) { + return; + } + // close old file handler + if ([self.loggingFileHandler isKindOfClass:[NSFileHandle class]]) { + [self.loggingFileHandler closeFile]; + } + _loggingFile = loggingFile; + _loggingFileHandler = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; + if (_loggingFileHandler == nil) { + [[NSFileManager defaultManager] createFileAtPath:_loggingFile contents:nil attributes:nil]; + _loggingFileHandler = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; + } +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGObject.h b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGObject.h new file mode 100644 index 00000000000..be57583b8f6 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGObject.h @@ -0,0 +1,30 @@ +#import +#import + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +@interface SWGObject : JSONModel + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGObject.m b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGObject.m new file mode 100644 index 00000000000..8085c404f7e --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGObject.m @@ -0,0 +1,13 @@ +#import "SWGObject.h" + +@implementation SWGObject + +/** + * Gets the string presentation of the object. + * This method will be called when logging model object using `NSLog`. + */ +- (NSString *)description { + return [[self toDictionary] description]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGQueryParamCollection.h b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGQueryParamCollection.h new file mode 100644 index 00000000000..69a5ab3c133 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGQueryParamCollection.h @@ -0,0 +1,35 @@ +#import + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +@interface SWGQueryParamCollection : NSObject + +@property(nonatomic, readonly) NSArray* values; +@property(nonatomic, readonly) NSString* format; + +- (id) initWithValuesAndFormat: (NSArray*) values + format: (NSString*) format; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGQueryParamCollection.m b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGQueryParamCollection.m new file mode 100644 index 00000000000..83303045185 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGQueryParamCollection.m @@ -0,0 +1,16 @@ +#import "SWGQueryParamCollection.h" + +@implementation SWGQueryParamCollection + +@synthesize values = _values; +@synthesize format = _format; + +- (id) initWithValuesAndFormat: (NSArray*) values + format: (NSString*) format { + _values = values; + _format = format; + + return self; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGResponseDeserializer.h b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGResponseDeserializer.h new file mode 100644 index 00000000000..c0d7b716a01 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGResponseDeserializer.h @@ -0,0 +1,68 @@ +#import + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/** + * A key for deserialization ErrorDomain + */ +extern NSString *const SWGDeserializationErrorDomainKey; + +/** + * Code for deserialization type mismatch error + */ +extern NSInteger const SWGTypeMismatchErrorCode; + +/** + * Code for deserialization empty value error + */ +extern NSInteger const SWGEmptyValueOccurredErrorCode; + +/** + * Error code for unknown response + */ +extern NSInteger const SWGUnknownResponseObjectErrorCode; + +@protocol SWGResponseDeserializer + +/** + * Deserializes the given data to Objective-C object. + * + * @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 *) className error:(NSError**)error; + +@end + +@interface SWGResponseDeserializer : NSObject + +/** + * If an null value occurs in dictionary or array if set to YES whole response will be invalid else will be ignored + * @default NO + */ +@property (nonatomic, assign) BOOL treatNullAsError; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGResponseDeserializer.m b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGResponseDeserializer.m new file mode 100644 index 00000000000..a0efd1d5927 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGResponseDeserializer.m @@ -0,0 +1,231 @@ +#import "SWGResponseDeserializer.h" +#import +#import + +NSString *const SWGDeserializationErrorDomainKey = @"SWGDeserializationErrorDomainKey"; + +NSInteger const SWGTypeMismatchErrorCode = 143553; + +NSInteger const SWGEmptyValueOccurredErrorCode = 143509; + +NSInteger const SWGUnknownResponseObjectErrorCode = 143528; + + +@interface SWGResponseDeserializer () + +@property (nonatomic, strong) NSNumberFormatter* numberFormatter; +@property (nonatomic, strong) NSArray *primitiveTypes; +@property (nonatomic, strong) NSArray *basicReturnTypes; + +@property (nonatomic, strong) NSRegularExpression* arrayOfModelsPatExpression; +@property (nonatomic, strong) NSRegularExpression* arrayOfPrimitivesPatExpression; +@property (nonatomic, strong) NSRegularExpression* dictPatExpression; +@property (nonatomic, strong) NSRegularExpression* dictModelsPatExpression; + +@end + +@implementation SWGResponseDeserializer + +- (instancetype)init { + self = [super init]; + if (self) { + NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; + formatter.numberStyle = NSNumberFormatterDecimalStyle; + _numberFormatter = formatter; + _primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"]; + _basicReturnTypes = @[@"NSObject", @"id", @"NSData"]; + _arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>" + options:NSRegularExpressionCaseInsensitive + error:nil]; + _arrayOfPrimitivesPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray\\* /\\* (.+) \\*/" + options:NSRegularExpressionCaseInsensitive + error:nil]; + _dictPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSDictionary\\* /\\* (.+?), (.+) \\*/" + options:NSRegularExpressionCaseInsensitive + error:nil]; + _dictModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSDictionary\\<(.+?), (.+)*\\>" + options:NSRegularExpressionCaseInsensitive + error:nil]; + } + return self; +} + +#pragma mark - Deserialize methods + +- (id) deserialize:(id) data class:(NSString *) className error:(NSError **) error { + // return nil if data is nil or className is nil + if (!data || !className || [data isKindOfClass:[NSNull class]]) { + return nil; + } + + // remove "*" from className, if ends with "*" + if ([className hasSuffix:@"*"]) { + className = [className substringToIndex:[className length] - 1]; + } + // pure object + if ([self.basicReturnTypes containsObject:className]) { + return data; + } + + // primitives + if ([self.primitiveTypes containsObject:className]) { + return [self deserializePrimitiveValue:data class:className error:error]; + } + + NSTextCheckingResult *match = nil; + NSRange range = NSMakeRange(0, [className length]); + // list of models + match = [self.arrayOfModelsPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]]; + return [self deserializeArrayValue:data innerType:innerType error:error]; + } + + // list of primitives + match = [self.arrayOfPrimitivesPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]]; + return [self deserializeArrayValue:data innerType:innerType error:error]; + } + + // map + match = [self.dictPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]]; + return [self deserializeDictionaryValue:data valueType:valueType error:error]; + } + + match = [self.dictModelsPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]]; + return [self deserializeDictionaryValue:data valueType:valueType error:error]; + } + + // model + Class ModelClass = NSClassFromString(className); + if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) { + return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error]; + } + + if(error) { + *error = [self unknownResponseErrorWithExpectedType:className data:data]; + } + return nil; +} + +- (id) deserializeDictionaryValue:(id) data valueType:(NSString *) valueType error:(NSError**)error { + if(![data isKindOfClass: [NSDictionary class]]) { + if(error) { + *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSDictionary class]) data:data]; + } + return nil; + } + __block NSMutableDictionary *resultDict = [NSMutableDictionary dictionaryWithCapacity:[data count]]; + for (id key in [data allKeys]) { + id obj = [data valueForKey:key]; + id dicObj = [self deserialize:obj class:valueType error:error]; + if(dicObj) { + [resultDict setValue:dicObj forKey:key]; + } else if([obj isKindOfClass:[NSNull class]]) { + if(self.treatNullAsError) { + if (error) { + *error = [self emptyValueOccurredError]; + } + resultDict = nil; + break; + } + } else { + resultDict = nil; + break; + } + } + return resultDict; +} + +- (id) deserializeArrayValue:(id) data innerType:(NSString *) innerType error:(NSError**)error { + if(![data isKindOfClass: [NSArray class]]) { + if(error) { + *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSArray class]) data:data]; + } + return nil; + } + NSMutableArray* resultArray = [NSMutableArray arrayWithCapacity:[data count]]; + for (id obj in data) { + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else if([obj isKindOfClass:[NSNull class]]) { + if(self.treatNullAsError) { + if (error) { + *error = [self emptyValueOccurredError]; + } + resultArray = nil; + break; + } + } else { + resultArray = nil; + break; + } + } + return resultArray; +}; + +- (id) deserializePrimitiveValue:(id) data class:(NSString *) className error:(NSError**)error { + if ([className isEqualToString:@"NSString"]) { + return [NSString stringWithString:data]; + } + else if ([className isEqualToString:@"NSDate"]) { + return [self deserializeDateValue:data error:error]; + } + else if ([className isEqualToString:@"NSNumber"]) { + // NSNumber from NSNumber + if ([data isKindOfClass:[NSNumber class]]) { + return data; + } + else if ([data isKindOfClass:[NSString class]]) { + // NSNumber (NSCFBoolean) from NSString + if ([[data lowercaseString] isEqualToString:@"true"] || [[data lowercaseString] isEqualToString:@"false"]) { + return @([data boolValue]); + // NSNumber from NSString + } else { + NSNumber* formattedValue = [self.numberFormatter numberFromString:data]; + if(!formattedValue && [data length] > 0 && error) { + *error = [self typeMismatchErrorWithExpectedType:className data:data]; + } + return formattedValue; + } + } + } + if(error) { + *error = [self typeMismatchErrorWithExpectedType:className data:data]; + } + return nil; +} + +- (id) deserializeDateValue:(id) data error:(NSError**)error { + NSDate *date =[NSDate dateWithISO8601String:data]; + if(!date && [data length] > 0 && error) { + *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSDate class]) data:data]; + } + return date; +}; + +-(NSError *)typeMismatchErrorWithExpectedType:(NSString *)expected data:(id)data { + NSString * message = [NSString stringWithFormat:NSLocalizedString(@"Received response [%@] is not an object of type %@",nil),data, expected]; + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message}; + return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGTypeMismatchErrorCode userInfo:userInfo]; +} + +-(NSError *)emptyValueOccurredError { + NSString * message = NSLocalizedString(@"Received response contains null value in dictionary or array response",nil); + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message}; + return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGEmptyValueOccurredErrorCode userInfo:userInfo]; +} + +-(NSError *)unknownResponseErrorWithExpectedType:(NSString *)expected data:(id)data { + NSString * message = [NSString stringWithFormat:NSLocalizedString(@"Unknown response expected type %@ [reponse: %@]",nil),expected,data]; + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message}; + return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGUnknownResponseObjectErrorCode userInfo:userInfo]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGSanitizer.h b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGSanitizer.h new file mode 100644 index 00000000000..59699c2bdd5 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGSanitizer.h @@ -0,0 +1,67 @@ +#import + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +extern NSString * SWGPercentEscapedStringFromString(NSString *string); + +@protocol SWGSanitizer + +/** + * Sanitize object for request + * + * @param object The query/path/header/form/body param to be sanitized. + */ +- (id) sanitizeForSerialization:(id) object; + +/** + * Convert parameter to NSString + */ +- (NSString *) parameterToString: (id) param; + +/** + * Detects Accept header from accepts NSArray + * + * @param accepts NSArray of header + * + * @return The Accept header + */ +-(NSString *) selectHeaderAccept:(NSArray *)accepts; + +/** + * Detects Content-Type header from contentTypes NSArray + * + * @param contentTypes NSArray of header + * + * @return The Content-Type header + */ +-(NSString *) selectHeaderContentType:(NSArray *)contentTypes; + +@end + +@interface SWGSanitizer : NSObject + + + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Core/SWGSanitizer.m b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGSanitizer.m new file mode 100644 index 00000000000..a74f72afbe3 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Core/SWGSanitizer.m @@ -0,0 +1,168 @@ +#import "SWGSanitizer.h" +#import "SWGObject.h" +#import "SWGQueryParamCollection.h" +#import + +NSString * SWGPercentEscapedStringFromString(NSString *string) { + static NSString * const kSWGCharactersGeneralDelimitersToEncode = @":#[]@"; + static NSString * const kSWGCharactersSubDelimitersToEncode = @"!$&'()*+,;="; + + NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy]; + [allowedCharacterSet removeCharactersInString:[kSWGCharactersGeneralDelimitersToEncode stringByAppendingString:kSWGCharactersSubDelimitersToEncode]]; + + static NSUInteger const batchSize = 50; + + NSUInteger index = 0; + NSMutableString *escaped = @"".mutableCopy; + + while (index < string.length) { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wgnu" + NSUInteger length = MIN(string.length - index, batchSize); + #pragma GCC diagnostic pop + NSRange range = NSMakeRange(index, length); + + // To avoid breaking up character sequences such as 👴🏻👮🏽 + range = [string rangeOfComposedCharacterSequencesForRange:range]; + + NSString *substring = [string substringWithRange:range]; + NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + [escaped appendString:encoded]; + + index += range.length; + } + + return escaped; +} + +@interface SWGSanitizer () + +@property (nonatomic, strong) NSRegularExpression* jsonHeaderTypeExpression; + +@end + +@implementation SWGSanitizer + +static NSString * kApplicationJSONType = @"application/json"; + +-(instancetype)init { + self = [super init]; + if ( !self ) { + return nil; + } + _jsonHeaderTypeExpression = [NSRegularExpression regularExpressionWithPattern:@"(.*)application(.*)json(.*)" options:NSRegularExpressionCaseInsensitive error:nil]; + return self; +} + + +- (id) sanitizeForSerialization:(id) object { + if (object == nil) { + return nil; + } + else if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]] || [object isKindOfClass:[SWGQueryParamCollection class]]) { + return object; + } + else if ([object isKindOfClass:[NSDate class]]) { + return [self dateParameterToString:object]; + } + else if ([object isKindOfClass:[NSArray class]]) { + NSArray *objectArray = object; + NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[objectArray count]]; + [object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + id sanitizedObj = [self sanitizeForSerialization:obj]; + if (sanitizedObj) { + [sanitizedObjs addObject:sanitizedObj]; + } + }]; + return sanitizedObjs; + } + else if ([object isKindOfClass:[NSDictionary class]]) { + NSDictionary *objectDict = object; + NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[objectDict count]]; + [object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + id sanitizedObj = [self sanitizeForSerialization:obj]; + if (sanitizedObj) { + sanitizedObjs[key] = sanitizedObj; + } + }]; + return sanitizedObjs; + } + else if ([object isKindOfClass:[SWGObject class]]) { + return [object toDictionary]; + } + else { + NSException *e = [NSException + exceptionWithName:@"InvalidObjectArgumentException" + reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", object] + userInfo:nil]; + @throw e; + } +} + +- (NSString *) parameterToString:(id)param { + if ([param isKindOfClass:[NSString class]]) { + return param; + } + else if ([param isKindOfClass:[NSNumber class]]) { + return [param stringValue]; + } + else if ([param isKindOfClass:[NSDate class]]) { + return [self dateParameterToString:param]; + } + else if ([param isKindOfClass:[NSArray class]]) { + NSMutableArray *mutableParam = [NSMutableArray array]; + [param enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [mutableParam addObject:[self parameterToString:obj]]; + }]; + return [mutableParam componentsJoinedByString:@","]; + } + else { + NSException *e = [NSException + exceptionWithName:@"InvalidObjectArgumentException" + reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", param] + userInfo:nil]; + @throw e; + } +} + +- (NSString *)dateParameterToString:(id)param { + return [param ISO8601String]; +} + +#pragma mark - Utility Methods + +/* + * Detect `Accept` from accepts + */ +- (NSString *) selectHeaderAccept:(NSArray *)accepts { + if (accepts.count == 0) { + return @""; + } + NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]]; + for (NSString *string in accepts) { + if ([self.jsonHeaderTypeExpression matchesInString:string options:0 range:NSMakeRange(0, [string length])].count > 0) { + return kApplicationJSONType; + } + [lowerAccepts addObject:[string lowercaseString]]; + } + return [lowerAccepts componentsJoinedByString:@", "]; +} + +/* + * Detect `Content-Type` from contentTypes + */ +- (NSString *) selectHeaderContentType:(NSArray *)contentTypes { + if (contentTypes.count == 0) { + return kApplicationJSONType; + } + NSMutableArray *lowerContentTypes = [[NSMutableArray alloc] initWithCapacity:[contentTypes count]]; + for (NSString *string in contentTypes) { + if([self.jsonHeaderTypeExpression matchesInString:string options:0 range:NSMakeRange(0, [string length])].count > 0){ + return kApplicationJSONType; + } + [lowerContentTypes addObject:[string lowercaseString]]; + } + return [lowerContentTypes firstObject]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Model/SWGCategory.h b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGCategory.h new file mode 100644 index 00000000000..1565724cf8c --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGCategory.h @@ -0,0 +1,40 @@ +#import +#import "SWGObject.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + + +@protocol SWGCategory +@end + +@interface SWGCategory : SWGObject + + +@property(nonatomic) NSNumber* _id; + +@property(nonatomic) NSString* name; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Model/SWGCategory.m b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGCategory.m new file mode 100644 index 00000000000..00745d1f499 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGCategory.m @@ -0,0 +1,34 @@ +#import "SWGCategory.h" + +@implementation SWGCategory + +- (instancetype)init { + self = [super init]; + if (self) { + // initialize property's default value, if any + + } + return self; +} + + +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ ++ (JSONKeyMapper *)keyMapper { + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; +} + +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. + * This method is used by `JSONModel`. + */ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + + NSArray *optionalProperties = @[@"_id", @"name"]; + return [optionalProperties containsObject:propertyName]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Model/SWGOrder.h b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGOrder.h new file mode 100644 index 00000000000..5c29f61c0e6 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGOrder.h @@ -0,0 +1,49 @@ +#import +#import "SWGObject.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + + +@protocol SWGOrder +@end + +@interface SWGOrder : SWGObject + + +@property(nonatomic) NSNumber* _id; + +@property(nonatomic) NSNumber* petId; + +@property(nonatomic) NSNumber* quantity; + +@property(nonatomic) NSDate* shipDate; +/* Order Status [optional] + */ +@property(nonatomic) NSString* status; + +@property(nonatomic) NSNumber* complete; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Model/SWGOrder.m b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGOrder.m new file mode 100644 index 00000000000..e0b44e06954 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGOrder.m @@ -0,0 +1,34 @@ +#import "SWGOrder.h" + +@implementation SWGOrder + +- (instancetype)init { + self = [super init]; + if (self) { + // initialize property's default value, if any + + } + return self; +} + + +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ ++ (JSONKeyMapper *)keyMapper { + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }]; +} + +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. + * This method is used by `JSONModel`. + */ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + + NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"]; + return [optionalProperties containsObject:propertyName]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Model/SWGPet.h b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGPet.h new file mode 100644 index 00000000000..90de23fbbf5 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGPet.h @@ -0,0 +1,51 @@ +#import +#import "SWGObject.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#import "SWGCategory.h" +#import "SWGTag.h" + + +@protocol SWGPet +@end + +@interface SWGPet : SWGObject + + +@property(nonatomic) NSNumber* _id; + +@property(nonatomic) SWGCategory* category; + +@property(nonatomic) NSString* name; + +@property(nonatomic) NSArray* photoUrls; + +@property(nonatomic) NSArray* tags; +/* pet status in the store [optional] + */ +@property(nonatomic) NSString* status; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Model/SWGPet.m b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGPet.m new file mode 100644 index 00000000000..a1c63520dc4 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGPet.m @@ -0,0 +1,34 @@ +#import "SWGPet.h" + +@implementation SWGPet + +- (instancetype)init { + self = [super init]; + if (self) { + // initialize property's default value, if any + + } + return self; +} + + +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ ++ (JSONKeyMapper *)keyMapper { + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"category": @"category", @"name": @"name", @"photoUrls": @"photoUrls", @"tags": @"tags", @"status": @"status" }]; +} + +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. + * This method is used by `JSONModel`. + */ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + + NSArray *optionalProperties = @[@"_id", @"category", @"tags", @"status"]; + return [optionalProperties containsObject:propertyName]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Model/SWGTag.h b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGTag.h new file mode 100644 index 00000000000..97aa6162af6 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGTag.h @@ -0,0 +1,40 @@ +#import +#import "SWGObject.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + + +@protocol SWGTag +@end + +@interface SWGTag : SWGObject + + +@property(nonatomic) NSNumber* _id; + +@property(nonatomic) NSString* name; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Model/SWGTag.m b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGTag.m new file mode 100644 index 00000000000..e71829873d1 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGTag.m @@ -0,0 +1,34 @@ +#import "SWGTag.h" + +@implementation SWGTag + +- (instancetype)init { + self = [super init]; + if (self) { + // initialize property's default value, if any + + } + return self; +} + + +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ ++ (JSONKeyMapper *)keyMapper { + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; +} + +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. + * This method is used by `JSONModel`. + */ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + + NSArray *optionalProperties = @[@"_id", @"name"]; + return [optionalProperties containsObject:propertyName]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Model/SWGUser.h b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGUser.h new file mode 100644 index 00000000000..2c94220a57e --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGUser.h @@ -0,0 +1,53 @@ +#import +#import "SWGObject.h" + +/** +* Swagger Petstore +* This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +* +* OpenAPI spec version: 1.0.0 +* Contact: apiteam@wordnik.com +* +* NOTE: This class is auto generated by the swagger code generator program. +* https://github.com/swagger-api/swagger-codegen.git +* Do not edit the class manually. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + + +@protocol SWGUser +@end + +@interface SWGUser : SWGObject + + +@property(nonatomic) NSNumber* _id; + +@property(nonatomic) NSString* username; + +@property(nonatomic) NSString* firstName; + +@property(nonatomic) NSString* lastName; + +@property(nonatomic) NSString* email; + +@property(nonatomic) NSString* password; + +@property(nonatomic) NSString* phone; +/* User Status [optional] + */ +@property(nonatomic) NSNumber* userStatus; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClient/Model/SWGUser.m b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGUser.m new file mode 100644 index 00000000000..c8195660df6 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClient/Model/SWGUser.m @@ -0,0 +1,34 @@ +#import "SWGUser.h" + +@implementation SWGUser + +- (instancetype)init { + self = [super init]; + if (self) { + // initialize property's default value, if any + + } + return self; +} + + +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ ++ (JSONKeyMapper *)keyMapper { + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"username": @"username", @"firstName": @"firstName", @"lastName": @"lastName", @"email": @"email", @"password": @"password", @"phone": @"phone", @"userStatus": @"userStatus" }]; +} + +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. + * This method is used by `JSONModel`. + */ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + + NSArray *optionalProperties = @[@"_id", @"username", @"firstName", @"lastName", @"email", @"password", @"phone", @"userStatus"]; + return [optionalProperties containsObject:propertyName]; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/Podfile b/samples/client/petstore/objc/default/SwaggerClientTests/Podfile new file mode 100644 index 00000000000..22654e6adda --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/Podfile @@ -0,0 +1,12 @@ +source 'https://github.com/CocoaPods/Specs.git' + +target 'SwaggerClient_Example' do + pod "SwaggerClient", :path => "../" +end + +target 'SwaggerClient_Tests' do + pod "SwaggerClient", :path => "../" + + pod 'Specta' + pod 'Expecta' +end diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj similarity index 98% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj rename to samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj index 1a8aa88ce42..cd20eb43998 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj @@ -24,7 +24,6 @@ B2ADC0B1C8A60A05C48B4DF7 /* DatabaseHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = B2ADC55130D5E329ED945E8F /* DatabaseHelper.m */; }; B2ADC17C287DCABF329BA8AC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC7027D4B025ABCA7999F /* Main.storyboard */; }; B2ADC2D632658A5F73C6CE66 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC65E342ADA697322D68C /* Images.xcassets */; }; - B2ADC3C7634D15595DD14814 /* BuildersTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B2ADC838FCC22F4BC6C41106 /* BuildersTest.m */; }; 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 */; }; @@ -72,7 +71,6 @@ B2ADC55130D5E329ED945E8F /* DatabaseHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DatabaseHelper.m; 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 = ""; }; - B2ADC838FCC22F4BC6C41106 /* BuildersTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BuildersTest.m; 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 = ""; }; @@ -181,7 +179,6 @@ CFDFB40D1B3CFEC3009739C5 /* UserApiTest.m */, 6003F5BB195388D20070C39A /* Tests.m */, 6003F5B6195388D20070C39A /* Supporting Files */, - B2ADC838FCC22F4BC6C41106 /* BuildersTest.m */, B2ADCA62DE4AC0F5BAB42208 /* Helpers */, ); path = Tests; @@ -438,7 +435,6 @@ CFDFB4151B3D000B009739C5 /* SWGApiClientTest.m in Sources */, CFDFB4121B3CFFA8009739C5 /* UserApiTest.m in Sources */, CF8F71391B5F73AC00162980 /* DeserializationTest.m in Sources */, - B2ADC3C7634D15595DD14814 /* BuildersTest.m in Sources */, B2ADC0B1C8A60A05C48B4DF7 /* DatabaseHelper.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000000..13bdd8ab8b7 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/All Tests.xcscheme b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/All Tests.xcscheme new file mode 100644 index 00000000000..5c68411bb2d --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/All Tests.xcscheme @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/SwaggerClient-Example.xcscheme b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/SwaggerClient-Example.xcscheme new file mode 100644 index 00000000000..d34e508f438 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/SwaggerClient-Example.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Images.xcassets/AppIcon.appiconset/Contents.json b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000000..f697f61f4aa --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,53 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Images.xcassets/LaunchImage.launchimage/Contents.json b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 00000000000..4458b40c055 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,51 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "subtype" : "retina4", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard new file mode 100644 index 00000000000..36df4e16819 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Main.storyboard b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Main.storyboard new file mode 100644 index 00000000000..f204320d333 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/Main.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGAppDelegate.h b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGAppDelegate.h new file mode 100644 index 00000000000..eb867594fde --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGAppDelegate.h @@ -0,0 +1,15 @@ +// +// SWGAppDelegate.h +// SwaggerClient +// +// Created by CocoaPods on 06/26/2015. +// Copyright (c) 2014 geekerzp. All rights reserved. +// + +@import UIKit; + +@interface SWGAppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGAppDelegate.m b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGAppDelegate.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGAppDelegate.m rename to samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGAppDelegate.m diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGViewController.h b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGViewController.h new file mode 100644 index 00000000000..7847f2d05b1 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGViewController.h @@ -0,0 +1,13 @@ +// +// SWGViewController.h +// SwaggerClient +// +// Created by geekerzp on 06/26/2015. +// Copyright (c) 2014 geekerzp. All rights reserved. +// + +@import UIKit; + +@interface SWGViewController : UIViewController + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGViewController.m b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGViewController.m new file mode 100644 index 00000000000..7f8e3d67881 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SWGViewController.m @@ -0,0 +1,60 @@ +// +// SWGViewController.m +// SwaggerClient +// +// Created by geekerzp on 06/26/2015. +// Copyright (c) 2014 geekerzp. All rights reserved. +// + +#import "SWGViewController.h" +#import +#import +#import +#import + +@interface SWGViewController () + +@end + +@implementation SWGViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + SWGConfiguration *config = [SWGConfiguration sharedConfig]; + config.debug = YES; + + SWGPetApi *api = [[SWGPetApi alloc] init]; + NSURL *file = [NSURL fileURLWithPath:@"/Users/geekerzp/tmp/test.jpg"]; + [api uploadFileWithPetId:@2 additionalMetadata:@"2" file:file completionHandler:^(NSError *error) { + NSLog(@"*** error: %@", error); + }]; +} + +- (SWGPet*) createPet { + SWGPet * pet = [[SWGPet alloc] init]; + pet._id = @((long) [[NSDate date] timeIntervalSince1970]); + pet.name = @"monkey"; + + SWGCategory * category = [[SWGCategory alloc] init]; + category._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + category.name = @"super-happy"; + pet.category = category; + + SWGTag *tag1 = [[SWGTag alloc] init]; + tag1._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + tag1.name = @"test tag 1"; + SWGTag *tag2 = [[SWGTag alloc] init]; + tag2._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + tag2.name = @"test tag 2"; + pet.tags = (NSArray *) @[tag1, tag2]; + + pet.status = @"available"; + + NSArray * photos = @[@"http://foo.bar.com/3", @"http://foo.bar.com/4"]; + pet.photoUrls = photos; + return pet; +} + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist new file mode 100644 index 00000000000..e21b2835ad7 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist @@ -0,0 +1,54 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + UILaunchStoryboardName + Launch Screen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SwaggerClient-Prefix.pch b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SwaggerClient-Prefix.pch new file mode 100644 index 00000000000..7825372cbdd --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/SwaggerClient-Prefix.pch @@ -0,0 +1,16 @@ +// +// Prefix header +// +// The contents of this file are implicitly included at the beginning of every source file. +// + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + @import UIKit; + @import Foundation; +#endif diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/en.lproj/InfoPlist.strings b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/en.lproj/InfoPlist.strings new file mode 100644 index 00000000000..477b28ff8f8 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/main.m b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/main.m new file mode 100644 index 00000000000..4a47f1fd69e --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient/main.m @@ -0,0 +1,17 @@ +// +// main.m +// SwaggerClient +// +// Created by geekerzp on 06/26/2015. +// Copyright (c) 2014 geekerzp. All rights reserved. +// + +@import UIKit; +#import "SWGAppDelegate.h" + +int main(int argc, char * argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([SWGAppDelegate class])); + } +} diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/DeserializationTest.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m rename to samples/client/petstore/objc/default/SwaggerClientTests/Tests/DeserializationTest.m diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Helpers/DatabaseHelper.h b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Helpers/DatabaseHelper.h new file mode 100644 index 00000000000..8216e012a32 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Helpers/DatabaseHelper.h @@ -0,0 +1,14 @@ +#import +#import + +@interface DatabaseHelper : NSObject + ++ (NSManagedObjectContext *)createContextWithModelName:(NSString *)mName; + ++ (void)clearContext:(NSManagedObjectContext *)ctx fromEntitiesWithName:(NSString *)entityName; + ++ (NSManagedObjectModel *)createModelWithModelName:(NSString *)mName; + ++ (NSManagedObjectContext *)createDatabaseWithModel:(NSManagedObjectModel*)model; + +@end diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Helpers/DatabaseHelper.m b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Helpers/DatabaseHelper.m new file mode 100644 index 00000000000..3433ac19ddb --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Helpers/DatabaseHelper.m @@ -0,0 +1,42 @@ +#import "DatabaseHelper.h" + +@implementation DatabaseHelper + + ++ (NSManagedObjectContext *)createContextWithModelName:(NSString *)mName { + NSManagedObjectModel *model = [self createModelWithModelName:mName]; + return [self createDatabaseWithModel:model]; +} + ++ (NSManagedObjectContext *)createDatabaseWithModel:(NSManagedObjectModel*)model { + NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; + [coordinator addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:nil]; + + NSManagedObjectContext *testingContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; + [testingContext setPersistentStoreCoordinator:coordinator]; + [testingContext setMergePolicy:NSMergeByPropertyObjectTrumpMergePolicy]; + return testingContext; +} + ++ (NSManagedObjectModel *)createModelWithModelName:(NSString *)mName { + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSString *path = [bundle pathForResource:mName ofType:@"momd"]; + NSAssert(path, @"Missing Model for name: %@",mName); + NSURL *modURL = [NSURL fileURLWithPath:path]; + return [[NSManagedObjectModel alloc] initWithContentsOfURL:modURL]; +} + ++ (void)clearContext:(NSManagedObjectContext *)ctx fromEntitiesWithName:(NSString *)entityName { + NSFetchRequest *fetch = [[NSFetchRequest alloc] init]; + [fetch setEntity:[NSEntityDescription entityForName:entityName inManagedObjectContext:ctx]]; + NSError *error = nil; + NSArray *result = [ctx executeFetchRequest:fetch error:&error]; + if (error) { + NSLog(@"Failed clearing context from entities with name [%@]", error); + } + for (id basket in result) { + [ctx deleteObject:basket]; + } +} + +@end diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/PetApiTest.m b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/PetApiTest.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/PetApiTest.m rename to samples/client/petstore/objc/default/SwaggerClientTests/Tests/PetApiTest.m diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/PetTest.m b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/PetTest.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/PetTest.m rename to samples/client/petstore/objc/default/SwaggerClientTests/Tests/PetTest.m diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/SWGApiClientTest.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m rename to samples/client/petstore/objc/default/SwaggerClientTests/Tests/SWGApiClientTest.m diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/StoreApiTest.m b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/StoreApiTest.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/StoreApiTest.m rename to samples/client/petstore/objc/default/SwaggerClientTests/Tests/StoreApiTest.m diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Tests-Info.plist b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Tests-Info.plist new file mode 100644 index 00000000000..41520eda89e --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Tests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Tests-Prefix.pch b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Tests-Prefix.pch new file mode 100644 index 00000000000..6d08c288215 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Tests-Prefix.pch @@ -0,0 +1,8 @@ +// The contents of this file are implicitly included at the beginning of every test case source file. + +#ifdef __OBJC__ + + //@import Specta; + //@import Expecta; + +#endif diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/Tests.m b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/Tests.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/Tests.m rename to samples/client/petstore/objc/default/SwaggerClientTests/Tests/Tests.m diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/UserApiTest.m b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/UserApiTest.m similarity index 100% rename from samples/client/petstore/objc/SwaggerClientTests/Tests/UserApiTest.m rename to samples/client/petstore/objc/default/SwaggerClientTests/Tests/UserApiTest.m diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/Tests/en.lproj/InfoPlist.strings b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/en.lproj/InfoPlist.strings new file mode 100644 index 00000000000..477b28ff8f8 --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/Tests/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/pom.xml b/samples/client/petstore/objc/default/SwaggerClientTests/pom.xml new file mode 100644 index 00000000000..a480547e0ae --- /dev/null +++ b/samples/client/petstore/objc/default/SwaggerClientTests/pom.xml @@ -0,0 +1,65 @@ + + 4.0.0 + io.swagger + ObjcPetstoreClientTests + pom + 1.0-SNAPSHOT + Objective-C Swagger Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + install-pods + pre-integration-test + + exec + + + pod + + install + + + + + xcodebuild-test + integration-test + + exec + + + xcodebuild + + -workspace + SwaggerClient.xcworkspace + -scheme + SwaggerClient-Example + test + -destination + platform=iOS Simulator,name=iPhone 5s,OS=9.3 + + + + + + + + diff --git a/samples/client/petstore/objc/docs/SWGCategory.md b/samples/client/petstore/objc/default/docs/SWGCategory.md similarity index 100% rename from samples/client/petstore/objc/docs/SWGCategory.md rename to samples/client/petstore/objc/default/docs/SWGCategory.md diff --git a/samples/client/petstore/objc/docs/SWGOrder.md b/samples/client/petstore/objc/default/docs/SWGOrder.md similarity index 100% rename from samples/client/petstore/objc/docs/SWGOrder.md rename to samples/client/petstore/objc/default/docs/SWGOrder.md diff --git a/samples/client/petstore/objc/docs/SWGPet.md b/samples/client/petstore/objc/default/docs/SWGPet.md similarity index 100% rename from samples/client/petstore/objc/docs/SWGPet.md rename to samples/client/petstore/objc/default/docs/SWGPet.md diff --git a/samples/client/petstore/objc/docs/SWGPetApi.md b/samples/client/petstore/objc/default/docs/SWGPetApi.md similarity index 100% rename from samples/client/petstore/objc/docs/SWGPetApi.md rename to samples/client/petstore/objc/default/docs/SWGPetApi.md diff --git a/samples/client/petstore/objc/docs/SWGStoreApi.md b/samples/client/petstore/objc/default/docs/SWGStoreApi.md similarity index 100% rename from samples/client/petstore/objc/docs/SWGStoreApi.md rename to samples/client/petstore/objc/default/docs/SWGStoreApi.md diff --git a/samples/client/petstore/objc/docs/SWGTag.md b/samples/client/petstore/objc/default/docs/SWGTag.md similarity index 100% rename from samples/client/petstore/objc/docs/SWGTag.md rename to samples/client/petstore/objc/default/docs/SWGTag.md diff --git a/samples/client/petstore/objc/docs/SWGUser.md b/samples/client/petstore/objc/default/docs/SWGUser.md similarity index 100% rename from samples/client/petstore/objc/docs/SWGUser.md rename to samples/client/petstore/objc/default/docs/SWGUser.md diff --git a/samples/client/petstore/objc/docs/SWGUserApi.md b/samples/client/petstore/objc/default/docs/SWGUserApi.md similarity index 100% rename from samples/client/petstore/objc/docs/SWGUserApi.md rename to samples/client/petstore/objc/default/docs/SWGUserApi.md diff --git a/samples/client/petstore/objc/default/git_push.sh b/samples/client/petstore/objc/default/git_push.sh new file mode 100644 index 00000000000..ed374619b13 --- /dev/null +++ b/samples/client/petstore/objc/default/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/objc/docs/SWG200Response.md b/samples/client/petstore/objc/docs/SWG200Response.md deleted file mode 100644 index 31392772201..00000000000 --- a/samples/client/petstore/objc/docs/SWG200Response.md +++ /dev/null @@ -1,10 +0,0 @@ -# SWG200Response - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **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/SWGAdditionalPropertiesClass.md b/samples/client/petstore/objc/docs/SWGAdditionalPropertiesClass.md deleted file mode 100644 index 930b5b886d9..00000000000 --- a/samples/client/petstore/objc/docs/SWGAdditionalPropertiesClass.md +++ /dev/null @@ -1,11 +0,0 @@ -# SWGAdditionalPropertiesClass - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**mapProperty** | **NSDictionary<NSString*, NSString*>*** | | [optional] -**mapOfMapProperty** | [**NSDictionary<NSString*, NSDictionary<NSString*, NSString*>*>***](NSDictionary.md) | | [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/SWGAnimal.md b/samples/client/petstore/objc/docs/SWGAnimal.md deleted file mode 100644 index a54bdefe8af..00000000000 --- a/samples/client/petstore/objc/docs/SWGAnimal.md +++ /dev/null @@ -1,11 +0,0 @@ -# SWGAnimal - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **NSString*** | | -**color** | **NSString*** | | [optional] [default to @"red"] - -[[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/SWGAnimalFarm.md b/samples/client/petstore/objc/docs/SWGAnimalFarm.md deleted file mode 100644 index 48b268a95f3..00000000000 --- a/samples/client/petstore/objc/docs/SWGAnimalFarm.md +++ /dev/null @@ -1,9 +0,0 @@ -# SWGAnimalFarm - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - -[[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/SWGApiResponse.md b/samples/client/petstore/objc/docs/SWGApiResponse.md deleted file mode 100644 index 88ff755faf7..00000000000 --- a/samples/client/petstore/objc/docs/SWGApiResponse.md +++ /dev/null @@ -1,12 +0,0 @@ -# SWGApiResponse - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**code** | **NSNumber*** | | [optional] -**type** | **NSString*** | | [optional] -**message** | **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/SWGArrayTest.md b/samples/client/petstore/objc/docs/SWGArrayTest.md deleted file mode 100644 index 089bd48dc16..00000000000 --- a/samples/client/petstore/objc/docs/SWGArrayTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# SWGArrayTest - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**arrayOfString** | **NSArray<NSString*>*** | | [optional] -**arrayArrayOfInteger** | [**NSArray<NSArray<NSNumber*>*>***](NSArray.md) | | [optional] -**arrayArrayOfModel** | [**NSArray<NSArray<SWGReadOnlyFirst>*>***](NSArray.md) | | [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/SWGCat.md b/samples/client/petstore/objc/docs/SWGCat.md deleted file mode 100644 index 9fd46b05af0..00000000000 --- a/samples/client/petstore/objc/docs/SWGCat.md +++ /dev/null @@ -1,12 +0,0 @@ -# SWGCat - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **NSString*** | | -**color** | **NSString*** | | [optional] [default to @"red"] -**declawed** | **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/SWGDog.md b/samples/client/petstore/objc/docs/SWGDog.md deleted file mode 100644 index 1b3deb35c3f..00000000000 --- a/samples/client/petstore/objc/docs/SWGDog.md +++ /dev/null @@ -1,12 +0,0 @@ -# SWGDog - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **NSString*** | | -**color** | **NSString*** | | [optional] [default to @"red"] -**breed** | **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/SWGEnumClass.md b/samples/client/petstore/objc/docs/SWGEnumClass.md deleted file mode 100644 index 6acdf03e456..00000000000 --- a/samples/client/petstore/objc/docs/SWGEnumClass.md +++ /dev/null @@ -1,9 +0,0 @@ -# SWGEnumClass - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - -[[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/SWGEnumTest.md b/samples/client/petstore/objc/docs/SWGEnumTest.md deleted file mode 100644 index 4f0c5f3285e..00000000000 --- a/samples/client/petstore/objc/docs/SWGEnumTest.md +++ /dev/null @@ -1,12 +0,0 @@ -# SWGEnumTest - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**enumString** | **NSString*** | | [optional] -**enumInteger** | **NSNumber*** | | [optional] -**enumNumber** | **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/SWGFakeApi.md b/samples/client/petstore/objc/docs/SWGFakeApi.md deleted file mode 100644 index 536f88dee8e..00000000000 --- a/samples/client/petstore/objc/docs/SWGFakeApi.md +++ /dev/null @@ -1,100 +0,0 @@ -# SWGFakeApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**testEndpointParameters**](SWGFakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - - -# **testEndpointParameters** -```objc --(NSNumber*) testEndpointParametersWithNumber: (NSNumber*) number - _double: (NSNumber*) _double - string: (NSString*) string - byte: (NSData*) byte - integer: (NSNumber*) integer - int32: (NSNumber*) int32 - int64: (NSNumber*) int64 - _float: (NSNumber*) _float - binary: (NSData*) binary - date: (NSDate*) date - dateTime: (NSDate*) dateTime - password: (NSString*) password - completionHandler: (void (^)(NSError* error)) handler; -``` - -Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - -Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - -### Example -```objc - -NSNumber* number = @3.4; // None -NSNumber* _double = @1.2; // None -NSString* string = @"string_example"; // None -NSData* byte = [[NSData alloc] init]; // None -NSNumber* integer = @56; // None (optional) -NSNumber* int32 = @56; // None (optional) -NSNumber* int64 = @789; // None (optional) -NSNumber* _float = @3.4; // None (optional) -NSData* binary = [[NSData alloc] init]; // None (optional) -NSDate* date = @"2013-10-20"; // None (optional) -NSDate* dateTime = @"2013-10-20T19:20:30+01:00"; // None (optional) -NSString* password = @"password_example"; // None (optional) - -SWGFakeApi*apiInstance = [[SWGFakeApi alloc] init]; - -// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 -[apiInstance testEndpointParametersWithNumber:number - _double:_double - string:string - byte:byte - integer:integer - int32:int32 - int64:int64 - _float:_float - binary:binary - date:date - dateTime:dateTime - password:password - completionHandler: ^(NSError* error) { - if (error) { - NSLog(@"Error calling SWGFakeApi->testEndpointParameters: %@", error); - } - }]; -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **number** | **NSNumber***| None | - **_double** | **NSNumber***| None | - **string** | **NSString***| None | - **byte** | **NSData***| None | - **integer** | **NSNumber***| None | [optional] - **int32** | **NSNumber***| None | [optional] - **int64** | **NSNumber***| None | [optional] - **_float** | **NSNumber***| None | [optional] - **binary** | **NSData***| None | [optional] - **date** | **NSDate***| None | [optional] - **dateTime** | **NSDate***| None | [optional] - **password** | **NSString***| None | [optional] - -### Return type - -void (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/xml; charset=utf-8, application/json; charset=utf-8 - - **Accept**: application/xml; charset=utf-8, application/json; charset=utf-8 - -[[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/SWGFormatTest.md b/samples/client/petstore/objc/docs/SWGFormatTest.md deleted file mode 100644 index 2682c4a3a78..00000000000 --- a/samples/client/petstore/objc/docs/SWGFormatTest.md +++ /dev/null @@ -1,22 +0,0 @@ -# SWGFormatTest - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**integer** | **NSNumber*** | | [optional] -**int32** | **NSNumber*** | | [optional] -**int64** | **NSNumber*** | | [optional] -**number** | **NSNumber*** | | -**_float** | **NSNumber*** | | [optional] -**_double** | **NSNumber*** | | [optional] -**string** | **NSString*** | | [optional] -**byte** | **NSData*** | | -**binary** | **NSData*** | | [optional] -**date** | **NSDate*** | | -**dateTime** | **NSDate*** | | [optional] -**uuid** | **NSString*** | | [optional] -**password** | **NSString*** | | - -[[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/SWGMixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/objc/docs/SWGMixedPropertiesAndAdditionalPropertiesClass.md deleted file mode 100644 index 707e45b9840..00000000000 --- a/samples/client/petstore/objc/docs/SWGMixedPropertiesAndAdditionalPropertiesClass.md +++ /dev/null @@ -1,12 +0,0 @@ -# SWGMixedPropertiesAndAdditionalPropertiesClass - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**uuid** | **NSString*** | | [optional] -**dateTime** | **NSDate*** | | [optional] -**map** | [**NSDictionary<NSString*, SWGAnimal>***](SWGAnimal.md) | | [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/SWGName.md b/samples/client/petstore/objc/docs/SWGName.md deleted file mode 100644 index 89dd0ff47e5..00000000000 --- a/samples/client/petstore/objc/docs/SWGName.md +++ /dev/null @@ -1,13 +0,0 @@ -# SWGName - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **NSNumber*** | | -**snakeCase** | **NSNumber*** | | [optional] -**_property** | **NSString*** | | [optional] -**_123Number** | **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/SWGReadOnlyFirst.md b/samples/client/petstore/objc/docs/SWGReadOnlyFirst.md deleted file mode 100644 index d9260a1b83e..00000000000 --- a/samples/client/petstore/objc/docs/SWGReadOnlyFirst.md +++ /dev/null @@ -1,11 +0,0 @@ -# SWGReadOnlyFirst - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**bar** | **NSString*** | | [optional] -**baz** | **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/SWGReturn.md b/samples/client/petstore/objc/docs/SWGReturn.md deleted file mode 100644 index 5fd23efdadc..00000000000 --- a/samples/client/petstore/objc/docs/SWGReturn.md +++ /dev/null @@ -1,10 +0,0 @@ -# SWGReturn - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**_return** | **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/SWGSpecialModelName_.md b/samples/client/petstore/objc/docs/SWGSpecialModelName_.md deleted file mode 100644 index 4e62042d6f6..00000000000 --- a/samples/client/petstore/objc/docs/SWGSpecialModelName_.md +++ /dev/null @@ -1,10 +0,0 @@ -# SWGSpecialModelName_ - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**specialPropertyName** | **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/python/README.md b/samples/client/petstore/python/README.md index c429ada359d..34b2014aa03 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-06-17T00:41:00.422+08:00 +- Build date: 2016-06-20T11:55:16.948+08:00 - Build package: class io.swagger.codegen.languages.PythonClientCodegen ## Requirements. diff --git a/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index 5bc448a950c..2521ba15fd3 100644 --- a/samples/client/petstore/python/petstore_api/api_client.py +++ b/samples/client/petstore/python/petstore_api/api_client.py @@ -103,7 +103,7 @@ class ApiClient(object): def __call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, - response_type=None, auth_settings=None, callback=None): + response_type=None, auth_settings=None, callback=None, _return_http_data_only=None): # headers parameters header_params = header_params or {} @@ -157,9 +157,12 @@ class ApiClient(object): deserialized_data = None if callback: - callback(deserialized_data) + callback(deserialized_data) if _return_http_data_only else callback((deserialized_data, response_data.status, response_data.getheaders())) + elif _return_http_data_only: + return ( deserialized_data ); else: - return deserialized_data + return (deserialized_data, response_data.status, response_data.getheaders()) + def to_path_value(self, obj): """ @@ -287,7 +290,7 @@ class ApiClient(object): def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, - response_type=None, auth_settings=None, callback=None): + response_type=None, auth_settings=None, callback=None, _return_http_data_only=None): """ Makes the HTTP request (synchronous) and return the deserialized data. To make an async request, define a function for callback. @@ -308,6 +311,7 @@ class ApiClient(object): :param callback function: Callback function for asynchronous request. If provide this parameter, the request will be called asynchronously. + :param _return_http_data_only: response data without head status code and headers :return: If provide parameter callback, the request will be called asynchronously. @@ -319,7 +323,7 @@ class ApiClient(object): return self.__call_api(resource_path, method, path_params, query_params, header_params, body, post_params, files, - response_type, auth_settings, callback) + response_type, auth_settings, callback, _return_http_data_only) else: thread = threading.Thread(target=self.__call_api, args=(resource_path, method, @@ -327,7 +331,7 @@ class ApiClient(object): header_params, body, post_params, files, response_type, auth_settings, - callback)) + callback,_return_http_data_only)) thread.start() return thread diff --git a/samples/client/petstore/python/petstore_api/apis/fake_api.py b/samples/client/petstore/python/petstore_api/apis/fake_api.py index 317232217b8..33eb3aabb99 100644 --- a/samples/client/petstore/python/petstore_api/apis/fake_api.py +++ b/samples/client/petstore/python/petstore_api/apis/fake_api.py @@ -64,6 +64,44 @@ class FakeApi(object): >>> >>> thread = api.test_endpoint_parameters(number, double, string, byte, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param float number: None (required) + :param float double: None (required) + :param str string: None (required) + :param str byte: None (required) + :param int integer: None + :param int int32: None + :param int int64: None + :param float float: None + :param str binary: None + :param date date: None + :param datetime date_time: None + :param str password: None + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.test_endpoint_parameters_with_http_info(number, double, string, byte, **kwargs) + else: + (data) = self.test_endpoint_parameters_with_http_info(number, double, string, byte, **kwargs) + return data + + def test_endpoint_parameters_with_http_info(self, number, double, string, byte, **kwargs): + """ + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.test_endpoint_parameters_with_http_info(number, double, string, byte, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param float number: None (required) @@ -85,6 +123,7 @@ class FakeApi(object): all_params = ['number', 'double', 'string', 'byte', 'integer', 'int32', 'int64', 'float', 'binary', 'date', 'date_time', 'password'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -181,7 +220,7 @@ class FakeApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'POST', + return self.api_client.call_api(resource_path, 'POST', path_params, query_params, header_params, @@ -190,5 +229,5 @@ class FakeApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) diff --git a/samples/client/petstore/python/petstore_api/apis/pet_api.py b/samples/client/petstore/python/petstore_api/apis/pet_api.py index 2f2ee4429c2..f3af7edcb8e 100644 --- a/samples/client/petstore/python/petstore_api/apis/pet_api.py +++ b/samples/client/petstore/python/petstore_api/apis/pet_api.py @@ -64,6 +64,33 @@ class PetApi(object): >>> >>> thread = api.add_pet(body, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param Pet body: Pet object that needs to be added to the store (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.add_pet_with_http_info(body, **kwargs) + else: + (data) = self.add_pet_with_http_info(body, **kwargs) + return data + + def add_pet_with_http_info(self, body, **kwargs): + """ + Add a new pet to the store + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.add_pet_with_http_info(body, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param Pet body: Pet object that needs to be added to the store (required) @@ -74,6 +101,7 @@ class PetApi(object): all_params = ['body'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -115,7 +143,7 @@ class PetApi(object): # Authentication setting auth_settings = ['petstore_auth'] - response = self.api_client.call_api(resource_path, 'POST', + return self.api_client.call_api(resource_path, 'POST', path_params, query_params, header_params, @@ -124,8 +152,8 @@ class PetApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def delete_pet(self, pet_id, **kwargs): """ @@ -140,6 +168,34 @@ class PetApi(object): >>> >>> thread = api.delete_pet(pet_id, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param int pet_id: Pet id to delete (required) + :param str api_key: + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.delete_pet_with_http_info(pet_id, **kwargs) + else: + (data) = self.delete_pet_with_http_info(pet_id, **kwargs) + return data + + def delete_pet_with_http_info(self, pet_id, **kwargs): + """ + Deletes a pet + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.delete_pet_with_http_info(pet_id, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param int pet_id: Pet id to delete (required) @@ -151,6 +207,7 @@ class PetApi(object): all_params = ['pet_id', 'api_key'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -194,7 +251,7 @@ class PetApi(object): # Authentication setting auth_settings = ['petstore_auth'] - response = self.api_client.call_api(resource_path, 'DELETE', + return self.api_client.call_api(resource_path, 'DELETE', path_params, query_params, header_params, @@ -203,8 +260,8 @@ class PetApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def find_pets_by_status(self, status, **kwargs): """ @@ -219,6 +276,33 @@ class PetApi(object): >>> >>> thread = api.find_pets_by_status(status, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param list[str] status: Status values that need to be considered for filter (required) + :return: list[Pet] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.find_pets_by_status_with_http_info(status, **kwargs) + else: + (data) = self.find_pets_by_status_with_http_info(status, **kwargs) + return data + + def find_pets_by_status_with_http_info(self, status, **kwargs): + """ + Finds Pets by status + Multiple status values can be provided with comma separated strings + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.find_pets_by_status_with_http_info(status, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param list[str] status: Status values that need to be considered for filter (required) @@ -229,6 +313,7 @@ class PetApi(object): all_params = ['status'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -270,7 +355,7 @@ class PetApi(object): # Authentication setting auth_settings = ['petstore_auth'] - response = self.api_client.call_api(resource_path, 'GET', + return self.api_client.call_api(resource_path, 'GET', path_params, query_params, header_params, @@ -279,8 +364,8 @@ class PetApi(object): files=local_var_files, response_type='list[Pet]', auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def find_pets_by_tags(self, tags, **kwargs): """ @@ -295,6 +380,33 @@ class PetApi(object): >>> >>> thread = api.find_pets_by_tags(tags, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param list[str] tags: Tags to filter by (required) + :return: list[Pet] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.find_pets_by_tags_with_http_info(tags, **kwargs) + else: + (data) = self.find_pets_by_tags_with_http_info(tags, **kwargs) + return data + + def find_pets_by_tags_with_http_info(self, tags, **kwargs): + """ + Finds Pets by tags + Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.find_pets_by_tags_with_http_info(tags, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param list[str] tags: Tags to filter by (required) @@ -305,6 +417,7 @@ class PetApi(object): all_params = ['tags'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -346,7 +459,7 @@ class PetApi(object): # Authentication setting auth_settings = ['petstore_auth'] - response = self.api_client.call_api(resource_path, 'GET', + return self.api_client.call_api(resource_path, 'GET', path_params, query_params, header_params, @@ -355,8 +468,8 @@ class PetApi(object): files=local_var_files, response_type='list[Pet]', auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def get_pet_by_id(self, pet_id, **kwargs): """ @@ -371,6 +484,33 @@ class PetApi(object): >>> >>> thread = api.get_pet_by_id(pet_id, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param int pet_id: ID of pet to return (required) + :return: Pet + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.get_pet_by_id_with_http_info(pet_id, **kwargs) + else: + (data) = self.get_pet_by_id_with_http_info(pet_id, **kwargs) + return data + + def get_pet_by_id_with_http_info(self, pet_id, **kwargs): + """ + Find pet by ID + Returns a single pet + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.get_pet_by_id_with_http_info(pet_id, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param int pet_id: ID of pet to return (required) @@ -381,6 +521,7 @@ class PetApi(object): all_params = ['pet_id'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -422,7 +563,7 @@ class PetApi(object): # Authentication setting auth_settings = ['api_key'] - response = self.api_client.call_api(resource_path, 'GET', + return self.api_client.call_api(resource_path, 'GET', path_params, query_params, header_params, @@ -431,8 +572,8 @@ class PetApi(object): files=local_var_files, response_type='Pet', auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def update_pet(self, body, **kwargs): """ @@ -447,6 +588,33 @@ class PetApi(object): >>> >>> thread = api.update_pet(body, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param Pet body: Pet object that needs to be added to the store (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.update_pet_with_http_info(body, **kwargs) + else: + (data) = self.update_pet_with_http_info(body, **kwargs) + return data + + def update_pet_with_http_info(self, body, **kwargs): + """ + Update an existing pet + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.update_pet_with_http_info(body, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param Pet body: Pet object that needs to be added to the store (required) @@ -457,6 +625,7 @@ class PetApi(object): all_params = ['body'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -498,7 +667,7 @@ class PetApi(object): # Authentication setting auth_settings = ['petstore_auth'] - response = self.api_client.call_api(resource_path, 'PUT', + return self.api_client.call_api(resource_path, 'PUT', path_params, query_params, header_params, @@ -507,8 +676,8 @@ class PetApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def update_pet_with_form(self, pet_id, **kwargs): """ @@ -523,6 +692,35 @@ class PetApi(object): >>> >>> thread = api.update_pet_with_form(pet_id, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param int pet_id: ID of pet that needs to be updated (required) + :param str name: Updated name of the pet + :param str status: Updated status of the pet + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.update_pet_with_form_with_http_info(pet_id, **kwargs) + else: + (data) = self.update_pet_with_form_with_http_info(pet_id, **kwargs) + return data + + def update_pet_with_form_with_http_info(self, pet_id, **kwargs): + """ + Updates a pet in the store with form data + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.update_pet_with_form_with_http_info(pet_id, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param int pet_id: ID of pet that needs to be updated (required) @@ -535,6 +733,7 @@ class PetApi(object): all_params = ['pet_id', 'name', 'status'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -580,7 +779,7 @@ class PetApi(object): # Authentication setting auth_settings = ['petstore_auth'] - response = self.api_client.call_api(resource_path, 'POST', + return self.api_client.call_api(resource_path, 'POST', path_params, query_params, header_params, @@ -589,8 +788,8 @@ class PetApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def upload_file(self, pet_id, **kwargs): """ @@ -605,6 +804,35 @@ class PetApi(object): >>> >>> thread = api.upload_file(pet_id, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param int pet_id: ID of pet to update (required) + :param str additional_metadata: Additional data to pass to server + :param file file: file to upload + :return: ApiResponse + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.upload_file_with_http_info(pet_id, **kwargs) + else: + (data) = self.upload_file_with_http_info(pet_id, **kwargs) + return data + + def upload_file_with_http_info(self, pet_id, **kwargs): + """ + uploads an image + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.upload_file_with_http_info(pet_id, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param int pet_id: ID of pet to update (required) @@ -617,6 +845,7 @@ class PetApi(object): all_params = ['pet_id', 'additional_metadata', 'file'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -662,7 +891,7 @@ class PetApi(object): # Authentication setting auth_settings = ['petstore_auth'] - response = self.api_client.call_api(resource_path, 'POST', + return self.api_client.call_api(resource_path, 'POST', path_params, query_params, header_params, @@ -671,5 +900,5 @@ class PetApi(object): files=local_var_files, response_type='ApiResponse', auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) diff --git a/samples/client/petstore/python/petstore_api/apis/store_api.py b/samples/client/petstore/python/petstore_api/apis/store_api.py index e945b61509c..853ceaf4f80 100644 --- a/samples/client/petstore/python/petstore_api/apis/store_api.py +++ b/samples/client/petstore/python/petstore_api/apis/store_api.py @@ -64,6 +64,33 @@ class StoreApi(object): >>> >>> thread = api.delete_order(order_id, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param str order_id: ID of the order that needs to be deleted (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.delete_order_with_http_info(order_id, **kwargs) + else: + (data) = self.delete_order_with_http_info(order_id, **kwargs) + return data + + def delete_order_with_http_info(self, order_id, **kwargs): + """ + Delete purchase order by ID + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.delete_order_with_http_info(order_id, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param str order_id: ID of the order that needs to be deleted (required) @@ -74,6 +101,7 @@ class StoreApi(object): all_params = ['order_id'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -117,7 +145,7 @@ class StoreApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'DELETE', + return self.api_client.call_api(resource_path, 'DELETE', path_params, query_params, header_params, @@ -126,8 +154,8 @@ class StoreApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def get_inventory(self, **kwargs): """ @@ -142,6 +170,32 @@ class StoreApi(object): >>> >>> thread = api.get_inventory(callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :return: dict(str, int) + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.get_inventory_with_http_info(**kwargs) + else: + (data) = self.get_inventory_with_http_info(**kwargs) + return data + + def get_inventory_with_http_info(self, **kwargs): + """ + Returns pet inventories by status + Returns a map of status codes to quantities + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.get_inventory_with_http_info(callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :return: dict(str, int) @@ -151,6 +205,7 @@ class StoreApi(object): all_params = [] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -187,7 +242,7 @@ class StoreApi(object): # Authentication setting auth_settings = ['api_key'] - response = self.api_client.call_api(resource_path, 'GET', + return self.api_client.call_api(resource_path, 'GET', path_params, query_params, header_params, @@ -196,8 +251,8 @@ class StoreApi(object): files=local_var_files, response_type='dict(str, int)', auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def get_order_by_id(self, order_id, **kwargs): """ @@ -212,6 +267,33 @@ class StoreApi(object): >>> >>> thread = api.get_order_by_id(order_id, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param int order_id: ID of pet that needs to be fetched (required) + :return: Order + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.get_order_by_id_with_http_info(order_id, **kwargs) + else: + (data) = self.get_order_by_id_with_http_info(order_id, **kwargs) + return data + + def get_order_by_id_with_http_info(self, order_id, **kwargs): + """ + Find purchase order by ID + For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.get_order_by_id_with_http_info(order_id, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param int order_id: ID of pet that needs to be fetched (required) @@ -222,6 +304,7 @@ class StoreApi(object): all_params = ['order_id'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -267,7 +350,7 @@ class StoreApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'GET', + return self.api_client.call_api(resource_path, 'GET', path_params, query_params, header_params, @@ -276,8 +359,8 @@ class StoreApi(object): files=local_var_files, response_type='Order', auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def place_order(self, body, **kwargs): """ @@ -292,6 +375,33 @@ class StoreApi(object): >>> >>> thread = api.place_order(body, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param Order body: order placed for purchasing the pet (required) + :return: Order + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.place_order_with_http_info(body, **kwargs) + else: + (data) = self.place_order_with_http_info(body, **kwargs) + return data + + def place_order_with_http_info(self, body, **kwargs): + """ + Place an order for a pet + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.place_order_with_http_info(body, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param Order body: order placed for purchasing the pet (required) @@ -302,6 +412,7 @@ class StoreApi(object): all_params = ['body'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -343,7 +454,7 @@ class StoreApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'POST', + return self.api_client.call_api(resource_path, 'POST', path_params, query_params, header_params, @@ -352,5 +463,5 @@ class StoreApi(object): files=local_var_files, response_type='Order', auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) diff --git a/samples/client/petstore/python/petstore_api/apis/user_api.py b/samples/client/petstore/python/petstore_api/apis/user_api.py index 5a8f1815495..b0b9709fe99 100644 --- a/samples/client/petstore/python/petstore_api/apis/user_api.py +++ b/samples/client/petstore/python/petstore_api/apis/user_api.py @@ -64,6 +64,33 @@ class UserApi(object): >>> >>> thread = api.create_user(body, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param User body: Created user object (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.create_user_with_http_info(body, **kwargs) + else: + (data) = self.create_user_with_http_info(body, **kwargs) + return data + + def create_user_with_http_info(self, body, **kwargs): + """ + Create user + This can only be done by the logged in user. + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.create_user_with_http_info(body, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param User body: Created user object (required) @@ -74,6 +101,7 @@ class UserApi(object): all_params = ['body'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -115,7 +143,7 @@ class UserApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'POST', + return self.api_client.call_api(resource_path, 'POST', path_params, query_params, header_params, @@ -124,8 +152,8 @@ class UserApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def create_users_with_array_input(self, body, **kwargs): """ @@ -140,6 +168,33 @@ class UserApi(object): >>> >>> thread = api.create_users_with_array_input(body, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param list[User] body: List of user object (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.create_users_with_array_input_with_http_info(body, **kwargs) + else: + (data) = self.create_users_with_array_input_with_http_info(body, **kwargs) + return data + + def create_users_with_array_input_with_http_info(self, body, **kwargs): + """ + Creates list of users with given input array + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.create_users_with_array_input_with_http_info(body, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param list[User] body: List of user object (required) @@ -150,6 +205,7 @@ class UserApi(object): all_params = ['body'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -191,7 +247,7 @@ class UserApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'POST', + return self.api_client.call_api(resource_path, 'POST', path_params, query_params, header_params, @@ -200,8 +256,8 @@ class UserApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def create_users_with_list_input(self, body, **kwargs): """ @@ -216,6 +272,33 @@ class UserApi(object): >>> >>> thread = api.create_users_with_list_input(body, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param list[User] body: List of user object (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.create_users_with_list_input_with_http_info(body, **kwargs) + else: + (data) = self.create_users_with_list_input_with_http_info(body, **kwargs) + return data + + def create_users_with_list_input_with_http_info(self, body, **kwargs): + """ + Creates list of users with given input array + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.create_users_with_list_input_with_http_info(body, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param list[User] body: List of user object (required) @@ -226,6 +309,7 @@ class UserApi(object): all_params = ['body'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -267,7 +351,7 @@ class UserApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'POST', + return self.api_client.call_api(resource_path, 'POST', path_params, query_params, header_params, @@ -276,8 +360,8 @@ class UserApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def delete_user(self, username, **kwargs): """ @@ -292,6 +376,33 @@ class UserApi(object): >>> >>> thread = api.delete_user(username, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param str username: The name that needs to be deleted (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.delete_user_with_http_info(username, **kwargs) + else: + (data) = self.delete_user_with_http_info(username, **kwargs) + return data + + def delete_user_with_http_info(self, username, **kwargs): + """ + Delete user + This can only be done by the logged in user. + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.delete_user_with_http_info(username, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param str username: The name that needs to be deleted (required) @@ -302,6 +413,7 @@ class UserApi(object): all_params = ['username'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -343,7 +455,7 @@ class UserApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'DELETE', + return self.api_client.call_api(resource_path, 'DELETE', path_params, query_params, header_params, @@ -352,8 +464,8 @@ class UserApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def get_user_by_name(self, username, **kwargs): """ @@ -368,6 +480,33 @@ class UserApi(object): >>> >>> thread = api.get_user_by_name(username, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param str username: The name that needs to be fetched. Use user1 for testing. (required) + :return: User + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.get_user_by_name_with_http_info(username, **kwargs) + else: + (data) = self.get_user_by_name_with_http_info(username, **kwargs) + return data + + def get_user_by_name_with_http_info(self, username, **kwargs): + """ + Get user by user name + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.get_user_by_name_with_http_info(username, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param str username: The name that needs to be fetched. Use user1 for testing. (required) @@ -378,6 +517,7 @@ class UserApi(object): all_params = ['username'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -419,7 +559,7 @@ class UserApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'GET', + return self.api_client.call_api(resource_path, 'GET', path_params, query_params, header_params, @@ -428,8 +568,8 @@ class UserApi(object): files=local_var_files, response_type='User', auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def login_user(self, username, password, **kwargs): """ @@ -444,6 +584,34 @@ class UserApi(object): >>> >>> thread = api.login_user(username, password, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param str username: The user name for login (required) + :param str password: The password for login in clear text (required) + :return: str + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.login_user_with_http_info(username, password, **kwargs) + else: + (data) = self.login_user_with_http_info(username, password, **kwargs) + return data + + def login_user_with_http_info(self, username, password, **kwargs): + """ + Logs user into the system + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.login_user_with_http_info(username, password, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param str username: The user name for login (required) @@ -455,6 +623,7 @@ class UserApi(object): all_params = ['username', 'password'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -501,7 +670,7 @@ class UserApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'GET', + return self.api_client.call_api(resource_path, 'GET', path_params, query_params, header_params, @@ -510,8 +679,8 @@ class UserApi(object): files=local_var_files, response_type='str', auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def logout_user(self, **kwargs): """ @@ -526,6 +695,32 @@ class UserApi(object): >>> >>> thread = api.logout_user(callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.logout_user_with_http_info(**kwargs) + else: + (data) = self.logout_user_with_http_info(**kwargs) + return data + + def logout_user_with_http_info(self, **kwargs): + """ + Logs out current logged in user session + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.logout_user_with_http_info(callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :return: None @@ -535,6 +730,7 @@ class UserApi(object): all_params = [] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -571,7 +767,7 @@ class UserApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'GET', + return self.api_client.call_api(resource_path, 'GET', path_params, query_params, header_params, @@ -580,8 +776,8 @@ class UserApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) def update_user(self, username, body, **kwargs): """ @@ -596,6 +792,34 @@ class UserApi(object): >>> >>> thread = api.update_user(username, body, callback=callback_function) + :param callback function: The callback function + for asynchronous request. (optional) + :param str username: name that need to be deleted (required) + :param User body: Updated user object (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('callback'): + return self.update_user_with_http_info(username, body, **kwargs) + else: + (data) = self.update_user_with_http_info(username, body, **kwargs) + return data + + def update_user_with_http_info(self, username, body, **kwargs): + """ + Updated user + This can only be done by the logged in user. + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.update_user_with_http_info(username, body, callback=callback_function) + :param callback function: The callback function for asynchronous request. (optional) :param str username: name that need to be deleted (required) @@ -607,6 +831,7 @@ class UserApi(object): all_params = ['username', 'body'] all_params.append('callback') + all_params.append('_return_http_data_only') params = locals() for key, val in iteritems(params['kwargs']): @@ -653,7 +878,7 @@ class UserApi(object): # Authentication setting auth_settings = [] - response = self.api_client.call_api(resource_path, 'PUT', + return self.api_client.call_api(resource_path, 'PUT', path_params, query_params, header_params, @@ -662,5 +887,5 @@ class UserApi(object): files=local_var_files, response_type=None, auth_settings=auth_settings, - callback=params.get('callback')) - return response + callback=params.get('callback'), + _return_http_data_only=params.get('_return_http_data_only')) diff --git a/samples/client/petstore/python/swagger_client/models/animal.py b/samples/client/petstore/python/swagger_client/models/animal.py new file mode 100644 index 00000000000..762e3df5b37 --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/animal.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class Animal(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + Animal - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'class_name': 'str' + } + + self.attribute_map = { + 'class_name': 'className' + } + + self._class_name = None + + @property + def class_name(self): + """ + Gets the class_name of this Animal. + + + :return: The class_name of this Animal. + :rtype: str + """ + return self._class_name + + @class_name.setter + def class_name(self, class_name): + """ + Sets the class_name of this Animal. + + + :param class_name: The class_name of this Animal. + :type: str + """ + self._class_name = class_name + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/swagger_client/models/cat.py b/samples/client/petstore/python/swagger_client/models/cat.py new file mode 100644 index 00000000000..4744fc4821c --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/cat.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class Cat(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + Cat - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'class_name': 'str', + 'declawed': 'bool' + } + + self.attribute_map = { + 'class_name': 'className', + 'declawed': 'declawed' + } + + self._class_name = None + self._declawed = None + + @property + def class_name(self): + """ + Gets the class_name of this Cat. + + + :return: The class_name of this Cat. + :rtype: str + """ + return self._class_name + + @class_name.setter + def class_name(self, class_name): + """ + Sets the class_name of this Cat. + + + :param class_name: The class_name of this Cat. + :type: str + """ + self._class_name = class_name + + @property + def declawed(self): + """ + Gets the declawed of this Cat. + + + :return: The declawed of this Cat. + :rtype: bool + """ + return self._declawed + + @declawed.setter + def declawed(self, declawed): + """ + Sets the declawed of this Cat. + + + :param declawed: The declawed of this Cat. + :type: bool + """ + self._declawed = declawed + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/swagger_client/models/dog.py b/samples/client/petstore/python/swagger_client/models/dog.py new file mode 100644 index 00000000000..3885dd314ef --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/dog.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class Dog(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + Dog - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'class_name': 'str', + 'breed': 'str' + } + + self.attribute_map = { + 'class_name': 'className', + 'breed': 'breed' + } + + self._class_name = None + self._breed = None + + @property + def class_name(self): + """ + Gets the class_name of this Dog. + + + :return: The class_name of this Dog. + :rtype: str + """ + return self._class_name + + @class_name.setter + def class_name(self, class_name): + """ + Sets the class_name of this Dog. + + + :param class_name: The class_name of this Dog. + :type: str + """ + self._class_name = class_name + + @property + def breed(self): + """ + Gets the breed of this Dog. + + + :return: The breed of this Dog. + :rtype: str + """ + return self._breed + + @breed.setter + def breed(self, breed): + """ + Sets the breed of this Dog. + + + :param breed: The breed of this Dog. + :type: str + """ + self._breed = breed + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/test_python2.sh b/samples/client/petstore/python/test_python2.sh index c6889895950..680d2ce61e0 100755 --- a/samples/client/petstore/python/test_python2.sh +++ b/samples/client/petstore/python/test_python2.sh @@ -21,7 +21,7 @@ python setup.py develop nosetests ### deactivate virtualenv -if [ $DEACTIVE == true ]; then - deactivate -fi +#if [ $DEACTIVE == true ]; then +# deactivate +#fi diff --git a/samples/client/petstore/python/test_python2_and_3.sh b/samples/client/petstore/python/test_python2_and_3.sh index 03c16abd4ae..2e4b4630a33 100755 --- a/samples/client/petstore/python/test_python2_and_3.sh +++ b/samples/client/petstore/python/test_python2_and_3.sh @@ -21,6 +21,6 @@ python setup.py develop tox ### deactivate virtualenv -if [ $DEACTIVE == true ]; then - deactivate -fi +#if [ $DEACTIVE == true ]; then +# deactivate +#fi diff --git a/samples/client/petstore/python/tests/test_pet_api.py b/samples/client/petstore/python/tests/test_pet_api.py index 4b749fc044a..37fe5a55212 100644 --- a/samples/client/petstore/python/tests/test_pet_api.py +++ b/samples/client/petstore/python/tests/test_pet_api.py @@ -97,6 +97,45 @@ class PetApiTests(unittest.TestCase): self.assertIsNotNone(fetched.category) self.assertEqual(self.pet.category.name, fetched.category.name) + def test_async_add_pet_and_get_pet_by_id(self): + self.pet_api.add_pet(body=self.pet) + + def callback_function(data): + #fetched = self.pet_api.get_pet_by_id(pet_id=self.pet.id) + self.assertIsNotNone(data) + self.assertEqual(self.pet.id, data.id) + self.assertIsNotNone(data.category) + self.assertEqual(self.pet.category.name, data.category.name) + + thread = self.pet_api.get_pet_by_id(pet_id=self.pet.id, callback=callback_function) + thread.join(10) + if thread.isAlive(): + self.fail("Request timeout") + + def test_add_pet_and_get_pet_by_id_with_http_info(self): + self.pet_api.add_pet(body=self.pet) + + fetched = self.pet_api.get_pet_by_id_with_http_info(pet_id=self.pet.id) + self.assertIsNotNone(fetched) + self.assertEqual(self.pet.id, fetched[0].id) + self.assertIsNotNone(fetched[0].category) + self.assertEqual(self.pet.category.name, fetched[0].category.name) + + def test_async_add_pet_and_get_pet_by_id_with_http_info(self): + self.pet_api.add_pet(body=self.pet) + + def callback_function(data): + #fetched = self.pet_api.get_pet_by_id_with_http_info(pet_id=self.pet.id) + self.assertIsNotNone(data) + self.assertEqual(self.pet.id, data[0].id) + self.assertIsNotNone(data[0].category) + self.assertEqual(self.pet.category.name, data[0].category.name) + + thread = self.pet_api.get_pet_by_id_with_http_info(pet_id=self.pet.id, callback=callback_function) + thread.join(10) + if thread.isAlive(): + self.fail("Request timeout") + def test_update_pet(self): self.pet.name = "hello kity with updated" self.pet_api.update_pet(body=self.pet) 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 165fce2a49d..fca6b39bfa8 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 @@ -3,12 +3,11 @@ 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-04-29T00:20:47.240+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-06-16T10:34:51.577+02:00") public class Category { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java index 8c1bdbf106e..8229b459bd0 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -3,12 +3,11 @@ 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-04-29T00:20:47.240+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-06-16T10:34:51.577+02:00") public class ModelApiResponse { private Integer code = null; 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 f33876b9c65..fe59a870a06 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-29T00:20:47.240+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-06-16T10:34:51.577+02: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 a14c7269931..c56d0930366 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-29T00:20:47.240+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-06-16T10:34:51.577+02:00") public class Pet { private Long id = null; 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 74ec375d7e2..952f4e39d24 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 @@ -3,12 +3,11 @@ 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-04-29T00:20:47.240+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-06-16T10:34:51.577+02: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 f01215a829e..a3e69975601 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 @@ -3,12 +3,11 @@ 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-04-29T00:20:47.240+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-06-16T10:34:51.577+02:00") public class User { private Long id = null; diff --git a/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/Category.java index f76411d073a..67bc75b3b10 100644 --- a/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/Category.java @@ -2,7 +2,6 @@ package io.swagger.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/ModelApiResponse.java index 9c61a7434e7..5e3aa82bbee 100644 --- a/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/ModelApiResponse.java +++ b/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -2,7 +2,6 @@ package io.swagger.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/Tag.java index f203b01f55b..f26d84e74b2 100644 --- a/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/Tag.java @@ -2,7 +2,6 @@ package io.swagger.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/User.java index f239bb3febc..5dc291a7889 100644 --- a/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs/jersey1/src/gen/java/io/swagger/model/User.java @@ -2,7 +2,6 @@ package io.swagger.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty;