diff --git a/README.md b/README.md index f52c4097347c..703adaa70890 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,7 @@ AkkaScalaClientCodegen.java AndroidClientCodegen.java AsyncScalaClientCodegen.java CSharpClientCodegen.java +FlashClientCodegen.java JavaClientCodegen.java JaxRSServerCodegen.java NodeJSServerCodegen.java diff --git a/bin/flash-petstore.sh b/bin/flash-petstore.sh new file mode 100755 index 000000000000..20d75e8a8ac6 --- /dev/null +++ b/bin/flash-petstore.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/flash -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l flash -o samples/client/petstore/flash" + +java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java new file mode 100755 index 000000000000..ca0979fb694d --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java @@ -0,0 +1,367 @@ +package io.swagger.codegen.languages; + +import io.swagger.codegen.CliOption; +import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenType; +import io.swagger.codegen.DefaultCodegen; +import io.swagger.codegen.SupportingFile; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.MapProperty; +import io.swagger.models.properties.Property; +import io.swagger.models.properties.AbstractNumericProperty; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.DateProperty; +import io.swagger.models.properties.DateTimeProperty; +import io.swagger.models.properties.DecimalProperty; +import io.swagger.models.properties.DoubleProperty; +import io.swagger.models.properties.FloatProperty; +import io.swagger.models.properties.IntegerProperty; +import io.swagger.models.properties.LongProperty; +import io.swagger.models.properties.MapProperty; +import io.swagger.models.properties.Property; +import io.swagger.models.properties.PropertyBuilder; +import io.swagger.models.properties.RefProperty; +import io.swagger.models.properties.StringProperty; + +import java.io.File; +import java.util.Arrays; +import java.util.HashSet; +import java.util.HashMap; + +import org.apache.commons.lang.StringUtils; + +public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig { + protected String packageName = "io.swagger"; + protected String packageVersion = null; + + protected String invokerPackage = "io.swagger"; + protected String sourceFolder = "src/main/flex"; + + public FlashClientCodegen() { + super(); + + modelPackage = "io.swagger.client.model"; + apiPackage = "io.swagger.client.api"; + outputFolder = "generated-code" + File.separatorChar + "flash"; + modelTemplateFiles.put("model.mustache", ".as"); + modelTemplateFiles.put("modelList.mustache", "List.as"); + apiTemplateFiles.put("api.mustache", ".as"); + templateDir = "flash"; + + languageSpecificPrimitives.clear(); + languageSpecificPrimitives.add("Number"); + languageSpecificPrimitives.add("Boolean"); + languageSpecificPrimitives.add("String"); + languageSpecificPrimitives.add("Date"); + languageSpecificPrimitives.add("Array"); + languageSpecificPrimitives.add("Dictionary"); + + typeMapping.clear(); + typeMapping.put("integer", "Number"); + typeMapping.put("float", "Number"); + typeMapping.put("long", "Number"); + typeMapping.put("double", "Number"); + typeMapping.put("array", "Array"); + typeMapping.put("map", "Dictionary"); + typeMapping.put("boolean", "Boolean"); + typeMapping.put("string", "String"); + typeMapping.put("date", "Date"); + typeMapping.put("DateTime", "Date"); + typeMapping.put("object", "Object"); + typeMapping.put("file", "File"); + + importMapping = new HashMap(); + importMapping.put("File", "flash.filesystem.File"); + + // from + reservedWords = new HashSet( + Arrays.asList( +"add", "for", "lt", "tellTarget", "and", "function", "ne", "this", "break", "ge", "new", "typeof", "continue", "gt", "not", "var", "delete", "if", "on", "void", "do", "ifFrameLoaded", "onClipEvent", "while", "else", "in", "or", "with", "eq", "le", "return")); + + cliOptions.clear(); + cliOptions.add(new CliOption("packageName", "flash package name (convention: package.name), default: io.swagger")); + cliOptions.add(new CliOption("packageVersion", "flash package version, default: 1.0.0")); + cliOptions.add(new CliOption("invokerPackage", "root package for generated code")); + cliOptions.add(new CliOption("sourceFolder", "source folder for generated code. e.g. src/main/flex")); + + } + + @Override + public void processOpts() { + super.processOpts(); + + if (additionalProperties.containsKey("invokerPackage")) { + this.setInvokerPackage((String) additionalProperties.get("invokerPackage")); + } else { + //not set, use default to be passed to template + additionalProperties.put("invokerPackage", invokerPackage); + } + + if (additionalProperties.containsKey("sourceFolder")) { + this.setSourceFolder((String) additionalProperties.get("sourceFolder")); + } + + if (additionalProperties.containsKey("packageName")) { + setPackageName((String) additionalProperties.get("packageName")); + apiPackage = packageName + ".client.api"; + modelPackage = packageName + ".client.model"; + } + else { + setPackageName("io.swagger"); + } + + if (additionalProperties.containsKey("packageVersion")) { + setPackageVersion((String) additionalProperties.get("packageVersion")); + } + else { + setPackageVersion("1.0.0"); + } + + additionalProperties.put("packageName", packageName); + additionalProperties.put("packageVersion", packageVersion); + + //modelPackage = invokerPackage + File.separatorChar + "client" + File.separatorChar + "model"; + //apiPackage = invokerPackage + File.separatorChar + "client" + File.separatorChar + "api"; + + final String invokerFolder = (sourceFolder + File.separator + invokerPackage + File.separator + "swagger" + File.separator).replace(".", File.separator).replace('.', File.separatorChar); + + supportingFiles.add(new SupportingFile("ApiInvoker.as", invokerFolder + "common", "ApiInvoker.as")); + supportingFiles.add(new SupportingFile("ApiUrlHelper.as", invokerFolder + "common", "ApiUrlHelper.as")); + supportingFiles.add(new SupportingFile("ApiUserCredentials.as", invokerFolder + "common", "ApiUserCredentials.as")); + supportingFiles.add(new SupportingFile("ListWrapper.as", invokerFolder + "common", "ListWrapper.as")); + supportingFiles.add(new SupportingFile("SwaggerApi.as", invokerFolder + "common", "SwaggerApi.as")); + supportingFiles.add(new SupportingFile("XMLWriter.as", invokerFolder + "common", "XMLWriter.as")); + supportingFiles.add(new SupportingFile("ApiError.as", invokerFolder + "exception", "ApiErrors.as")); + supportingFiles.add(new SupportingFile("ApiErrorCodes.as", invokerFolder + "exception", "ApiErrorCodes.as")); + supportingFiles.add(new SupportingFile("ApiClientEvent.as", invokerFolder + "event", "ApiClientEvent.as")); + supportingFiles.add(new SupportingFile("Response.as", invokerFolder + "event", "Response.as")); + supportingFiles.add(new SupportingFile("build.properties", sourceFolder, "build.properties")); + supportingFiles.add(new SupportingFile("build.xml", sourceFolder, "build.xml")); + supportingFiles.add(new SupportingFile("AirExecutorApp-app.xml", sourceFolder + File.separatorChar + "bin", "AirExecutorApp-app.xml")); + supportingFiles.add(new SupportingFile("ASAXB-0.1.1.swc", sourceFolder + File.separatorChar + "lib", "ASAXB-0.1.1.swc")); + supportingFiles.add(new SupportingFile("as3corelib.swc", sourceFolder + File.separatorChar + "lib", "as3corelib.swc")); + supportingFiles.add(new SupportingFile("flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc")); + supportingFiles.add(new SupportingFile("flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc")); + supportingFiles.add(new SupportingFile("flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc")); + supportingFiles.add(new SupportingFile("flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc")); + } + + private static String dropDots(String str) { + return str.replaceAll("\\.", "_"); + } + + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + public String getName() { + return "flash"; + } + + public String getHelp() { + return "Generates a Flash client library."; + } + + @Override + public String escapeReservedWord(String name) { + return name + "_"; + } + + @Override + public String apiFileFolder() { + return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar + apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar); + } + + public String modelFileFolder() { + return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar + modelPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar); + } + + @Override + public String getTypeDeclaration(Property p) { + if (p instanceof ArrayProperty) { + ArrayProperty ap = (ArrayProperty) p; + Property inner = ap.getItems(); + return getSwaggerType(p); + } else if (p instanceof MapProperty) { + MapProperty mp = (MapProperty) p; + Property inner = mp.getAdditionalProperties(); + + return getSwaggerType(p); + } + return super.getTypeDeclaration(p); + } + + @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)) { + return type; + } + } else { + type = toModelName(swaggerType); + } + return type; + } + + public String toDefaultValue(Property p) { + if (p instanceof StringProperty) { + return "null"; + } else if (p instanceof BooleanProperty) { + return "false"; + } else if (p instanceof DateProperty) { + return "null"; + } else if (p instanceof DateTimeProperty) { + return "null"; + } else if (p instanceof DoubleProperty) { + DoubleProperty dp = (DoubleProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + return "0.0"; + } else if (p instanceof FloatProperty) { + FloatProperty dp = (FloatProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + return "0.0"; + } else if (p instanceof IntegerProperty) { + IntegerProperty dp = (IntegerProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + return "0"; + } else if (p instanceof LongProperty) { + LongProperty dp = (LongProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + return "0"; + } else if (p instanceof MapProperty) { + MapProperty ap = (MapProperty) p; + String inner = getSwaggerType(ap.getAdditionalProperties()); + return "new Dictionary()"; + } else if (p instanceof ArrayProperty) { + ArrayProperty ap = (ArrayProperty) p; + String inner = getSwaggerType(ap.getItems()); + return "new Array()"; + } else { + return "null"; + } + } + + @Override + public String toVarName(String name) { + // replace - with _ e.g. created-at => created_at + name = name.replaceAll("-", "_"); + + // if it's all uppper case, convert to lower case + if (name.matches("^[A-Z_]*$")) { + name = name.toLowerCase(); + } + + // underscore the variable name + // petId => pet_id + name = camelize(dropDots(name), true); + + // for reserved word or word starting with number, append _ + if (reservedWords.contains(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(String name) { + // model name cannot use reserved keyword, e.g. return + if (reservedWords.contains(name)) { + throw new RuntimeException(name + " (reserved word) cannot be used as a model name"); + } + + // camelize the model name + // phone_number => PhoneNumber + return camelize(name); + } + + @Override + public String toModelFilename(String name) { + // model name cannot use reserved keyword, e.g. return + if (reservedWords.contains(name)) { + throw new RuntimeException(name + " (reserved word) cannot be used as a model name"); + } + + // underscore the model file name + // PhoneNumber => phone_number + return camelize(dropDots(name)); + } + + @Override + public String toApiFilename(String name) { + // replace - with _ e.g. created-at => created_at + name = name.replaceAll("-", "_"); + + // e.g. PhoneNumberApi.rb => phone_number_api.rb + return camelize(name) + "Api"; + } + + @Override + public String toApiName(String name) { + if (name.length() == 0) { + return "DefaultApi"; + } + // e.g. phone_number_api => PhoneNumberApi + return camelize(name) + "Api"; + } + + @Override + public String toApiVarName(String name) { + if (name.length() == 0) { + return "DefaultApi"; + } + return camelize(name) + "Api"; + } + + @Override + public String toOperationId(String operationId) { + // throw exception if method name is empty + if (StringUtils.isEmpty(operationId)) { + throw new RuntimeException("Empty method name (operationId) not allowed"); + } + + // method name cannot use reserved keyword, e.g. return + if (reservedWords.contains(operationId)) { + throw new RuntimeException(operationId + " (reserved word) cannot be used as method name"); + } + + return underscore(operationId); + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public void setPackageVersion(String packageVersion) { + this.packageVersion = packageVersion; + } + + public void setInvokerPackage(String invokerPackage) { + this.invokerPackage = invokerPackage; + } + + public void setSourceFolder(String sourceFolder) { + this.sourceFolder = sourceFolder; + } + +} + + diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 2e514436747f..e98ac4622301 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -1,6 +1,7 @@ io.swagger.codegen.languages.AndroidClientCodegen io.swagger.codegen.languages.AsyncScalaClientCodegen io.swagger.codegen.languages.CSharpClientCodegen +io.swagger.codegen.languages.FlashClientCodegen io.swagger.codegen.languages.JavaClientCodegen io.swagger.codegen.languages.JaxRSServerCodegen io.swagger.codegen.languages.JavaInflectorServerCodegen diff --git a/modules/swagger-codegen/src/main/resources/flash/api.mustache b/modules/swagger-codegen/src/main/resources/flash/api.mustache index b1f11e92438b..7fa8cb03d0aa 100644 --- a/modules/swagger-codegen/src/main/resources/flash/api.mustache +++ b/modules/swagger-codegen/src/main/resources/flash/api.mustache @@ -56,7 +56,7 @@ public class {{classname}} extends SwaggerApi { {{#headerParams}}headerParams["{{paramName}}"] = toPathValue({{paramName}}); {{/headerParams}} - var token:AsyncToken = getApiInvoker().invokeAPI(path, "{{httpMethod}}", queryParams, {{#bodyParam}}{{bodyParam}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}, headerParams); + var token:AsyncToken = getApiInvoker().invokeAPI(path, "{{httpMethod}}", queryParams, {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}, headerParams); var requestId: String = getUniqueId(); @@ -70,4 +70,4 @@ public class {{classname}} extends SwaggerApi { {{/operation}} } {{/operations}} -} \ No newline at end of file +} diff --git a/modules/swagger-codegen/src/main/resources/flash/model.mustache b/modules/swagger-codegen/src/main/resources/flash/model.mustache index c3369514e80e..a365a99f2cf3 100644 --- a/modules/swagger-codegen/src/main/resources/flash/model.mustache +++ b/modules/swagger-codegen/src/main/resources/flash/model.mustache @@ -7,34 +7,30 @@ package {{package}} { {{#model}} [XmlRootNode(name="{{classname}}")] public class {{classname}} { - {{#vars}} - - {{#description}}/* {{description}} */ - {{/description}} - - {{#isList}} + {{#vars}} + {{#description}}/* {{description}} */ + {{/description}} + {{#isContainer}} // This declaration below of _{{name}}_obj_class is to force flash compiler to include this class private var _{{name}}_obj_class: {{baseType}} = null; - [XmlElementWrapper(name="{{name}}")] - [XmlElements(name="{{nameSingular}}", type="{{baseType}}")] - {{/isList}} - {{#isNotContainer}}[XmlElement(name="{{name}}")] - {{/isNotContainer}} + [XmlElementWrapper(name="{{baseName}}")] + [XmlElements(name="{{name}}", type="{{baseType}}")] + {{/isContainer}} + {{^isContainer}}[XmlElement(name="{{baseName}}")] + {{/isContainer}} public var {{name}}: {{{datatype}}} = {{{defaultValue}}}; - {{/vars}} - public function toString(): String { - var str: String = "{{classname}}: "; - {{#vars}} - str += " ({{name}}: " + {{name}} + ")"; - {{/vars}} - return str; - } - + public function toString(): String { + var str: String = "{{classname}}: "; + {{#vars}} + str += " ({{name}}: " + {{name}} + ")"; + {{/vars}} + return str; + } } {{/model}} - {{/models}} +{{/models}} } diff --git a/samples/client/petstore/flash/FlashPetstoreCodegen.scala b/samples/client/petstore/flash/FlashPetstoreCodegen.scala deleted file mode 100644 index e318765c57e1..000000000000 --- a/samples/client/petstore/flash/FlashPetstoreCodegen.scala +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2014 Wordnik, Inc. - * - * 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. - */ - -object FlashPetstoreCodegen extends BasicFlashCodegen { - def main(args: Array[String]) = generateClient(args) - - override def packageName = "io.swagger.client" - - // where to write generated code - override def destinationDir = destinationRoot + "/src/main/flex" - - override def destinationRoot = "samples/client/petstore/flash" - - // package for models - override def modelPackage = Some("com.wordnik.client.model") - - // package for api classes - override def apiPackage = Some("com.wordnik.client.api") - - // supporting classes - override def supportingFiles = baseSupportingFiles ++ List() -} diff --git a/samples/client/petstore/flash/bin/AirExecutorApp-app.xml b/samples/client/petstore/flash/bin/AirExecutorApp-app.xml deleted file mode 100644 index 1eb5e43c7d70..000000000000 --- a/samples/client/petstore/flash/bin/AirExecutorApp-app.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - AirExecutorApp - - - AirExecutorApp - - - AirExecutorApp - - - v1 - - - - - - - - - - - - - - - AirExecutorApp.swf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/client/petstore/flash/src/main/flex/bin/AirExecutorApp-app.xml b/samples/client/petstore/flash/src/main/flex/bin/AirExecutorApp-app.xml new file mode 100644 index 000000000000..1dbaf98e6443 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/bin/AirExecutorApp-app.xml @@ -0,0 +1,146 @@ + + + + + + + AirExecutorApp + + + AirExecutorApp + + + AirExecutorApp + + + v1 + + + + + + + + + + + + + + + AirExecutorApp.swf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/flash/build.properties b/samples/client/petstore/flash/src/main/flex/build.properties similarity index 100% rename from samples/client/petstore/flash/build.properties rename to samples/client/petstore/flash/src/main/flex/build.properties diff --git a/samples/client/petstore/flash/build.xml b/samples/client/petstore/flash/src/main/flex/build.xml similarity index 89% rename from samples/client/petstore/flash/build.xml rename to samples/client/petstore/flash/src/main/flex/build.xml index 6861dd464ece..4f021b0b8b2a 100644 --- a/samples/client/petstore/flash/build.xml +++ b/samples/client/petstore/flash/src/main/flex/build.xml @@ -62,11 +62,11 @@ - - - - - + + + + + diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/api/PetApi.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/api/PetApi.as deleted file mode 100644 index 88f9b42eaa09..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/api/PetApi.as +++ /dev/null @@ -1,272 +0,0 @@ -package com.wordnik.client.api { - -import com.wordnik.swagger.common.ApiInvoker; -import com.wordnik.swagger.exception.ApiErrorCodes; -import com.wordnik.swagger.exception.ApiError; -import com.wordnik.swagger.common.ApiUserCredentials; -import com.wordnik.swagger.event.Response; -import com.wordnik.swagger.common.SwaggerApi; -import com.wordnik.client.model.Pet; -import com.wordnik.client.model.File; - -import mx.rpc.AsyncToken; -import mx.utils.UIDUtil; - -import flash.utils.Dictionary; -import flash.events.EventDispatcher; - -public class PetApi extends SwaggerApi { - public static const event_getPetById:String = "getPetById"; - public static const event_deletePet:String = "deletePet"; - public static const event_partialUpdate:String = "partialUpdate"; - public static const event_updatePetWithForm:String = "updatePetWithForm"; - public static const event_uploadFile:String = "uploadFile"; - public static const event_addPet:String = "addPet"; - public static const event_updatePet:String = "updatePet"; - public static const event_findPetsByStatus:String = "findPetsByStatus"; - public static const event_findPetsByTags:String = "findPetsByTags"; - - /** - * Constructor for the PetApi api client - * @param apiCredentials Wrapper object for tokens and hostName required towards authentication - * @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response - */ - public function PetApi(apiCredentials:ApiUserCredentials, eventDispatcher:EventDispatcher = null) { - super(apiCredentials, eventDispatcher); - } - /* - * Returns Pet */ - - public function getPetById(petId:Number):String { - // create path and map variables - var path:String = "/pet/{petId}".replace(/{format}/g, "xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId)); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (petId == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "getPetById"; - - token.returnType = Pet; - return requestId; - - } - - /* - * Returns void */ - public function deletePet(petId:String):String { - // create path and map variables - var path:String = "/pet/{petId}".replace(/{format}/g, "xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId)); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (petId == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "DELETE", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "deletePet"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns Array[Pet] */ - public function partialUpdate(petId:String, body:Pet):String { - // create path and map variables - var path:String = "/pet/{petId}".replace(/{format}/g, "xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId)); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (petId == null || body == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "PATCH", queryParams, body, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "partialUpdate"; - - token.returnType = Array[Pet]; - return requestId; - - } - - /* - * Returns void */ - public function updatePetWithForm(petId:String, name:String, status:String):String { - // create path and map variables - var path:String = "/pet/{petId}".replace(/{format}/g, "xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId)); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (petId == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "updatePetWithForm"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns void */ - public function uploadFile(additionalMetadata:String, body:File):String { - // create path and map variables - var path:String = "/pet/uploadImage".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "uploadFile"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns void */ - public function addPet(body:Pet):String { - // create path and map variables - var path:String = "/pet".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (body == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "addPet"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns void */ - public function updatePet(body:Pet):String { - // create path and map variables - var path:String = "/pet".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (body == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "PUT", queryParams, body, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "updatePet"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns Array[Pet] */ - public function findPetsByStatus(status:String = "available"):String { - // create path and map variables - var path:String = "/pet/findByStatus".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (status == null) { - throw new ApiError(400, "missing required params"); - } - if ("null" != String(status)) - queryParams["status"] = toPathValue(status); - var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "findPetsByStatus"; - - token.returnType = Array[Pet]; - return requestId; - - } - - /* - * Returns Array[Pet] */ - public function findPetsByTags(tags:String):String { - // create path and map variables - var path:String = "/pet/findByTags".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (tags == null) { - throw new ApiError(400, "missing required params"); - } - if ("null" != String(tags)) - queryParams["tags"] = toPathValue(tags); - var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "findPetsByTags"; - - token.returnType = Array[Pet]; - return requestId; - - } -} -} diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/api/StoreApi.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/api/StoreApi.as deleted file mode 100644 index cc4bc2c4a136..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/api/StoreApi.as +++ /dev/null @@ -1,109 +0,0 @@ -package com.wordnik.client.api { - -import com.wordnik.swagger.common.ApiInvoker; -import com.wordnik.swagger.exception.ApiErrorCodes; -import com.wordnik.swagger.exception.ApiError; -import com.wordnik.swagger.common.ApiUserCredentials; -import com.wordnik.swagger.event.Response; -import com.wordnik.swagger.common.SwaggerApi; -import com.wordnik.client.model.Order; - -import mx.rpc.AsyncToken; -import mx.utils.UIDUtil; - -import flash.utils.Dictionary; -import flash.events.EventDispatcher; - -public class StoreApi extends SwaggerApi { - public static const event_getOrderById:String = "getOrderById"; - public static const event_deleteOrder:String = "deleteOrder"; - public static const event_placeOrder:String = "placeOrder"; - - /** - * Constructor for the StoreApi api client - * @param apiCredentials Wrapper object for tokens and hostName required towards authentication - * @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response - */ - public function StoreApi(apiCredentials:ApiUserCredentials, eventDispatcher:EventDispatcher = null) { - super(apiCredentials, eventDispatcher); - } - /* - * Returns Order */ - - public function getOrderById(orderId:String):String { - // create path and map variables - var path:String = "/store/order/{orderId}".replace(/{format}/g, "xml").replace("{" + "orderId" + "}", getApiInvoker().escapeString(orderId)); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (orderId == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "getOrderById"; - - token.returnType = Order; - return requestId; - - } - - /* - * Returns void */ - public function deleteOrder(orderId:String):String { - // create path and map variables - var path:String = "/store/order/{orderId}".replace(/{format}/g, "xml").replace("{" + "orderId" + "}", getApiInvoker().escapeString(orderId)); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (orderId == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "DELETE", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "deleteOrder"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns void */ - public function placeOrder(body:Order):String { - // create path and map variables - var path:String = "/store/order".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (body == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "placeOrder"; - - token.returnType = null; - return requestId; - - } -} -} diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/api/UserApi.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/api/UserApi.as deleted file mode 100644 index 1714b4a0381c..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/api/UserApi.as +++ /dev/null @@ -1,244 +0,0 @@ -package com.wordnik.client.api { - -import com.wordnik.swagger.common.ApiInvoker; -import com.wordnik.swagger.exception.ApiErrorCodes; -import com.wordnik.swagger.exception.ApiError; -import com.wordnik.swagger.common.ApiUserCredentials; -import com.wordnik.swagger.event.Response; -import com.wordnik.swagger.common.SwaggerApi; -import com.wordnik.client.model.User; - -import mx.rpc.AsyncToken; -import mx.utils.UIDUtil; - -import flash.utils.Dictionary; -import flash.events.EventDispatcher; - -public class UserApi extends SwaggerApi { - public static const event_updateUser:String = "updateUser"; - public static const event_deleteUser:String = "deleteUser"; - public static const event_getUserByName:String = "getUserByName"; - public static const event_loginUser:String = "loginUser"; - public static const event_logoutUser:String = "logoutUser"; - public static const event_createUser:String = "createUser"; - public static const event_createUsersWithArrayInput:String = "createUsersWithArrayInput"; - public static const event_createUsersWithListInput:String = "createUsersWithListInput"; - - /** - * Constructor for the UserApi api client - * @param apiCredentials Wrapper object for tokens and hostName required towards authentication - * @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response - */ - public function UserApi(apiCredentials:ApiUserCredentials, eventDispatcher:EventDispatcher = null) { - super(apiCredentials, eventDispatcher); - } - /* - * Returns void */ - - public function updateUser(username:String, body:User):String { - // create path and map variables - var path:String = "/user/{username}".replace(/{format}/g, "xml").replace("{" + "username" + "}", getApiInvoker().escapeString(username)); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (username == null || body == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "PUT", queryParams, body, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "updateUser"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns void */ - public function deleteUser(username:String):String { - // create path and map variables - var path:String = "/user/{username}".replace(/{format}/g, "xml").replace("{" + "username" + "}", getApiInvoker().escapeString(username)); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (username == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "DELETE", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "deleteUser"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns User */ - public function getUserByName(username:String):String { - // create path and map variables - var path:String = "/user/{username}".replace(/{format}/g, "xml").replace("{" + "username" + "}", getApiInvoker().escapeString(username)); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (username == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "getUserByName"; - - token.returnType = User; - return requestId; - - } - - /* - * Returns string */ - public function loginUser(username:String, password:String):String { - // create path and map variables - var path:String = "/user/login".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (username == null || password == null) { - throw new ApiError(400, "missing required params"); - } - if ("null" != String(username)) - queryParams["username"] = toPathValue(username); - if ("null" != String(password)) - queryParams["password"] = toPathValue(password); - var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "loginUser"; - - token.returnType = string; - return requestId; - - } - - /* - * Returns void */ - public function logoutUser():String { - // create path and map variables - var path:String = "/user/logout".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "logoutUser"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns void */ - public function createUser(body:User):String { - // create path and map variables - var path:String = "/user".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (body == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "createUser"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns void */ - public function createUsersWithArrayInput(body:Array):String { - // create path and map variables - var path:String = "/user/createWithArray".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (body == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "createUsersWithArrayInput"; - - token.returnType = null; - return requestId; - - } - - /* - * Returns void */ - public function createUsersWithListInput(body:Array):String { - // create path and map variables - var path:String = "/user/createWithList".replace(/{format}/g, "xml"); - - // query params - var queryParams:Dictionary = new Dictionary(); - var headerParams:Dictionary = new Dictionary(); - - // verify required params are set - if (body == null) { - throw new ApiError(400, "missing required params"); - } - var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); - - var requestId:String = getUniqueId(); - - token.requestId = requestId; - token.completionEventType = "createUsersWithListInput"; - - token.returnType = null; - return requestId; - - } -} -} diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Category.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Category.as deleted file mode 100644 index e20d3701cf72..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Category.as +++ /dev/null @@ -1,21 +0,0 @@ -package com.wordnik.client.model { - -[XmlRootNode(name="Category")] -public class Category { - [XmlElement(name="id")] - public var id:Number = 0.0; - - [XmlElement(name="name")] - public var name:String = null; - - public function toString():String { - var str:String = "Category: "; - str += " (id: " + id + ")"; - str += " (name: " + name + ")"; - return str; - } - - -} -} - diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/CategoryList.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/CategoryList.as deleted file mode 100644 index 48b18dbe1f46..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/CategoryList.as +++ /dev/null @@ -1,17 +0,0 @@ -package com.wordnik.client.model { - -import com.wordnik.swagger.common.ListWrapper; - -public class CategoryList implements ListWrapper { - // This declaration below of _Category_obj_class is to force flash compiler to include this class - [XmlElements(name="category", type="com.wordnik.client.model.Category")] - public var category:Array = new Array(); - private var _category_obj_class:com.wordnik.client.model.Category = null; - - public function getList():Array { - return category; - } - -} -} - diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Order.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Order.as deleted file mode 100644 index 5147a428ba5c..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Order.as +++ /dev/null @@ -1,34 +0,0 @@ -package com.wordnik.client.model { - -[XmlRootNode(name="Order")] -public class Order { - [XmlElement(name="id")] - public var id:Number = 0.0; - - [XmlElement(name="petId")] - public var petId:Number = 0.0; - - [XmlElement(name="quantity")] - public var quantity:Number = 0.0; - - /* Order Status */ - [XmlElement(name="status")] - public var status:String = null; - - [XmlElement(name="shipDate")] - public var shipDate:Date = null; - - public function toString():String { - var str:String = "Order: "; - str += " (id: " + id + ")"; - str += " (petId: " + petId + ")"; - str += " (quantity: " + quantity + ")"; - str += " (status: " + status + ")"; - str += " (shipDate: " + shipDate + ")"; - return str; - } - - -} -} - diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/OrderList.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/OrderList.as deleted file mode 100644 index 56825295dd87..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/OrderList.as +++ /dev/null @@ -1,17 +0,0 @@ -package com.wordnik.client.model { - -import com.wordnik.swagger.common.ListWrapper; - -public class OrderList implements ListWrapper { - // This declaration below of _Order_obj_class is to force flash compiler to include this class - [XmlElements(name="order", type="com.wordnik.client.model.Order")] - public var order:Array = new Array(); - private var _order_obj_class:com.wordnik.client.model.Order = null; - - public function getList():Array { - return order; - } - -} -} - diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Pet.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Pet.as deleted file mode 100644 index 4a19692e9f17..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Pet.as +++ /dev/null @@ -1,48 +0,0 @@ -package com.wordnik.client.model { - -import com.wordnik.client.model.Category; -import com.wordnik.client.model.Tag; - -[XmlRootNode(name="Pet")] -public class Pet { - /* unique identifier for the pet */ - [XmlElement(name="id")] - public var id:Number = 0.0; - - [XmlElement(name="category")] - public var category:Category = null; - - [XmlElement(name="name")] - public var name:String = null; - - // This declaration below of _photoUrls_obj_class is to force flash compiler to include this class - [XmlElementWrapper(name="photoUrls")] - [XmlElements(name="photoUrl", type="com.wordnik.client.model.String")] - public var photoUrls:Array = new Array(); - [XmlElementWrapper(name="tags")] - [XmlElements(name="tag", type="com.wordnik.client.model.Tag")] - public var tags:Array = new Array(); - - // This declaration below of _tags_obj_class is to force flash compiler to include this class - [XmlElement(name="status")] - public var status:String = null; - private var _photoUrls_obj_class:com.wordnik.client.model.String = null; - - /* pet status in the store */ - private var _tags_obj_class:com.wordnik.client.model.Tag = null; - - public function toString():String { - var str:String = "Pet: "; - str += " (id: " + id + ")"; - str += " (category: " + category + ")"; - str += " (name: " + name + ")"; - str += " (photoUrls: " + photoUrls + ")"; - str += " (tags: " + tags + ")"; - str += " (status: " + status + ")"; - return str; - } - - -} -} - diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/PetList.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/PetList.as deleted file mode 100644 index 61b4070a543d..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/PetList.as +++ /dev/null @@ -1,19 +0,0 @@ -package com.wordnik.client.model { - -import com.wordnik.swagger.common.ListWrapper; -import com.wordnik.client.model.Category; -import com.wordnik.client.model.Tag; - -public class PetList implements ListWrapper { - // This declaration below of _Pet_obj_class is to force flash compiler to include this class - [XmlElements(name="pet", type="com.wordnik.client.model.Pet")] - public var pet:Array = new Array(); - private var _pet_obj_class:com.wordnik.client.model.Pet = null; - - public function getList():Array { - return pet; - } - -} -} - diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Tag.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Tag.as deleted file mode 100644 index 07f1f8dd9f38..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/Tag.as +++ /dev/null @@ -1,21 +0,0 @@ -package com.wordnik.client.model { - -[XmlRootNode(name="Tag")] -public class Tag { - [XmlElement(name="id")] - public var id:Number = 0.0; - - [XmlElement(name="name")] - public var name:String = null; - - public function toString():String { - var str:String = "Tag: "; - str += " (id: " + id + ")"; - str += " (name: " + name + ")"; - return str; - } - - -} -} - diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/TagList.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/TagList.as deleted file mode 100644 index 92a9f7d71b19..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/TagList.as +++ /dev/null @@ -1,17 +0,0 @@ -package com.wordnik.client.model { - -import com.wordnik.swagger.common.ListWrapper; - -public class TagList implements ListWrapper { - // This declaration below of _Tag_obj_class is to force flash compiler to include this class - [XmlElements(name="tag", type="com.wordnik.client.model.Tag")] - public var tag:Array = new Array(); - private var _tag_obj_class:com.wordnik.client.model.Tag = null; - - public function getList():Array { - return tag; - } - -} -} - diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/User.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/User.as deleted file mode 100644 index d5227f9d28eb..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/User.as +++ /dev/null @@ -1,46 +0,0 @@ -package com.wordnik.client.model { - -[XmlRootNode(name="User")] -public class User { - [XmlElement(name="id")] - public var id:Number = 0.0; - - [XmlElement(name="firstName")] - public var firstName:String = null; - - [XmlElement(name="username")] - public var username:String = null; - - [XmlElement(name="lastName")] - public var lastName:String = null; - - [XmlElement(name="email")] - public var email:String = null; - - [XmlElement(name="password")] - public var password:String = null; - - [XmlElement(name="phone")] - public var phone:String = null; - - /* User Status */ - [XmlElement(name="userStatus")] - public var userStatus:Number = 0.0; - - public function toString():String { - var str:String = "User: "; - str += " (id: " + id + ")"; - str += " (firstName: " + firstName + ")"; - str += " (username: " + username + ")"; - str += " (lastName: " + lastName + ")"; - str += " (email: " + email + ")"; - str += " (password: " + password + ")"; - str += " (phone: " + phone + ")"; - str += " (userStatus: " + userStatus + ")"; - return str; - } - - -} -} - diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/UserList.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/UserList.as deleted file mode 100644 index fdaab68ac238..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/client/model/UserList.as +++ /dev/null @@ -1,17 +0,0 @@ -package com.wordnik.client.model { - -import com.wordnik.swagger.common.ListWrapper; - -public class UserList implements ListWrapper { - // This declaration below of _User_obj_class is to force flash compiler to include this class - [XmlElements(name="user", type="com.wordnik.client.model.User")] - public var user:Array = new Array(); - private var _user_obj_class:com.wordnik.client.model.User = null; - - public function getList():Array { - return user; - } - -} -} - diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ListWrapper.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ListWrapper.as deleted file mode 100644 index 1dc8ef029fa9..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ListWrapper.as +++ /dev/null @@ -1,7 +0,0 @@ -package com.wordnik.swagger.common { -public interface ListWrapper { - - function getList():Array; - -} -} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/SwaggerApi.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/SwaggerApi.as deleted file mode 100644 index af58870d1791..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/SwaggerApi.as +++ /dev/null @@ -1,70 +0,0 @@ -package com.wordnik.swagger.common { -import com.wordnik.swagger.common.ApiUserCredentials; - -import flash.events.EventDispatcher; -import flash.events.IEventDispatcher; - -import mx.utils.UIDUtil; - -public class SwaggerApi extends EventDispatcher { - - /** - * Method for returning the path value - * For a string value an empty value is returned if the value is null - * @param value - * @return - */ - protected static function toPathValue(value:Object):String { - if (value is Array) { - return arrayToPathValue(value as Array); - } - return value == null ? "" : value.toString(); - } - - /** - * Method for returning a path value - * For a list of objects a comma separated string is returned - * @param objects - * @return - */ - protected static function arrayToPathValue(objects:Array):String { - var out:String = ""; - - return objects.join(","); - } - - /** - * Constructor for the api client - * @param apiCredentials Wrapper object for tokens and hostName required towards authentication - * @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response - */ - public function SwaggerApi(apiCredentials:ApiUserCredentials, eventDispatcher:EventDispatcher = null) { - super(); - _apiUsageCredentials = apiCredentials; - _apiEventNotifier = eventDispatcher; - } - protected var _apiUsageCredentials:ApiUserCredentials; - protected var _apiEventNotifier:EventDispatcher; - protected var _apiInvoker:ApiInvoker; - protected var _useProxyServer:Boolean = false; - - public function useProxyServer(value:Boolean, proxyServerUrl:String = null):void { - _useProxyServer = value; - } - - protected function getApiInvoker():ApiInvoker { - if (_apiInvoker == null) { - if (_apiEventNotifier == null) { - _apiEventNotifier = this; - } - _apiInvoker = new ApiInvoker(_apiUsageCredentials, _apiEventNotifier, _useProxyServer); - } - return _apiInvoker; - } - - protected function getUniqueId():String { - return UIDUtil.createUID(); - } - -} -} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/XMLWriter.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/XMLWriter.as deleted file mode 100644 index 9b575262a312..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/XMLWriter.as +++ /dev/null @@ -1,24 +0,0 @@ -package com.wordnik.swagger.common { -public class XMLWriter { - public function XMLWriter() { - xml = ; - } - public var xml:XML; - - public function reset():void { - xml = new XML(); - } - - public function addProperty(propertyName:String, propertyValue:String):XML { - var xmlProperty:XML = - xmlProperty.setName(propertyName); - xmlProperty.appendChild(propertyValue); - xml.appendChild(xmlProperty); - return xmlProperty; - } - - public function addAttribute(propertyName:String, attribute:String, attributeValue:String):void { - xml.elements(propertyName)[0].@[attribute] = attributeValue; - } -} -} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/exception/ApiError.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/exception/ApiError.as deleted file mode 100644 index 8f473a0cbf99..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/exception/ApiError.as +++ /dev/null @@ -1,7 +0,0 @@ -package com.wordnik.swagger.exception { -public class ApiError extends Error { - public function ApiError(id:* = 0, message:* = "") { - super(message, id); - } -} -} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/exception/ApiErrorCodes.as b/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/exception/ApiErrorCodes.as deleted file mode 100644 index 7abb7642f8e0..000000000000 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/exception/ApiErrorCodes.as +++ /dev/null @@ -1,32 +0,0 @@ -package com.wordnik.swagger.exception { -public class ApiErrorCodes { - /** - * System exception. - */ - public static const SYSTEM_EXCEPTION:Number = 0; - - /** - * With Arguments as current key. - */ - public static const API_KEY_NOT_VALID:Number = 1000; - /** - * With arguments as current token value - */ - public static const AUTH_TOKEN_NOT_VALID:Number = 1001; - /** - * With arguments as input JSON and output class anme - */ - public static const ERROR_CONVERTING_JSON_TO_JAVA:Number = 1002; - /** - * With arguments as JAVA class name - */ - public static const ERROR_CONVERTING_JAVA_TO_JSON:Number = 1003; - - public static const ERROR_FROM_WEBSERVICE_CALL:Number = 1004; - /** - * With arguments as current API server name - */ - public static const API_SERVER_NOT_VALID:Number = 1005; - -} -} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/PetApi.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/PetApi.as new file mode 100644 index 000000000000..edd1298600f7 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/PetApi.as @@ -0,0 +1,276 @@ +package io.swagger.client.api { + +import io.swagger.common.ApiInvoker; +import io.swagger.exception.ApiErrorCodes; +import io.swagger.exception.ApiError; +import io.swagger.common.ApiUserCredentials; +import io.swagger.event.Response; +import io.swagger.common.SwaggerApi; +import io.swagger.client.model.Pet; +import flash.filesystem.File; + +import mx.rpc.AsyncToken; +import mx.utils.UIDUtil; +import flash.utils.Dictionary; +import flash.events.EventDispatcher; + +public class PetApi extends SwaggerApi { + /** + * Constructor for the PetApi api client + * @param apiCredentials Wrapper object for tokens and hostName required towards authentication + * @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response + */ + public function PetApi(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) { + super(apiCredentials, eventDispatcher); + } + + public static const event_update_pet: String = "update_pet"; + public static const event_add_pet: String = "add_pet"; + public static const event_find_pets_by_status: String = "find_pets_by_status"; + public static const event_find_pets_by_tags: String = "find_pets_by_tags"; + public static const event_get_pet_by_id: String = "get_pet_by_id"; + public static const event_update_pet_with_form: String = "update_pet_with_form"; + public static const event_delete_pet: String = "delete_pet"; + public static const event_upload_file: String = "upload_file"; + + + /* + * Returns void + */ + public function update_pet (body: Pet): String { + // create path and map variables + var path: String = "/pet".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "PUT", queryParams, body, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "update_pet"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns void + */ + public function add_pet (body: Pet): String { + // create path and map variables + var path: String = "/pet".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "add_pet"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns Array + */ + public function find_pets_by_status (status: Array = available): String { + // create path and map variables + var path: String = "/pet/findByStatus".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + if("null" != String(status)) + queryParams["status"] = toPathValue(status); + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "find_pets_by_status"; + + token.returnType = Array; + return requestId; + + } + + /* + * Returns Array + */ + public function find_pets_by_tags (tags: Array): String { + // create path and map variables + var path: String = "/pet/findByTags".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + if("null" != String(tags)) + queryParams["tags"] = toPathValue(tags); + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "find_pets_by_tags"; + + token.returnType = Array; + return requestId; + + } + + /* + * Returns Pet + */ + public function get_pet_by_id (petId: Number): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "get_pet_by_id"; + + token.returnType = Pet; + return requestId; + + } + + /* + * Returns void + */ + public function update_pet_with_form (petId: String, name: String, status: String): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "update_pet_with_form"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns void + */ + public function delete_pet (petId: Number, apiKey: String): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + headerParams["apiKey"] = toPathValue(apiKey); + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "DELETE", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "delete_pet"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns void + */ + public function upload_file (petId: Number, additionalMetadata: String, file: File): String { + // create path and map variables + var path: String = "/pet/{petId}/uploadImage".replace(/{format}/g,"xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "upload_file"; + + token.returnType = null ; + return requestId; + + } + +} + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/StoreApi.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/StoreApi.as new file mode 100644 index 000000000000..061878ad257c --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/StoreApi.as @@ -0,0 +1,150 @@ +package io.swagger.client.api { + +import io.swagger.common.ApiInvoker; +import io.swagger.exception.ApiErrorCodes; +import io.swagger.exception.ApiError; +import io.swagger.common.ApiUserCredentials; +import io.swagger.event.Response; +import io.swagger.common.SwaggerApi; +import io.swagger.client.model.Order; + +import mx.rpc.AsyncToken; +import mx.utils.UIDUtil; +import flash.utils.Dictionary; +import flash.events.EventDispatcher; + +public class StoreApi extends SwaggerApi { + /** + * Constructor for the StoreApi api client + * @param apiCredentials Wrapper object for tokens and hostName required towards authentication + * @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response + */ + public function StoreApi(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) { + super(apiCredentials, eventDispatcher); + } + + public static const event_get_inventory: String = "get_inventory"; + public static const event_place_order: String = "place_order"; + public static const event_get_order_by_id: String = "get_order_by_id"; + public static const event_delete_order: String = "delete_order"; + + + /* + * Returns Dictionary + */ + public function get_inventory (): String { + // create path and map variables + var path: String = "/store/inventory".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "get_inventory"; + + token.returnType = Dictionary; + return requestId; + + } + + /* + * Returns Order + */ + public function place_order (body: Order): String { + // create path and map variables + var path: String = "/store/order".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "place_order"; + + token.returnType = Order; + return requestId; + + } + + /* + * Returns Order + */ + public function get_order_by_id (orderId: String): String { + // create path and map variables + var path: String = "/store/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "orderId" + "}", getApiInvoker().escapeString(orderId)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "get_order_by_id"; + + token.returnType = Order; + return requestId; + + } + + /* + * Returns void + */ + public function delete_order (orderId: String): String { + // create path and map variables + var path: String = "/store/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "orderId" + "}", getApiInvoker().escapeString(orderId)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "DELETE", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "delete_order"; + + token.returnType = null ; + return requestId; + + } + +} + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/UserApi.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/UserApi.as new file mode 100644 index 000000000000..06b0d079799c --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/UserApi.as @@ -0,0 +1,274 @@ +package io.swagger.client.api { + +import io.swagger.common.ApiInvoker; +import io.swagger.exception.ApiErrorCodes; +import io.swagger.exception.ApiError; +import io.swagger.common.ApiUserCredentials; +import io.swagger.event.Response; +import io.swagger.common.SwaggerApi; +import io.swagger.client.model.User; + +import mx.rpc.AsyncToken; +import mx.utils.UIDUtil; +import flash.utils.Dictionary; +import flash.events.EventDispatcher; + +public class UserApi extends SwaggerApi { + /** + * Constructor for the UserApi api client + * @param apiCredentials Wrapper object for tokens and hostName required towards authentication + * @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response + */ + public function UserApi(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) { + super(apiCredentials, eventDispatcher); + } + + public static const event_create_user: String = "create_user"; + public static const event_create_users_with_array_input: String = "create_users_with_array_input"; + public static const event_create_users_with_list_input: String = "create_users_with_list_input"; + public static const event_login_user: String = "login_user"; + public static const event_logout_user: String = "logout_user"; + public static const event_get_user_by_name: String = "get_user_by_name"; + public static const event_update_user: String = "update_user"; + public static const event_delete_user: String = "delete_user"; + + + /* + * Returns void + */ + public function create_user (body: User): String { + // create path and map variables + var path: String = "/user".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "create_user"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns void + */ + public function create_users_with_array_input (body: Array): String { + // create path and map variables + var path: String = "/user/createWithArray".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "create_users_with_array_input"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns void + */ + public function create_users_with_list_input (body: Array): String { + // create path and map variables + var path: String = "/user/createWithList".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "create_users_with_list_input"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns String + */ + public function login_user (username: String, password: String): String { + // create path and map variables + var path: String = "/user/login".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + if("null" != String(username)) + queryParams["username"] = toPathValue(username); + if("null" != String(password)) + queryParams["password"] = toPathValue(password); + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "login_user"; + + token.returnType = String; + return requestId; + + } + + /* + * Returns void + */ + public function logout_user (): String { + // create path and map variables + var path: String = "/user/logout".replace(/{format}/g,"xml"); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "logout_user"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns User + */ + public function get_user_by_name (username: String): String { + // create path and map variables + var path: String = "/user/{username}".replace(/{format}/g,"xml").replace("{" + "username" + "}", getApiInvoker().escapeString(username)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "get_user_by_name"; + + token.returnType = User; + return requestId; + + } + + /* + * Returns void + */ + public function update_user (username: String, body: User): String { + // create path and map variables + var path: String = "/user/{username}".replace(/{format}/g,"xml").replace("{" + "username" + "}", getApiInvoker().escapeString(username)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "PUT", queryParams, body, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "update_user"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns void + */ + public function delete_user (username: String): String { + // create path and map variables + var path: String = "/user/{username}".replace(/{format}/g,"xml").replace("{" + "username" + "}", getApiInvoker().escapeString(username)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + + + var token:AsyncToken = getApiInvoker().invokeAPI(path, "DELETE", queryParams, null, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "delete_user"; + + token.returnType = null ; + return requestId; + + } + +} + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Category.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Category.as new file mode 100644 index 000000000000..6aa73414387c --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Category.as @@ -0,0 +1,32 @@ +package io.swagger.client.model { + + + [XmlRootNode(name="Category")] + public class Category { + + + + [XmlElement(name="id")] + + public var id: Number = 0; + + + + [XmlElement(name="name")] + + public var name: String = null; + + + public function toString(): String { + var str: String = "Category: "; + + str += " (id: " + id + ")"; + + str += " (name: " + name + ")"; + + return str; + } + +} + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/CategoryList.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/CategoryList.as new file mode 100644 index 000000000000..342cd70c0013 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/CategoryList.as @@ -0,0 +1,18 @@ +package io.swagger.client.model { + +import io.swagger.common.ListWrapper; + + public class CategoryList implements ListWrapper { + // This declaration below of _Category_obj_class is to force flash compiler to include this class + private var _category_obj_class: io.swagger.client.model.Category = null; + [XmlElements(name="category", type="io.swagger.client.model.Category")] + public var category: Array = new Array(); + + public function getList(): Array{ + return category; + } + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Order.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Order.as new file mode 100644 index 000000000000..d6e4e6dc4d78 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Order.as @@ -0,0 +1,65 @@ +package io.swagger.client.model { + + + [XmlRootNode(name="Order")] + public class Order { + + + + [XmlElement(name="id")] + + public var id: Number = 0; + + + + [XmlElement(name="petId")] + + public var petId: Number = 0; + + + + [XmlElement(name="quantity")] + + public var quantity: Number = 0; + + + + [XmlElement(name="shipDate")] + + public var shipDate: Date = null; + + /* Order Status */ + + + [XmlElement(name="status")] + + public var status: String = null; + + + + [XmlElement(name="complete")] + + public var complete: Boolean = false; + + + public function toString(): String { + var str: String = "Order: "; + + str += " (id: " + id + ")"; + + str += " (petId: " + petId + ")"; + + str += " (quantity: " + quantity + ")"; + + str += " (shipDate: " + shipDate + ")"; + + str += " (status: " + status + ")"; + + str += " (complete: " + complete + ")"; + + return str; + } + +} + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/OrderList.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/OrderList.as new file mode 100644 index 000000000000..bba3d8a47243 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/OrderList.as @@ -0,0 +1,18 @@ +package io.swagger.client.model { + +import io.swagger.common.ListWrapper; + + public class OrderList implements ListWrapper { + // This declaration below of _Order_obj_class is to force flash compiler to include this class + private var _order_obj_class: io.swagger.client.model.Order = null; + [XmlElements(name="order", type="io.swagger.client.model.Order")] + public var order: Array = new Array(); + + public function getList(): Array{ + return order; + } + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Pet.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Pet.as new file mode 100644 index 000000000000..81b29d91e4cb --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Pet.as @@ -0,0 +1,75 @@ +package io.swagger.client.model { + +import io.swagger.client.model.Category; +import io.swagger.client.model.Tag; + + [XmlRootNode(name="Pet")] + public class Pet { + + + + [XmlElement(name="id")] + + public var id: Number = 0; + + + + [XmlElement(name="category")] + + public var category: Category = null; + + + + [XmlElement(name="name")] + + public var name: String = null; + + + + // This declaration below of _photoUrls_obj_class is to force flash compiler to include this class + private var _photoUrls_obj_class: Array = null; + [XmlElementWrapper(name="photoUrls")] + [XmlElements(name="photoUrls", type="Array")] + + + public var photoUrls: Array = new Array(); + + + + // This declaration below of _tags_obj_class is to force flash compiler to include this class + private var _tags_obj_class: Array = null; + [XmlElementWrapper(name="tags")] + [XmlElements(name="tags", type="Array")] + + + public var tags: Array = new Array(); + + /* pet status in the store */ + + + [XmlElement(name="status")] + + public var status: String = null; + + + public function toString(): String { + var str: String = "Pet: "; + + str += " (id: " + id + ")"; + + str += " (category: " + category + ")"; + + str += " (name: " + name + ")"; + + str += " (photoUrls: " + photoUrls + ")"; + + str += " (tags: " + tags + ")"; + + str += " (status: " + status + ")"; + + return str; + } + +} + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/PetList.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/PetList.as new file mode 100644 index 000000000000..ada0846c5ea8 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/PetList.as @@ -0,0 +1,20 @@ +package io.swagger.client.model { + +import io.swagger.common.ListWrapper; +import io.swagger.client.model.Category; +import io.swagger.client.model.Tag; + + public class PetList implements ListWrapper { + // This declaration below of _Pet_obj_class is to force flash compiler to include this class + private var _pet_obj_class: io.swagger.client.model.Pet = null; + [XmlElements(name="pet", type="io.swagger.client.model.Pet")] + public var pet: Array = new Array(); + + public function getList(): Array{ + return pet; + } + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Tag.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Tag.as new file mode 100644 index 000000000000..7387e2e27455 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Tag.as @@ -0,0 +1,32 @@ +package io.swagger.client.model { + + + [XmlRootNode(name="Tag")] + public class Tag { + + + + [XmlElement(name="id")] + + public var id: Number = 0; + + + + [XmlElement(name="name")] + + public var name: String = null; + + + public function toString(): String { + var str: String = "Tag: "; + + str += " (id: " + id + ")"; + + str += " (name: " + name + ")"; + + return str; + } + +} + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/TagList.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/TagList.as new file mode 100644 index 000000000000..25ebadb27fb7 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/TagList.as @@ -0,0 +1,18 @@ +package io.swagger.client.model { + +import io.swagger.common.ListWrapper; + + public class TagList implements ListWrapper { + // This declaration below of _Tag_obj_class is to force flash compiler to include this class + private var _tag_obj_class: io.swagger.client.model.Tag = null; + [XmlElements(name="tag", type="io.swagger.client.model.Tag")] + public var tag: Array = new Array(); + + public function getList(): Array{ + return tag; + } + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/User.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/User.as new file mode 100644 index 000000000000..2b6474de90c0 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/User.as @@ -0,0 +1,81 @@ +package io.swagger.client.model { + + + [XmlRootNode(name="User")] + public class User { + + + + [XmlElement(name="id")] + + public var id: Number = 0; + + + + [XmlElement(name="username")] + + public var username: String = null; + + + + [XmlElement(name="firstName")] + + public var firstName: String = null; + + + + [XmlElement(name="lastName")] + + public var lastName: String = null; + + + + [XmlElement(name="email")] + + public var email: String = null; + + + + [XmlElement(name="password")] + + public var password: String = null; + + + + [XmlElement(name="phone")] + + public var phone: String = null; + + /* User Status */ + + + [XmlElement(name="userStatus")] + + public var userStatus: Number = 0; + + + public function toString(): String { + var str: String = "User: "; + + str += " (id: " + id + ")"; + + str += " (username: " + username + ")"; + + str += " (firstName: " + firstName + ")"; + + str += " (lastName: " + lastName + ")"; + + str += " (email: " + email + ")"; + + str += " (password: " + password + ")"; + + str += " (phone: " + phone + ")"; + + str += " (userStatus: " + userStatus + ")"; + + return str; + } + +} + +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/UserList.as b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/UserList.as new file mode 100644 index 000000000000..e8a1fdb27f69 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/UserList.as @@ -0,0 +1,18 @@ +package io.swagger.client.model { + +import io.swagger.common.ListWrapper; + + public class UserList implements ListWrapper { + // This declaration below of _User_obj_class is to force flash compiler to include this class + private var _user_obj_class: io.swagger.client.model.User = null; + [XmlElements(name="user", type="io.swagger.client.model.User")] + public var user: Array = new Array(); + + public function getList(): Array{ + return user; + } + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ApiInvoker.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiInvoker.as similarity index 93% rename from samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ApiInvoker.as rename to samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiInvoker.as index 89fd394d2e92..98d94052ec43 100644 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ApiInvoker.as +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiInvoker.as @@ -1,27 +1,6 @@ -package com.wordnik.swagger.common { -import asaxb.xml.bind.ASAXBContext; -import asaxb.xml.bind.Unmarshaller; - -import com.wordnik.swagger.event.ApiClientEvent; -import com.wordnik.swagger.event.Response; -import com.wordnik.swagger.common.ApiUserCredentials; - -import flash.events.EventDispatcher; -import flash.utils.Dictionary; -import flash.utils.describeType; -import flash.xml.XMLDocument; -import flash.xml.XMLNode; - -import mx.messaging.ChannelSet; -import mx.messaging.channels.HTTPChannel; -import mx.messaging.messages.HTTPRequestMessage; -import mx.rpc.AsyncToken; -import mx.rpc.events.FaultEvent; -import mx.rpc.events.ResultEvent; -import mx.rpc.http.HTTPService; -import mx.rpc.xml.SimpleXMLEncoder; -import mx.utils.ObjectUtil; - +package io.swagger.common { +import io.swagger.event.ApiClientEvent; +import io.swagger.event.Response; public class ApiInvoker extends EventDispatcher { diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ApiUrlHelper.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUrlHelper.as similarity index 74% rename from samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ApiUrlHelper.as rename to samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUrlHelper.as index 0fc7e1821b18..4333c6c7e4ca 100644 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ApiUrlHelper.as +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUrlHelper.as @@ -1,5 +1,5 @@ -package com.wordnik.swagger.common { -import com.wordnik.swagger.common.ApiUserCredentials; +package io.swagger.common { +import io.swagger.common.ApiUserCredentials; /** * @private @@ -12,17 +12,17 @@ internal class ApiUrlHelper { private static const HTTP_URL_PREFIX:String = "http://"; - internal static function appendTokenInfo(restUrl:String, requestHeader:Object, credentials:ApiUserCredentials):String { + internal static function appendTokenInfo(restUrl:String, requestHeader: Object, credentials: ApiUserCredentials): String { //checks for the presence api credentials on client initialization and not repeated here - if (restUrl.indexOf("?") == -1) { + if(restUrl.indexOf("?") == -1){ restUrl += ( "?" + API_URL_KEY + "=" + credentials.apiToken ); } - else { + else{ restUrl += ( "&" + API_URL_KEY + "=" + credentials.apiToken ); } requestHeader.api_key = credentials.apiToken; - if (credentials.authToken != null && credentials.authToken != "") { + if(credentials.authToken != null && credentials.authToken != ""){ restUrl += ( "&" + AUTH_TOKEN_URL_KEY + "=" + credentials.authToken ); requestHeader.auth_token = credentials.authToken; } @@ -30,7 +30,7 @@ internal class ApiUrlHelper { return restUrl; } - internal static function getProxyUrl(hostName:String, proxyPath:String):String { + internal static function getProxyUrl(hostName: String, proxyPath: String): String{ if (hostName(hostName.length - 1) == "/") //remove trailing slash { hostName = hostName.substring(0, hostName.length - 1); diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ApiUserCredentials.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUserCredentials.as similarity index 53% rename from samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ApiUserCredentials.as rename to samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUserCredentials.as index 3b0e38e6ccc6..118d917a2470 100644 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/common/ApiUserCredentials.as +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUserCredentials.as @@ -1,28 +1,10 @@ -package com.wordnik.swagger.common { +package io.swagger.common { /** * Api account credentials. * */ public class ApiUserCredentials { - /** - * Constructor of ApiUserCredentials - * @param apiToken An apitoken that is passed along with the requests - * @param authToken A valid auth_token which could necessary for certain operations - * @param hostName The host name for the Rest API eg. api.companyName.com - * @param userId The userId which is required for certain operations - currently, get user lists - */ - public function ApiUserCredentials(hostName:String, apiPath:String, apiToken:String, - authToken:String = null, userId:Number = -1, apiProxyServerUrl:String = "", - proxyPath:String = null) { - this.hostName = hostName; - this.apiToken = apiToken; - this.authToken = authToken; - this.userId = userId; - this.apiPath = apiPath; - this.apiProxyServerUrl = apiProxyServerUrl; - this.proxyPath = proxyPath; - } /** * An apitoken that is passed along with the requests */ @@ -39,21 +21,43 @@ public class ApiUserCredentials { * The host name for the Rest API eg. api.companyName.com */ public var hostName:String; + + /** + * The base path to the api resources - used along with the hostname + * eg. /v4 + */ + public var apiPath: String; + + /** + * The base path to the blazeds proxy + * eg. /v4/messagebroker/restproxy + */ + public var proxyPath: String; + + /** + * If a proxy server has been set up for the services specify the URL here. This value is used when the Api is invoked with + * the value useProxy as true + */ + public var apiProxyServerUrl: String; + /** - * The base path to the api resources - used along with the hostname - * eg. /v4 + * Constructor of ApiUserCredentials + * @param apiToken An apitoken that is passed along with the requests + * @param authToken A valid auth_token which could necessary for certain operations + * @param hostName The host name for the Rest API eg. api.companyName.com + * @param userId The userId which is required for certain operations - currently, get user lists */ - public var apiPath:String; - /** - * The base path to the blazeds proxy - * eg. /v4/messagebroker/restproxy - */ - public var proxyPath:String; - /** - * If a proxy server has been set up for the services specify the URL here. This value is used when the Api is invoked with - * the value useProxy as true - */ - public var apiProxyServerUrl:String; + public function ApiUserCredentials(hostName: String, apiPath: String, apiToken: String, + authToken: String = null, userId: Number = -1, apiProxyServerUrl: String="", + proxyPath: String = null) { + this.hostName = hostName; + this.apiToken = apiToken; + this.authToken = authToken; + this.userId = userId; + this.apiPath = apiPath; + this.apiProxyServerUrl = apiProxyServerUrl; + this.proxyPath = proxyPath; + } } } \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ListWrapper.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ListWrapper.as new file mode 100644 index 000000000000..b22890ad1d1d --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ListWrapper.as @@ -0,0 +1,9 @@ +package io.swagger.common +{ + public interface ListWrapper + { + + function getList(): Array; + + } +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/SwaggerApi.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/SwaggerApi.as new file mode 100644 index 000000000000..059de642a748 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/SwaggerApi.as @@ -0,0 +1,75 @@ +package io.swagger.common +{ + import io.swagger.common.ApiUserCredentials; + + import flash.events.EventDispatcher; + import flash.events.IEventDispatcher; + + import mx.utils.UIDUtil; + + public class SwaggerApi extends EventDispatcher + { + + protected var _apiUsageCredentials:ApiUserCredentials; + protected var _apiEventNotifier:EventDispatcher; + protected var _apiInvoker: ApiInvoker; + + protected var _useProxyServer: Boolean = false; + + + /** + * Constructor for the api client + * @param apiCredentials Wrapper object for tokens and hostName required towards authentication + * @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response + */ + public function SwaggerApi(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) { + super(); + _apiUsageCredentials = apiCredentials; + _apiEventNotifier = eventDispatcher; + } + + public function useProxyServer(value:Boolean, proxyServerUrl: String = null):void { + _useProxyServer = value; + } + + protected function getApiInvoker():ApiInvoker { + if(_apiInvoker == null){ + if(_apiEventNotifier == null){ + _apiEventNotifier = this; + } + _apiInvoker = new ApiInvoker(_apiUsageCredentials, _apiEventNotifier, _useProxyServer); + } + return _apiInvoker; + } + + protected function getUniqueId():String { + return UIDUtil.createUID(); + } + + /** + * Method for returning the path value + * For a string value an empty value is returned if the value is null + * @param value + * @return + */ + protected static function toPathValue(value: Object): String { + if(value is Array){ + return arrayToPathValue(value as Array); + } + return value == null ? "" : value.toString(); + } + + /** + * Method for returning a path value + * For a list of objects a comma separated string is returned + * @param objects + * @return + */ + protected static function arrayToPathValue(objects: Array): String { + var out: String = ""; + + return objects.join(","); + } + + } +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/XMLWriter.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/XMLWriter.as new file mode 100644 index 000000000000..0b08066775b9 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/XMLWriter.as @@ -0,0 +1,28 @@ +package io.swagger.common +{ + public class XMLWriter + { + public var xml:XML; + + public function XMLWriter() + { + xml=; + } + + public function reset():void { + xml=new XML(); + } + + public function addProperty(propertyName:String, propertyValue:String):XML { + var xmlProperty:XML= + xmlProperty.setName(propertyName); + xmlProperty.appendChild(propertyValue); + xml.appendChild(xmlProperty); + return xmlProperty; + } + + public function addAttribute(propertyName:String, attribute:String, attributeValue:String):void { + xml.elements(propertyName)[0].@[attribute]=attributeValue; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/event/ApiClientEvent.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/event/ApiClientEvent.as similarity index 75% rename from samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/event/ApiClientEvent.as rename to samples/client/petstore/flash/src/main/flex/io/swagger/swagger/event/ApiClientEvent.as index 923cf3454fad..d64cd304d49c 100644 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/event/ApiClientEvent.as +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/event/ApiClientEvent.as @@ -1,5 +1,5 @@ -package com.wordnik.swagger.event { -import com.wordnik.swagger.event.Response; +package io.swagger.event { +import io.swagger.event.Response; import flash.events.Event; @@ -8,7 +8,7 @@ import flash.events.Event; * If a custom dispatcher has been assigned by the consumer on the generated client then the dispatcher dispatches * the ApiClientEvent to indicate success or failure of the invocation using the Response */ -public class ApiClientEvent extends Event { +public class ApiClientEvent extends Event{ /** * Event type to indicate a unsuccessful invocation @@ -19,17 +19,18 @@ public class ApiClientEvent extends Event { * Event type to indicate a successful invocation */ public static const SUCCESS_EVENT:String = "successfulInvocation"; - - public function ApiClientEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) { - super(type, bubbles, cancelable); - } + /** * The Response object which contains response info */ - public var response:Response; + public var response: Response; /** * Any additional info */ public var message:String; + + public function ApiClientEvent(type:String,bubbles:Boolean = false,cancelable:Boolean = false) { + super(type, bubbles, cancelable); + } } } \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/event/Response.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/event/Response.as similarity index 63% rename from samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/event/Response.as rename to samples/client/petstore/flash/src/main/flex/io/swagger/swagger/event/Response.as index 2379096932ab..a43b7980a38b 100644 --- a/samples/client/petstore/flash/src/main/flex/com/wordnik/swagger/event/Response.as +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/event/Response.as @@ -1,4 +1,4 @@ -package com.wordnik.swagger.event { +package io.swagger.event { /** * Response contains info on the result of an API invocation. @@ -6,47 +6,50 @@ package com.wordnik.swagger.event { */ public class Response { + /** + * Indicates whether the invoked operation failed or succeeded + */ + public var isSuccess:Boolean; + + /** + * The payload of the succesful operation eg. a Word in a WordRequest + */ + public var payload:Object; + + /** + * Error message in case of failure + */ + public var errorMessage:String; + + /** + * A request Id that was passed in by the user as a param when invoking the operation + */ + public var requestId:String; private static const API_ERROR_MSG:String = "Api error response: "; - private static function getFriendlyMessage(errorMessage:String):String { - var result:String = errorMessage; - if (errorMessage == null) + public function Response(isSuccessful: Boolean, payload: Object = null, errorMessage: String = null, requestId: String = null) { + this.isSuccess = isSuccessful; + this.payload = payload; + this.errorMessage = getFriendlyMessage(errorMessage); + } + + private static function getFriendlyMessage(errorMessage: String): String{ + var result: String = errorMessage; + if(errorMessage == null) return null; - var errorCode:String; - var errorCodeArray:Array = errorMessage.match(/(?<=HTTP\/1.1 )[0-9][0-9][0-9]/); - if (errorCodeArray != null && errorCodeArray.length == 1) { + var errorCode: String; + var errorCodeArray: Array = errorMessage.match(/(?<=HTTP\/1.1 )[0-9][0-9][0-9]/); + if(errorCodeArray != null && errorCodeArray.length == 1){ errorCode = String(errorCodeArray[0]); } - var msgArray:Array = errorMessage.match(/(?<=HTTP\/1.1 [0-9][0-9][0-9] )[^]*/); - if (msgArray != null && msgArray.length == 1) { + var msgArray: Array = errorMessage.match(/(?<=HTTP\/1.1 [0-9][0-9][0-9] )[^]*/); + if(msgArray != null && msgArray.length == 1){ result = API_ERROR_MSG + String(msgArray[0]); } return result; } - public function Response(isSuccessful:Boolean, payload:Object = null, errorMessage:String = null, requestId:String = null) { - this.isSuccess = isSuccessful; - this.payload = payload; - this.errorMessage = getFriendlyMessage(errorMessage); - } - /** - * Indicates whether the invoked operation failed or succeeded - */ - public var isSuccess:Boolean; - /** - * The payload of the succesful operation eg. a Word in a WordRequest - */ - public var payload:Object; - /** - * Error message in case of failure - */ - public var errorMessage:String; - /** - * A request Id that was passed in by the user as a param when invoking the operation - */ - public var requestId:String; - - public function toString():String { + public function toString(): String { return "Response (requestId:" + requestId + "; isSuccess:" + isSuccess + "; errorMessage:" + errorMessage + "; payload:" + payload + ")"; } } diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/exception/ApiErrorCodes.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/exception/ApiErrorCodes.as new file mode 100644 index 000000000000..e5ea46480aa5 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/exception/ApiErrorCodes.as @@ -0,0 +1,34 @@ +package io.swagger.exception +{ + public class ApiErrorCodes + { + /** + * System exception. + */ + public static const SYSTEM_EXCEPTION: Number = 0; + + /** + * With Arguments as current key. + */ + public static const API_KEY_NOT_VALID: Number = 1000; + /** + * With arguments as current token value + */ + public static const AUTH_TOKEN_NOT_VALID: Number = 1001; + /** + * With arguments as input JSON and output class anme + */ + public static const ERROR_CONVERTING_JSON_TO_JAVA: Number = 1002; + /** + * With arguments as JAVA class name + */ + public static const ERROR_CONVERTING_JAVA_TO_JSON: Number = 1003; + + public static const ERROR_FROM_WEBSERVICE_CALL: Number = 1004; + /** + * With arguments as current API server name + */ + public static const API_SERVER_NOT_VALID: Number = 1005; + + } +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/exception/ApiErrors.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/exception/ApiErrors.as new file mode 100644 index 000000000000..c8ac95a5c59c --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/exception/ApiErrors.as @@ -0,0 +1,10 @@ +package io.swagger.exception +{ + public class ApiError extends Error + { + public function ApiError(id:*=0, message:*="") + { + super(message,id); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/flash/lib/ASAXB-0.1.1.swc b/samples/client/petstore/flash/src/main/flex/lib/ASAXB-0.1.1.swc similarity index 100% rename from samples/client/petstore/flash/lib/ASAXB-0.1.1.swc rename to samples/client/petstore/flash/src/main/flex/lib/ASAXB-0.1.1.swc diff --git a/samples/client/petstore/flash/lib/ext/as3corelib.swc b/samples/client/petstore/flash/src/main/flex/lib/as3corelib.swc similarity index 100% rename from samples/client/petstore/flash/lib/ext/as3corelib.swc rename to samples/client/petstore/flash/src/main/flex/lib/as3corelib.swc diff --git a/samples/client/petstore/flash/lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc similarity index 100% rename from samples/client/petstore/flash/lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc rename to samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc diff --git a/samples/client/petstore/flash/lib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc similarity index 100% rename from samples/client/petstore/flash/lib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc rename to samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc diff --git a/samples/client/petstore/flash/lib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc similarity index 100% rename from samples/client/petstore/flash/lib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc rename to samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc diff --git a/samples/client/petstore/flash/lib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc similarity index 100% rename from samples/client/petstore/flash/lib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc rename to samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc