diff --git a/bin/flash-petstore.sh b/bin/flash-petstore.sh new file mode 100755 index 00000000000..20d75e8a8ac --- /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 00000000000..a1ddcd3915d --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java @@ -0,0 +1,302 @@ +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 java.io.File; +import java.util.Arrays; +import java.util.HashSet; + +import org.apache.commons.lang.StringUtils; + +public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig { + protected String packageName = null; + protected String packageVersion = null; + + protected String invokerPackage = "io.swagger"; + protected String sourceFolder = "src/main/flex"; + + public FlashClientCodegen() { + super(); + + modelPackage = "models"; + apiPackage = "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"); + + 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"); + + // 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: swagger.client")); + 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")); + } + else { + setPackageName("swagger.client"); + } + + 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) + "[" + getTypeDeclaration(inner) + "]"; + } else if (p instanceof MapProperty) { + MapProperty mp = (MapProperty) p; + Property inner = mp.getAdditionalProperties(); + + return getSwaggerType(p) + "(str, " + getTypeDeclaration(inner) + ")"; + } + 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) { + return "None"; + } + + @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 2e514436747..e98ac462230 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/samples/client/petstore/flash/bin/AirExecutorApp-app.xml b/samples/client/petstore/flash/bin/AirExecutorApp-app.xml index 1eb5e43c7d7..1dbaf98e644 100644 --- a/samples/client/petstore/flash/bin/AirExecutorApp-app.xml +++ b/samples/client/petstore/flash/bin/AirExecutorApp-app.xml @@ -1,87 +1,87 @@ - - minimumPatchLevel - The minimum patch level of the AIR runtime required to run - the application. Optional. - --> + + AirExecutorApp - - AirExecutorApp + + AirExecutorApp - - AirExecutorApp + + AirExecutorApp - - AirExecutorApp + + v1 - - v1 + + - - + + - - + + - - + + + + + AirExecutorApp.swf + + + - - - - - AirExecutorApp.swf + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - + + + @@ -90,57 +90,57 @@ - - + + - - + + - - + + - - + + + + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/samples/client/petstore/flash/build.xml b/samples/client/petstore/flash/build.xml index 6861dd464ec..4f021b0b8b2 100644 --- a/samples/client/petstore/flash/build.xml +++ b/samples/client/petstore/flash/build.xml @@ -62,11 +62,11 @@ - - - - - + + + + + diff --git a/samples/client/petstore/flash/common/ApiInvoker.as b/samples/client/petstore/flash/common/ApiInvoker.as new file mode 100644 index 00000000000..98d94052ec4 --- /dev/null +++ b/samples/client/petstore/flash/common/ApiInvoker.as @@ -0,0 +1,255 @@ +package io.swagger.common { +import io.swagger.event.ApiClientEvent; +import io.swagger.event.Response; + +public class ApiInvoker extends EventDispatcher { + + private static const DELETE_DATA_DUMMY:String = "dummyDataRequiredForDeleteOverride"; + private static const X_HTTP_OVERRIDE_KEY:String = "X-HTTP-Method-Override"; + private static const CONTENT_TYPE_HEADER_KEY:String = "Content-Type"; + + public function ApiInvoker(apiUsageCredentials:ApiUserCredentials, eventNotifier:EventDispatcher, useProxy:Boolean = true) { + _apiUsageCredentials = apiUsageCredentials; + _useProxyServer = useProxy; + if (_apiUsageCredentials.hostName != null) { + _proxyHostName = _apiUsageCredentials.hostName; + } + _apiPath = _apiUsageCredentials.apiPath; + _proxyPath = _apiUsageCredentials.proxyPath; + _apiProxyServerUrl = _apiUsageCredentials.apiProxyServerUrl; + _apiEventNotifier = eventNotifier; + } + public var _apiEventNotifier:EventDispatcher; + internal var _apiProxyServerUrl:String = ""; + internal var _useProxyServer:Boolean = true; + private var _apiUsageCredentials:ApiUserCredentials; + private var _baseUrl:String = ""; + private var _proxyHostName:String = ""; + private var _apiPath:String = ""; + private var _proxyPath:String = ""; + + public function invokeAPI(resourceURL:String, method:String, queryParams:Dictionary, postObject:Object, headerParams:Dictionary):AsyncToken { + //make the communication + if (_useProxyServer) { + resourceURL = _apiProxyServerUrl + resourceURL; + } + else { + resourceURL = "http://" + _proxyHostName + _apiPath + resourceURL; + } + + var counter:int = 0; + var symbol:String = "&"; + var paramValue:Object; + for (var paramName:String in queryParams) { + paramValue = queryParams[paramName]; + //var key:String = paramName; + // do stuff + symbol = "&"; + if (counter == 0) { + symbol = "?"; + } + resourceURL = resourceURL + symbol + paramName + "=" + paramValue.toString(); + counter++; + + } +// trace(resourceURL); + //create a httpservice and invoke the rest url waiting for response + var requestHeader:Object = new Object(); + if (headerParams != null) { + for (var key:String in headerParams) { + requestHeader[key] = headerParams[key]; + } + } + + resourceURL = ApiUrlHelper.appendTokenInfo(resourceURL, requestHeader, _apiUsageCredentials); + + var bodyData:String = marshal(postObject).toString();//restRequest.postData; + + return doRestCall(resourceURL, onApiRequestResult, onApiRequestFault, method, bodyData, requestHeader, "application/xml"); + + + } + + public function marshal(source:Object):Object { +// trace("marshal got - " + source) + if (source is String) { + return source; + } else if (source is Array && source.length > 0) { + var writer:XMLWriter = new XMLWriter(); + var sourceArray:Array = source as Array; + var arrayEnclosure:String = getArrayEnclosure(sourceArray); + writer.xml.setName(arrayEnclosure); + + for (var i:int = 0; i < sourceArray.length; i++) { + var o:Object = sourceArray[i]; + writer.xml.appendChild(marshal(o)); + } + return writer.xml; + } else + return marshalObject(source); + } + + public function marshalObject(source:Object):XML { + var writer:XMLWriter = new XMLWriter(); + var objDescriptor:XML = describeType(source); + var property:XML; + var propertyType:String; + var propertyValue:Object; + + var qualifiedClassName:String = objDescriptor.@name; + qualifiedClassName = qualifiedClassName.replace("::", "."); + var className:String = qualifiedClassName.substring(qualifiedClassName.lastIndexOf(".") + 1); + className = className().toLowerCase() + className.substring(1); + writer.xml.setName(className); + + for each(property in objDescriptor.elements("variable")) { + propertyValue = source[property.@name]; + if (propertyValue != null) { + if (ObjectUtil.isSimple(propertyValue)) { + writer.addProperty(property.@name, propertyValue.toString()); + } + else { + writer.addProperty(property.@name, marshal(propertyValue).toXMLString()); + } + } + } + for each(property in objDescriptor.elements("accessor")) { + if (property.@access == "readonly") { + continue; + } + propertyValue = source[property.@name]; + if (source[property.@name] != null) { + if (ObjectUtil.isSimple(propertyValue)) { + writer.addProperty(property.@name, propertyValue.toString()); + } + else { + writer.addProperty(property.@name, marshal(propertyValue).toXMLString()); + } + } + } + return writer.xml; + } + + public function escapeString(str:String):String { + return str; + } + + private function doRestCall(url:String, resultFunction:Function, faultFunction:Function = null, + restMethod:String = "GET", + bodyData:Object = null, headers:Object = null, contentType:String = "application/xml"):AsyncToken { + var httpService:HTTPService = new HTTPService(); + + if (headers == null) { + headers = new Object(); + } + httpService.method = restMethod; + + if (restMethod.toUpperCase() != HTTPRequestMessage.GET_METHOD) { + //httpService.method = HTTPRequestMessage.POST_METHOD; - not required as we're using the proxy + if (bodyData == null) { + bodyData = new Object(); + } + + if (restMethod == HTTPRequestMessage.DELETE_METHOD) { + headers[X_HTTP_OVERRIDE_KEY] = HTTPRequestMessage.DELETE_METHOD; + bodyData = DELETE_DATA_DUMMY; + } + else if (restMethod == HTTPRequestMessage.PUT_METHOD) { + headers[X_HTTP_OVERRIDE_KEY] = HTTPRequestMessage.PUT_METHOD; + } + else { + headers[CONTENT_TYPE_HEADER_KEY] = contentType; + } + } + else { + //if the request type is GET and content type is xml then the Flex HTTPService converts it to a POST ... yeah + contentType = null; + } + + httpService.url = url; + httpService.contentType = contentType; + httpService.resultFormat = "e4x"; + httpService.headers = headers; + httpService.addEventListener(ResultEvent.RESULT, resultFunction); + if (faultFunction != null) { + httpService.addEventListener(FaultEvent.FAULT, faultFunction); + } + if (_useProxyServer) { + httpService.useProxy = true; + + var channelSet:ChannelSet = new ChannelSet(); + var httpChannel:HTTPChannel = new HTTPChannel(); + httpChannel.uri = ApiUrlHelper.getProxyUrl(_proxyHostName, _proxyPath); + channelSet.addChannel(httpChannel); + httpService.channelSet = channelSet; + } + + return httpService.send(bodyData); + } + + private function onApiRequestResult(event:ResultEvent):void { + var completionListener:Function = event.token.completionListener; + var result:Object = event.result; + var resultType:Class = event.token.returnType; + var resultObject:Object; + if (resultType != null) { + var context:ASAXBContext = ASAXBContext.newInstance(resultType); + var unmarshaller:Unmarshaller = context.createUnmarshaller(); + var resultXML:XML = new XML(event.result); + try { + resultObject = unmarshaller.unmarshal(resultXML); + } + catch (error:TypeError) { + var errorResponse:Response = new Response(false, null, "Could not unmarshall response"); + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var failureEvent:ApiClientEvent = new ApiClientEvent(event.token.completionEventType); + failureEvent.response = errorResponse; + _apiEventNotifier.dispatchEvent(failureEvent); + } + } + + if (resultObject is ListWrapper) { + resultObject = ListWrapper(resultObject).getList(); + } + } + + var response:Response = new Response(true, resultObject); + response.requestId = event.token.requestId; + var successEventType:String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.SUCCESS_EVENT; + + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var successEvent:ApiClientEvent = new ApiClientEvent(successEventType); + successEvent.response = response; + _apiEventNotifier.dispatchEvent(successEvent); + } + } + + private function onApiRequestFault(event:FaultEvent):void { + var completionListener:Function = event.token.completionListener; + if (completionListener != null) { + completionListener.call(null, new Response(false, null, event.fault.faultString)); + } + + var failureEventType:String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.FAILURE_EVENT; + + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var failureEvent:ApiClientEvent = new ApiClientEvent(failureEventType); + failureEvent.response = new Response(false, null, event.fault.faultString); + _apiEventNotifier.dispatchEvent(failureEvent); + } + } + + private function getArrayEnclosure(arr:Array):String { + if (arr != null && arr.length > 0) { + var className:String = flash.utils.getQualifiedClassName(arr[0]) + if (className.indexOf("::") > 0) + className = className.substr(className.indexOf("::") + 2, className.length) + + return className.substring(0, 1).toLowerCase() + className.substring(1, className.length) + "s"; + } else + return ""; + } + + +} +} \ No newline at end of file diff --git a/samples/client/petstore/flash/common/ApiUrlHelper.as b/samples/client/petstore/flash/common/ApiUrlHelper.as new file mode 100644 index 00000000000..4333c6c7e4c --- /dev/null +++ b/samples/client/petstore/flash/common/ApiUrlHelper.as @@ -0,0 +1,41 @@ +package io.swagger.common { +import io.swagger.common.ApiUserCredentials; + +/** + * @private + * Internal class for the Rest client + */ +internal class ApiUrlHelper { + + private static const API_URL_KEY:String = "api_key"; + private static const AUTH_TOKEN_URL_KEY:String = "auth_token"; + + private static const HTTP_URL_PREFIX:String = "http://"; + + 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){ + restUrl += ( "?" + API_URL_KEY + "=" + credentials.apiToken ); + } + else{ + restUrl += ( "&" + API_URL_KEY + "=" + credentials.apiToken ); + } + requestHeader.api_key = credentials.apiToken; + + if(credentials.authToken != null && credentials.authToken != ""){ + restUrl += ( "&" + AUTH_TOKEN_URL_KEY + "=" + credentials.authToken ); + requestHeader.auth_token = credentials.authToken; + } + + return restUrl; + } + + internal static function getProxyUrl(hostName: String, proxyPath: String): String{ + if (hostName(hostName.length - 1) == "/") //remove trailing slash + { + hostName = hostName.substring(0, hostName.length - 1); + } + return HTTP_URL_PREFIX + hostName + proxyPath; + } +} +} diff --git a/samples/client/petstore/flash/common/ApiUserCredentials.as b/samples/client/petstore/flash/common/ApiUserCredentials.as new file mode 100644 index 00000000000..118d917a247 --- /dev/null +++ b/samples/client/petstore/flash/common/ApiUserCredentials.as @@ -0,0 +1,63 @@ +package io.swagger.common { + +/** + * Api account credentials. + * + */ +public class ApiUserCredentials { + /** + * An apitoken that is passed along with the requests + */ + public var apiToken:String; + /** + * A valid auth_token which could be necessary for certain operations + */ + public var authToken:String; + /** + * The userId which could be required for certain operations + */ + public var userId:Number; + /** + * 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; + + /** + * 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; + } + +} +} \ No newline at end of file diff --git a/samples/client/petstore/flash/common/ListWrapper.as b/samples/client/petstore/flash/common/ListWrapper.as new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/client/petstore/flash/common/SwaggerApi.as b/samples/client/petstore/flash/common/SwaggerApi.as new file mode 100644 index 00000000000..059de642a74 --- /dev/null +++ b/samples/client/petstore/flash/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/common/XMLWriter.as b/samples/client/petstore/flash/common/XMLWriter.as new file mode 100644 index 00000000000..0b08066775b --- /dev/null +++ b/samples/client/petstore/flash/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/event/ApiClientEvent.as b/samples/client/petstore/flash/event/ApiClientEvent.as new file mode 100644 index 00000000000..d64cd304d49 --- /dev/null +++ b/samples/client/petstore/flash/event/ApiClientEvent.as @@ -0,0 +1,36 @@ +package io.swagger.event { +import io.swagger.event.Response; + +import flash.events.Event; + +/** + * Event dispatched by the SDK to communicate success events and failure events. + * 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{ + + /** + * Event type to indicate a unsuccessful invocation + */ + public static const FAILURE_EVENT:String = "unsuccesfulInvocation"; + + /** + * Event type to indicate a successful invocation + */ + public static const SUCCESS_EVENT:String = "successfulInvocation"; + + /** + * The Response object which contains response info + */ + 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/event/Response.as b/samples/client/petstore/flash/event/Response.as new file mode 100644 index 00000000000..a43b7980a38 --- /dev/null +++ b/samples/client/petstore/flash/event/Response.as @@ -0,0 +1,56 @@ +package io.swagger.event { + +/** + * Response contains info on the result of an API invocation. + * A completion listener will expect this Response object. + */ +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: "; + + 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){ + errorCode = String(errorCodeArray[0]); + } + 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 toString(): String { + return "Response (requestId:" + requestId + "; isSuccess:" + isSuccess + "; errorMessage:" + errorMessage + "; payload:" + payload + ")"; + } +} +} \ No newline at end of file diff --git a/samples/client/petstore/flash/exception/ApiErrorCodes.as b/samples/client/petstore/flash/exception/ApiErrorCodes.as new file mode 100644 index 00000000000..e5ea46480aa --- /dev/null +++ b/samples/client/petstore/flash/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/exception/ApiErrors.as b/samples/client/petstore/flash/exception/ApiErrors.as new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/client/petstore/flash/io.swagger/client/model/ApiResponse.as b/samples/client/petstore/flash/io.swagger/client/model/ApiResponse.as new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/client/petstore/flash/io.swagger/client/model/ApiResponseList.as b/samples/client/petstore/flash/io.swagger/client/model/ApiResponseList.as new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/client/petstore/flash/lib/as3corelib.swc b/samples/client/petstore/flash/lib/as3corelib.swc new file mode 100644 index 00000000000..12dd6b3b0a6 Binary files /dev/null and b/samples/client/petstore/flash/lib/as3corelib.swc differ 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 00000000000..1dbaf98e644 --- /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/src/main/flex/build.properties b/samples/client/petstore/flash/src/main/flex/build.properties new file mode 100644 index 00000000000..8e77d88c961 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/build.properties @@ -0,0 +1,29 @@ +# Window and document title for the documentation +title=Sample app AS3 SDK API Documentation + +#Path to the source folder where the .as files are located +sourcepath = ./src/main/flex + +# Class-folders you want to search for classes to be included in the docs, seperated by spaces (for example ../com/ ../net/ ) +# to include every .as and .mxml file within your project, just state ../ +domainextensions = ./src/main/flex + +# The Location of deployment library on your Computer (PC/Mac) for compiled SWC file +liboutputfolder = bin +liboutputfile = as3-sample-sdk.swc +libpath = lib + +# The Location of the output folder for your generated documents +docsoutputfolder = asdoc + +# The location of the test sources +testsourcepath = ./src/test/flex + +# Home directory for flex sdk, change this to build for Mac or PC using # as comment +FLEX4_SDK_HOME = /usr/local/flex_sdk_4.1.0/ +#FLEX4_SDK_HOME = /Applications/Adobe Flash Builder 4/sdks/4.1.0/ + +# The location of your asdoc.exe, change this to build for Mac or PC using # as comment +#asdoc.exe = C:/Program Files/Adobe/Flash Builder 4/sdks/3.5.0/bin/asdoc.exe +#asdoc.exe = /Applications/Adobe Flash Builder 4/sdks/3.5.0/bin/asdoc + diff --git a/samples/client/petstore/flash/src/main/flex/build.xml b/samples/client/petstore/flash/src/main/flex/build.xml new file mode 100644 index 00000000000..4f021b0b8b2 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/build.xml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + docs created + + + + + + + + + + + + + + + + + + + + + + + + SWC created + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/bin/AirExecutorApp-app.xml b/samples/client/petstore/flash/src/main/flex/io/swagger/bin/AirExecutorApp-app.xml new file mode 100644 index 00000000000..1dbaf98e644 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/bin/AirExecutorApp-app.xml @@ -0,0 +1,146 @@ + + + + + + + AirExecutorApp + + + AirExecutorApp + + + AirExecutorApp + + + v1 + + + + + + + + + + + + + + + AirExecutorApp.swf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/build.properties b/samples/client/petstore/flash/src/main/flex/io/swagger/build.properties new file mode 100644 index 00000000000..8e77d88c961 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/build.properties @@ -0,0 +1,29 @@ +# Window and document title for the documentation +title=Sample app AS3 SDK API Documentation + +#Path to the source folder where the .as files are located +sourcepath = ./src/main/flex + +# Class-folders you want to search for classes to be included in the docs, seperated by spaces (for example ../com/ ../net/ ) +# to include every .as and .mxml file within your project, just state ../ +domainextensions = ./src/main/flex + +# The Location of deployment library on your Computer (PC/Mac) for compiled SWC file +liboutputfolder = bin +liboutputfile = as3-sample-sdk.swc +libpath = lib + +# The Location of the output folder for your generated documents +docsoutputfolder = asdoc + +# The location of the test sources +testsourcepath = ./src/test/flex + +# Home directory for flex sdk, change this to build for Mac or PC using # as comment +FLEX4_SDK_HOME = /usr/local/flex_sdk_4.1.0/ +#FLEX4_SDK_HOME = /Applications/Adobe Flash Builder 4/sdks/4.1.0/ + +# The location of your asdoc.exe, change this to build for Mac or PC using # as comment +#asdoc.exe = C:/Program Files/Adobe/Flash Builder 4/sdks/3.5.0/bin/asdoc.exe +#asdoc.exe = /Applications/Adobe Flash Builder 4/sdks/3.5.0/bin/asdoc + diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/build.xml b/samples/client/petstore/flash/src/main/flex/io/swagger/build.xml new file mode 100644 index 00000000000..4f021b0b8b2 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/build.xml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + docs created + + + + + + + + + + + + + + + + + + + + + + + + SWC created + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + \ 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 00000000000..51850ac896b --- /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 java.io.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, io.swagger.codegen.CodegenParameter@30f97aff, 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, io.swagger.codegen.CodegenParameter@4afa1477, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "add_pet"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_status (status: Array[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(); + + + + 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[Pet]; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_tags (tags: Array[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(); + + + + 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[Pet]; + 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/PetApi.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/PetApi.py new file mode 100644 index 00000000000..5ca5b8bd935 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/PetApi.py @@ -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 java.io.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, io.swagger.codegen.CodegenParameter@4afa1477, 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, io.swagger.codegen.CodegenParameter@6855b715, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "add_pet"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_status (status: Array[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(); + + + + 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[Pet]; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_tags (tags: Array[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(); + + + + 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[Pet]; + 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; + + } + +} + +} \ No newline at end of file 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 00000000000..4ba76f079c2 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/StoreApi.as @@ -0,0 +1,151 @@ +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.Dictionary; +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(str, Number) + */ + 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(str, Number); + 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, io.swagger.codegen.CodegenParameter@6855b715, 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/StoreApi.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/StoreApi.py new file mode 100644 index 00000000000..3db705ff486 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/StoreApi.py @@ -0,0 +1,151 @@ +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.Dictionary; +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(str, Number) + */ + 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(str, Number); + 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, io.swagger.codegen.CodegenParameter@5366f936, 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; + + } + +} + +} \ No newline at end of file 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 00000000000..8580eb76b70 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/UserApi.as @@ -0,0 +1,275 @@ +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 java.util.List; + +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, io.swagger.codegen.CodegenParameter@21668d9, 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[User]): 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, io.swagger.codegen.CodegenParameter@d3d7fa1, 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[User]): 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, io.swagger.codegen.CodegenParameter@408629d1, 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, io.swagger.codegen.CodegenParameter@2823796f, 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/UserApi.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/UserApi.py new file mode 100644 index 00000000000..865307ebc96 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/UserApi.py @@ -0,0 +1,275 @@ +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 java.util.List; + +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, io.swagger.codegen.CodegenParameter@d3d7fa1, 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[User]): 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, io.swagger.codegen.CodegenParameter@408629d1, 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[User]): 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, io.swagger.codegen.CodegenParameter@2823796f, 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, io.swagger.codegen.CodegenParameter@30f97aff, 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/pet_api.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/pet_api.py new file mode 100644 index 00000000000..3a095dc9a26 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/pet_api.py @@ -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 java.io.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, io.swagger.codegen.CodegenParameter@6855b715, 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, io.swagger.codegen.CodegenParameter@5366f936, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "add_pet"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_status (status: Array[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(); + + + + 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[Pet]; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_tags (tags: Array[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(); + + + + 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[Pet]; + return requestId; + + } + + /* + * Returns Pet + */ + public function get_pet_by_id (pet_id: Number): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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 (pet_id: String, name: String, status: String): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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 (pet_id: Number, api_key: String): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + headerParams["api_key"] = toPathValue(api_key); + + + 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 (pet_id: Number, additional_metadata: String, file: File): String { + // create path and map variables + var path: String = "/pet/{petId}/uploadImage".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/store_api.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/store_api.py new file mode 100644 index 00000000000..cb1bb891a16 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/store_api.py @@ -0,0 +1,151 @@ +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.Dictionary; +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(str, Number) + */ + 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(str, Number); + 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, io.swagger.codegen.CodegenParameter@d737301, 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 (order_id: String): String { + // create path and map variables + var path: String = "/store/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "order_id" + "}", getApiInvoker().escapeString(order_id)); + + // 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 (order_id: String): String { + // create path and map variables + var path: String = "/store/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "order_id" + "}", getApiInvoker().escapeString(order_id)); + + // 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/user_api.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/user_api.py new file mode 100644 index 00000000000..05f77a81ce1 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/api/user_api.py @@ -0,0 +1,275 @@ +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 java.util.List; + +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, io.swagger.codegen.CodegenParameter@408629d1, 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[User]): 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, io.swagger.codegen.CodegenParameter@2823796f, 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[User]): 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, io.swagger.codegen.CodegenParameter@30f97aff, 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, io.swagger.codegen.CodegenParameter@4afa1477, 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; + + } + +} + +} \ No newline at end of file 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 00000000000..b9de19775fe --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Category.as @@ -0,0 +1,40 @@ +package io.swagger/client/model { + + + [XmlRootNode(name="Category")] + public class Category { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + 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 00000000000..7c4fcfb42ad --- /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 00000000000..16fa9ca6584 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Order.as @@ -0,0 +1,85 @@ +package io.swagger/client/model { + + + [XmlRootNode(name="Order")] + public class Order { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="petId")] + + public var petId: Number = None; + + + + + + + [XmlElement(name="quantity")] + + public var quantity: Number = None; + + + + + + + [XmlElement(name="shipDate")] + + public var shipDate: Date = None; + + + + /* Order Status */ + + + + [XmlElement(name="status")] + + public var status: String = None; + + + + + + + [XmlElement(name="complete")] + + public var complete: Boolean = None; + + + + 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 00000000000..02aea6c5a3a --- /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 00000000000..191f1ec37fc --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Pet.as @@ -0,0 +1,86 @@ +package io.swagger/client/model { + +import io.swagger/client/model.Category; +import io.swagger/client/model.Tag; +import java.util.List; + + [XmlRootNode(name="Pet")] + public class Pet { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="category")] + + public var category: Category = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + + + + + public var photoUrls: Array[String] = None; + + + + + + + + public var tags: Array[Tag] = None; + + + + /* pet status in the store */ + + + + [XmlElement(name="status")] + + public var status: String = None; + + + + 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 00000000000..91d04085739 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/PetList.as @@ -0,0 +1,21 @@ +package io.swagger/client/model { + +import io.swagger.common.ListWrapper; +import io.swagger/client/model.Category; +import io.swagger/client/model.Tag; +import java.util.List; + + 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 00000000000..1203b17bc12 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/Tag.as @@ -0,0 +1,40 @@ +package io.swagger/client/model { + + + [XmlRootNode(name="Tag")] + public class Tag { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + 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 00000000000..082b7f9704d --- /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 00000000000..12511d9c989 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/User.as @@ -0,0 +1,107 @@ +package io.swagger/client/model { + + + [XmlRootNode(name="User")] + public class User { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="username")] + + public var username: String = None; + + + + + + + [XmlElement(name="firstName")] + + public var firstName: String = None; + + + + + + + [XmlElement(name="lastName")] + + public var lastName: String = None; + + + + + + + [XmlElement(name="email")] + + public var email: String = None; + + + + + + + [XmlElement(name="password")] + + public var password: String = None; + + + + + + + [XmlElement(name="phone")] + + public var phone: String = None; + + + + /* User Status */ + + + + [XmlElement(name="userStatus")] + + public var userStatus: Number = None; + + + + 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 00000000000..5adef06dfba --- /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/io/swagger/client/model/category.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/category.py new file mode 100644 index 00000000000..b9de19775fe --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/category.py @@ -0,0 +1,40 @@ +package io.swagger/client/model { + + + [XmlRootNode(name="Category")] + public class Category { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + 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/order.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/order.py new file mode 100644 index 00000000000..16fa9ca6584 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/order.py @@ -0,0 +1,85 @@ +package io.swagger/client/model { + + + [XmlRootNode(name="Order")] + public class Order { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="petId")] + + public var petId: Number = None; + + + + + + + [XmlElement(name="quantity")] + + public var quantity: Number = None; + + + + + + + [XmlElement(name="shipDate")] + + public var shipDate: Date = None; + + + + /* Order Status */ + + + + [XmlElement(name="status")] + + public var status: String = None; + + + + + + + [XmlElement(name="complete")] + + public var complete: Boolean = None; + + + + 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/pet.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/pet.py new file mode 100644 index 00000000000..191f1ec37fc --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/pet.py @@ -0,0 +1,86 @@ +package io.swagger/client/model { + +import io.swagger/client/model.Category; +import io.swagger/client/model.Tag; +import java.util.List; + + [XmlRootNode(name="Pet")] + public class Pet { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="category")] + + public var category: Category = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + + + + + public var photoUrls: Array[String] = None; + + + + + + + + public var tags: Array[Tag] = None; + + + + /* pet status in the store */ + + + + [XmlElement(name="status")] + + public var status: String = None; + + + + 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/tag.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/tag.py new file mode 100644 index 00000000000..1203b17bc12 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/tag.py @@ -0,0 +1,40 @@ +package io.swagger/client/model { + + + [XmlRootNode(name="Tag")] + public class Tag { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + 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/user.py b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/user.py new file mode 100644 index 00000000000..12511d9c989 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/client/model/user.py @@ -0,0 +1,107 @@ +package io.swagger/client/model { + + + [XmlRootNode(name="User")] + public class User { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="username")] + + public var username: String = None; + + + + + + + [XmlElement(name="firstName")] + + public var firstName: String = None; + + + + + + + [XmlElement(name="lastName")] + + public var lastName: String = None; + + + + + + + [XmlElement(name="email")] + + public var email: String = None; + + + + + + + [XmlElement(name="password")] + + public var password: String = None; + + + + + + + [XmlElement(name="phone")] + + public var phone: String = None; + + + + /* User Status */ + + + + [XmlElement(name="userStatus")] + + public var userStatus: Number = None; + + + + 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/common/ApiInvoker.as b/samples/client/petstore/flash/src/main/flex/io/swagger/common/ApiInvoker.as new file mode 100644 index 00000000000..98d94052ec4 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/common/ApiInvoker.as @@ -0,0 +1,255 @@ +package io.swagger.common { +import io.swagger.event.ApiClientEvent; +import io.swagger.event.Response; + +public class ApiInvoker extends EventDispatcher { + + private static const DELETE_DATA_DUMMY:String = "dummyDataRequiredForDeleteOverride"; + private static const X_HTTP_OVERRIDE_KEY:String = "X-HTTP-Method-Override"; + private static const CONTENT_TYPE_HEADER_KEY:String = "Content-Type"; + + public function ApiInvoker(apiUsageCredentials:ApiUserCredentials, eventNotifier:EventDispatcher, useProxy:Boolean = true) { + _apiUsageCredentials = apiUsageCredentials; + _useProxyServer = useProxy; + if (_apiUsageCredentials.hostName != null) { + _proxyHostName = _apiUsageCredentials.hostName; + } + _apiPath = _apiUsageCredentials.apiPath; + _proxyPath = _apiUsageCredentials.proxyPath; + _apiProxyServerUrl = _apiUsageCredentials.apiProxyServerUrl; + _apiEventNotifier = eventNotifier; + } + public var _apiEventNotifier:EventDispatcher; + internal var _apiProxyServerUrl:String = ""; + internal var _useProxyServer:Boolean = true; + private var _apiUsageCredentials:ApiUserCredentials; + private var _baseUrl:String = ""; + private var _proxyHostName:String = ""; + private var _apiPath:String = ""; + private var _proxyPath:String = ""; + + public function invokeAPI(resourceURL:String, method:String, queryParams:Dictionary, postObject:Object, headerParams:Dictionary):AsyncToken { + //make the communication + if (_useProxyServer) { + resourceURL = _apiProxyServerUrl + resourceURL; + } + else { + resourceURL = "http://" + _proxyHostName + _apiPath + resourceURL; + } + + var counter:int = 0; + var symbol:String = "&"; + var paramValue:Object; + for (var paramName:String in queryParams) { + paramValue = queryParams[paramName]; + //var key:String = paramName; + // do stuff + symbol = "&"; + if (counter == 0) { + symbol = "?"; + } + resourceURL = resourceURL + symbol + paramName + "=" + paramValue.toString(); + counter++; + + } +// trace(resourceURL); + //create a httpservice and invoke the rest url waiting for response + var requestHeader:Object = new Object(); + if (headerParams != null) { + for (var key:String in headerParams) { + requestHeader[key] = headerParams[key]; + } + } + + resourceURL = ApiUrlHelper.appendTokenInfo(resourceURL, requestHeader, _apiUsageCredentials); + + var bodyData:String = marshal(postObject).toString();//restRequest.postData; + + return doRestCall(resourceURL, onApiRequestResult, onApiRequestFault, method, bodyData, requestHeader, "application/xml"); + + + } + + public function marshal(source:Object):Object { +// trace("marshal got - " + source) + if (source is String) { + return source; + } else if (source is Array && source.length > 0) { + var writer:XMLWriter = new XMLWriter(); + var sourceArray:Array = source as Array; + var arrayEnclosure:String = getArrayEnclosure(sourceArray); + writer.xml.setName(arrayEnclosure); + + for (var i:int = 0; i < sourceArray.length; i++) { + var o:Object = sourceArray[i]; + writer.xml.appendChild(marshal(o)); + } + return writer.xml; + } else + return marshalObject(source); + } + + public function marshalObject(source:Object):XML { + var writer:XMLWriter = new XMLWriter(); + var objDescriptor:XML = describeType(source); + var property:XML; + var propertyType:String; + var propertyValue:Object; + + var qualifiedClassName:String = objDescriptor.@name; + qualifiedClassName = qualifiedClassName.replace("::", "."); + var className:String = qualifiedClassName.substring(qualifiedClassName.lastIndexOf(".") + 1); + className = className().toLowerCase() + className.substring(1); + writer.xml.setName(className); + + for each(property in objDescriptor.elements("variable")) { + propertyValue = source[property.@name]; + if (propertyValue != null) { + if (ObjectUtil.isSimple(propertyValue)) { + writer.addProperty(property.@name, propertyValue.toString()); + } + else { + writer.addProperty(property.@name, marshal(propertyValue).toXMLString()); + } + } + } + for each(property in objDescriptor.elements("accessor")) { + if (property.@access == "readonly") { + continue; + } + propertyValue = source[property.@name]; + if (source[property.@name] != null) { + if (ObjectUtil.isSimple(propertyValue)) { + writer.addProperty(property.@name, propertyValue.toString()); + } + else { + writer.addProperty(property.@name, marshal(propertyValue).toXMLString()); + } + } + } + return writer.xml; + } + + public function escapeString(str:String):String { + return str; + } + + private function doRestCall(url:String, resultFunction:Function, faultFunction:Function = null, + restMethod:String = "GET", + bodyData:Object = null, headers:Object = null, contentType:String = "application/xml"):AsyncToken { + var httpService:HTTPService = new HTTPService(); + + if (headers == null) { + headers = new Object(); + } + httpService.method = restMethod; + + if (restMethod.toUpperCase() != HTTPRequestMessage.GET_METHOD) { + //httpService.method = HTTPRequestMessage.POST_METHOD; - not required as we're using the proxy + if (bodyData == null) { + bodyData = new Object(); + } + + if (restMethod == HTTPRequestMessage.DELETE_METHOD) { + headers[X_HTTP_OVERRIDE_KEY] = HTTPRequestMessage.DELETE_METHOD; + bodyData = DELETE_DATA_DUMMY; + } + else if (restMethod == HTTPRequestMessage.PUT_METHOD) { + headers[X_HTTP_OVERRIDE_KEY] = HTTPRequestMessage.PUT_METHOD; + } + else { + headers[CONTENT_TYPE_HEADER_KEY] = contentType; + } + } + else { + //if the request type is GET and content type is xml then the Flex HTTPService converts it to a POST ... yeah + contentType = null; + } + + httpService.url = url; + httpService.contentType = contentType; + httpService.resultFormat = "e4x"; + httpService.headers = headers; + httpService.addEventListener(ResultEvent.RESULT, resultFunction); + if (faultFunction != null) { + httpService.addEventListener(FaultEvent.FAULT, faultFunction); + } + if (_useProxyServer) { + httpService.useProxy = true; + + var channelSet:ChannelSet = new ChannelSet(); + var httpChannel:HTTPChannel = new HTTPChannel(); + httpChannel.uri = ApiUrlHelper.getProxyUrl(_proxyHostName, _proxyPath); + channelSet.addChannel(httpChannel); + httpService.channelSet = channelSet; + } + + return httpService.send(bodyData); + } + + private function onApiRequestResult(event:ResultEvent):void { + var completionListener:Function = event.token.completionListener; + var result:Object = event.result; + var resultType:Class = event.token.returnType; + var resultObject:Object; + if (resultType != null) { + var context:ASAXBContext = ASAXBContext.newInstance(resultType); + var unmarshaller:Unmarshaller = context.createUnmarshaller(); + var resultXML:XML = new XML(event.result); + try { + resultObject = unmarshaller.unmarshal(resultXML); + } + catch (error:TypeError) { + var errorResponse:Response = new Response(false, null, "Could not unmarshall response"); + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var failureEvent:ApiClientEvent = new ApiClientEvent(event.token.completionEventType); + failureEvent.response = errorResponse; + _apiEventNotifier.dispatchEvent(failureEvent); + } + } + + if (resultObject is ListWrapper) { + resultObject = ListWrapper(resultObject).getList(); + } + } + + var response:Response = new Response(true, resultObject); + response.requestId = event.token.requestId; + var successEventType:String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.SUCCESS_EVENT; + + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var successEvent:ApiClientEvent = new ApiClientEvent(successEventType); + successEvent.response = response; + _apiEventNotifier.dispatchEvent(successEvent); + } + } + + private function onApiRequestFault(event:FaultEvent):void { + var completionListener:Function = event.token.completionListener; + if (completionListener != null) { + completionListener.call(null, new Response(false, null, event.fault.faultString)); + } + + var failureEventType:String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.FAILURE_EVENT; + + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var failureEvent:ApiClientEvent = new ApiClientEvent(failureEventType); + failureEvent.response = new Response(false, null, event.fault.faultString); + _apiEventNotifier.dispatchEvent(failureEvent); + } + } + + private function getArrayEnclosure(arr:Array):String { + if (arr != null && arr.length > 0) { + var className:String = flash.utils.getQualifiedClassName(arr[0]) + if (className.indexOf("::") > 0) + className = className.substr(className.indexOf("::") + 2, className.length) + + return className.substring(0, 1).toLowerCase() + className.substring(1, className.length) + "s"; + } else + return ""; + } + + +} +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/common/ApiUrlHelper.as b/samples/client/petstore/flash/src/main/flex/io/swagger/common/ApiUrlHelper.as new file mode 100644 index 00000000000..4333c6c7e4c --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/common/ApiUrlHelper.as @@ -0,0 +1,41 @@ +package io.swagger.common { +import io.swagger.common.ApiUserCredentials; + +/** + * @private + * Internal class for the Rest client + */ +internal class ApiUrlHelper { + + private static const API_URL_KEY:String = "api_key"; + private static const AUTH_TOKEN_URL_KEY:String = "auth_token"; + + private static const HTTP_URL_PREFIX:String = "http://"; + + 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){ + restUrl += ( "?" + API_URL_KEY + "=" + credentials.apiToken ); + } + else{ + restUrl += ( "&" + API_URL_KEY + "=" + credentials.apiToken ); + } + requestHeader.api_key = credentials.apiToken; + + if(credentials.authToken != null && credentials.authToken != ""){ + restUrl += ( "&" + AUTH_TOKEN_URL_KEY + "=" + credentials.authToken ); + requestHeader.auth_token = credentials.authToken; + } + + return restUrl; + } + + internal static function getProxyUrl(hostName: String, proxyPath: String): String{ + if (hostName(hostName.length - 1) == "/") //remove trailing slash + { + hostName = hostName.substring(0, hostName.length - 1); + } + return HTTP_URL_PREFIX + hostName + proxyPath; + } +} +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/common/ApiUserCredentials.as b/samples/client/petstore/flash/src/main/flex/io/swagger/common/ApiUserCredentials.as new file mode 100644 index 00000000000..118d917a247 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/common/ApiUserCredentials.as @@ -0,0 +1,63 @@ +package io.swagger.common { + +/** + * Api account credentials. + * + */ +public class ApiUserCredentials { + /** + * An apitoken that is passed along with the requests + */ + public var apiToken:String; + /** + * A valid auth_token which could be necessary for certain operations + */ + public var authToken:String; + /** + * The userId which could be required for certain operations + */ + public var userId:Number; + /** + * 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; + + /** + * 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; + } + +} +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/common/ListWrapper.as b/samples/client/petstore/flash/src/main/flex/io/swagger/common/ListWrapper.as new file mode 100644 index 00000000000..b22890ad1d1 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/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/common/SwaggerApi.as b/samples/client/petstore/flash/src/main/flex/io/swagger/common/SwaggerApi.as new file mode 100644 index 00000000000..059de642a74 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/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/common/XMLWriter.as b/samples/client/petstore/flash/src/main/flex/io/swagger/common/XMLWriter.as new file mode 100644 index 00000000000..0b08066775b --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/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/io/swagger/event/ApiClientEvent.as b/samples/client/petstore/flash/src/main/flex/io/swagger/event/ApiClientEvent.as new file mode 100644 index 00000000000..d64cd304d49 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/event/ApiClientEvent.as @@ -0,0 +1,36 @@ +package io.swagger.event { +import io.swagger.event.Response; + +import flash.events.Event; + +/** + * Event dispatched by the SDK to communicate success events and failure events. + * 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{ + + /** + * Event type to indicate a unsuccessful invocation + */ + public static const FAILURE_EVENT:String = "unsuccesfulInvocation"; + + /** + * Event type to indicate a successful invocation + */ + public static const SUCCESS_EVENT:String = "successfulInvocation"; + + /** + * The Response object which contains response info + */ + 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/io/swagger/event/Response.as b/samples/client/petstore/flash/src/main/flex/io/swagger/event/Response.as new file mode 100644 index 00000000000..a43b7980a38 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/event/Response.as @@ -0,0 +1,56 @@ +package io.swagger.event { + +/** + * Response contains info on the result of an API invocation. + * A completion listener will expect this Response object. + */ +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: "; + + 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){ + errorCode = String(errorCodeArray[0]); + } + 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 toString(): String { + return "Response (requestId:" + requestId + "; isSuccess:" + isSuccess + "; errorMessage:" + errorMessage + "; payload:" + payload + ")"; + } +} +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/exception/ApiErrorCodes.as b/samples/client/petstore/flash/src/main/flex/io/swagger/exception/ApiErrorCodes.as new file mode 100644 index 00000000000..e5ea46480aa --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/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/exception/ApiErrors.as b/samples/client/petstore/flash/src/main/flex/io/swagger/exception/ApiErrors.as new file mode 100644 index 00000000000..c8ac95a5c59 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/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/src/main/flex/io/swagger/lib/ASAXB-0.1.1.swc b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ASAXB-0.1.1.swc new file mode 100644 index 00000000000..c9359026784 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ASAXB-0.1.1.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/lib/as3corelib.swc b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/as3corelib.swc new file mode 100644 index 00000000000..12dd6b3b0a6 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/as3corelib.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc new file mode 100644 index 00000000000..e41bc68abd9 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc new file mode 100644 index 00000000000..8bbdf8b86a0 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc new file mode 100644 index 00000000000..b69064ac765 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc new file mode 100644 index 00000000000..a90af750bb5 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swagger/lib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiInvoker.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiInvoker.as new file mode 100644 index 00000000000..98d94052ec4 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiInvoker.as @@ -0,0 +1,255 @@ +package io.swagger.common { +import io.swagger.event.ApiClientEvent; +import io.swagger.event.Response; + +public class ApiInvoker extends EventDispatcher { + + private static const DELETE_DATA_DUMMY:String = "dummyDataRequiredForDeleteOverride"; + private static const X_HTTP_OVERRIDE_KEY:String = "X-HTTP-Method-Override"; + private static const CONTENT_TYPE_HEADER_KEY:String = "Content-Type"; + + public function ApiInvoker(apiUsageCredentials:ApiUserCredentials, eventNotifier:EventDispatcher, useProxy:Boolean = true) { + _apiUsageCredentials = apiUsageCredentials; + _useProxyServer = useProxy; + if (_apiUsageCredentials.hostName != null) { + _proxyHostName = _apiUsageCredentials.hostName; + } + _apiPath = _apiUsageCredentials.apiPath; + _proxyPath = _apiUsageCredentials.proxyPath; + _apiProxyServerUrl = _apiUsageCredentials.apiProxyServerUrl; + _apiEventNotifier = eventNotifier; + } + public var _apiEventNotifier:EventDispatcher; + internal var _apiProxyServerUrl:String = ""; + internal var _useProxyServer:Boolean = true; + private var _apiUsageCredentials:ApiUserCredentials; + private var _baseUrl:String = ""; + private var _proxyHostName:String = ""; + private var _apiPath:String = ""; + private var _proxyPath:String = ""; + + public function invokeAPI(resourceURL:String, method:String, queryParams:Dictionary, postObject:Object, headerParams:Dictionary):AsyncToken { + //make the communication + if (_useProxyServer) { + resourceURL = _apiProxyServerUrl + resourceURL; + } + else { + resourceURL = "http://" + _proxyHostName + _apiPath + resourceURL; + } + + var counter:int = 0; + var symbol:String = "&"; + var paramValue:Object; + for (var paramName:String in queryParams) { + paramValue = queryParams[paramName]; + //var key:String = paramName; + // do stuff + symbol = "&"; + if (counter == 0) { + symbol = "?"; + } + resourceURL = resourceURL + symbol + paramName + "=" + paramValue.toString(); + counter++; + + } +// trace(resourceURL); + //create a httpservice and invoke the rest url waiting for response + var requestHeader:Object = new Object(); + if (headerParams != null) { + for (var key:String in headerParams) { + requestHeader[key] = headerParams[key]; + } + } + + resourceURL = ApiUrlHelper.appendTokenInfo(resourceURL, requestHeader, _apiUsageCredentials); + + var bodyData:String = marshal(postObject).toString();//restRequest.postData; + + return doRestCall(resourceURL, onApiRequestResult, onApiRequestFault, method, bodyData, requestHeader, "application/xml"); + + + } + + public function marshal(source:Object):Object { +// trace("marshal got - " + source) + if (source is String) { + return source; + } else if (source is Array && source.length > 0) { + var writer:XMLWriter = new XMLWriter(); + var sourceArray:Array = source as Array; + var arrayEnclosure:String = getArrayEnclosure(sourceArray); + writer.xml.setName(arrayEnclosure); + + for (var i:int = 0; i < sourceArray.length; i++) { + var o:Object = sourceArray[i]; + writer.xml.appendChild(marshal(o)); + } + return writer.xml; + } else + return marshalObject(source); + } + + public function marshalObject(source:Object):XML { + var writer:XMLWriter = new XMLWriter(); + var objDescriptor:XML = describeType(source); + var property:XML; + var propertyType:String; + var propertyValue:Object; + + var qualifiedClassName:String = objDescriptor.@name; + qualifiedClassName = qualifiedClassName.replace("::", "."); + var className:String = qualifiedClassName.substring(qualifiedClassName.lastIndexOf(".") + 1); + className = className().toLowerCase() + className.substring(1); + writer.xml.setName(className); + + for each(property in objDescriptor.elements("variable")) { + propertyValue = source[property.@name]; + if (propertyValue != null) { + if (ObjectUtil.isSimple(propertyValue)) { + writer.addProperty(property.@name, propertyValue.toString()); + } + else { + writer.addProperty(property.@name, marshal(propertyValue).toXMLString()); + } + } + } + for each(property in objDescriptor.elements("accessor")) { + if (property.@access == "readonly") { + continue; + } + propertyValue = source[property.@name]; + if (source[property.@name] != null) { + if (ObjectUtil.isSimple(propertyValue)) { + writer.addProperty(property.@name, propertyValue.toString()); + } + else { + writer.addProperty(property.@name, marshal(propertyValue).toXMLString()); + } + } + } + return writer.xml; + } + + public function escapeString(str:String):String { + return str; + } + + private function doRestCall(url:String, resultFunction:Function, faultFunction:Function = null, + restMethod:String = "GET", + bodyData:Object = null, headers:Object = null, contentType:String = "application/xml"):AsyncToken { + var httpService:HTTPService = new HTTPService(); + + if (headers == null) { + headers = new Object(); + } + httpService.method = restMethod; + + if (restMethod.toUpperCase() != HTTPRequestMessage.GET_METHOD) { + //httpService.method = HTTPRequestMessage.POST_METHOD; - not required as we're using the proxy + if (bodyData == null) { + bodyData = new Object(); + } + + if (restMethod == HTTPRequestMessage.DELETE_METHOD) { + headers[X_HTTP_OVERRIDE_KEY] = HTTPRequestMessage.DELETE_METHOD; + bodyData = DELETE_DATA_DUMMY; + } + else if (restMethod == HTTPRequestMessage.PUT_METHOD) { + headers[X_HTTP_OVERRIDE_KEY] = HTTPRequestMessage.PUT_METHOD; + } + else { + headers[CONTENT_TYPE_HEADER_KEY] = contentType; + } + } + else { + //if the request type is GET and content type is xml then the Flex HTTPService converts it to a POST ... yeah + contentType = null; + } + + httpService.url = url; + httpService.contentType = contentType; + httpService.resultFormat = "e4x"; + httpService.headers = headers; + httpService.addEventListener(ResultEvent.RESULT, resultFunction); + if (faultFunction != null) { + httpService.addEventListener(FaultEvent.FAULT, faultFunction); + } + if (_useProxyServer) { + httpService.useProxy = true; + + var channelSet:ChannelSet = new ChannelSet(); + var httpChannel:HTTPChannel = new HTTPChannel(); + httpChannel.uri = ApiUrlHelper.getProxyUrl(_proxyHostName, _proxyPath); + channelSet.addChannel(httpChannel); + httpService.channelSet = channelSet; + } + + return httpService.send(bodyData); + } + + private function onApiRequestResult(event:ResultEvent):void { + var completionListener:Function = event.token.completionListener; + var result:Object = event.result; + var resultType:Class = event.token.returnType; + var resultObject:Object; + if (resultType != null) { + var context:ASAXBContext = ASAXBContext.newInstance(resultType); + var unmarshaller:Unmarshaller = context.createUnmarshaller(); + var resultXML:XML = new XML(event.result); + try { + resultObject = unmarshaller.unmarshal(resultXML); + } + catch (error:TypeError) { + var errorResponse:Response = new Response(false, null, "Could not unmarshall response"); + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var failureEvent:ApiClientEvent = new ApiClientEvent(event.token.completionEventType); + failureEvent.response = errorResponse; + _apiEventNotifier.dispatchEvent(failureEvent); + } + } + + if (resultObject is ListWrapper) { + resultObject = ListWrapper(resultObject).getList(); + } + } + + var response:Response = new Response(true, resultObject); + response.requestId = event.token.requestId; + var successEventType:String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.SUCCESS_EVENT; + + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var successEvent:ApiClientEvent = new ApiClientEvent(successEventType); + successEvent.response = response; + _apiEventNotifier.dispatchEvent(successEvent); + } + } + + private function onApiRequestFault(event:FaultEvent):void { + var completionListener:Function = event.token.completionListener; + if (completionListener != null) { + completionListener.call(null, new Response(false, null, event.fault.faultString)); + } + + var failureEventType:String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.FAILURE_EVENT; + + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var failureEvent:ApiClientEvent = new ApiClientEvent(failureEventType); + failureEvent.response = new Response(false, null, event.fault.faultString); + _apiEventNotifier.dispatchEvent(failureEvent); + } + } + + private function getArrayEnclosure(arr:Array):String { + if (arr != null && arr.length > 0) { + var className:String = flash.utils.getQualifiedClassName(arr[0]) + if (className.indexOf("::") > 0) + className = className.substr(className.indexOf("::") + 2, className.length) + + return className.substring(0, 1).toLowerCase() + className.substring(1, className.length) + "s"; + } else + return ""; + } + + +} +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUrlHelper.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUrlHelper.as new file mode 100644 index 00000000000..4333c6c7e4c --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUrlHelper.as @@ -0,0 +1,41 @@ +package io.swagger.common { +import io.swagger.common.ApiUserCredentials; + +/** + * @private + * Internal class for the Rest client + */ +internal class ApiUrlHelper { + + private static const API_URL_KEY:String = "api_key"; + private static const AUTH_TOKEN_URL_KEY:String = "auth_token"; + + private static const HTTP_URL_PREFIX:String = "http://"; + + 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){ + restUrl += ( "?" + API_URL_KEY + "=" + credentials.apiToken ); + } + else{ + restUrl += ( "&" + API_URL_KEY + "=" + credentials.apiToken ); + } + requestHeader.api_key = credentials.apiToken; + + if(credentials.authToken != null && credentials.authToken != ""){ + restUrl += ( "&" + AUTH_TOKEN_URL_KEY + "=" + credentials.authToken ); + requestHeader.auth_token = credentials.authToken; + } + + return restUrl; + } + + internal static function getProxyUrl(hostName: String, proxyPath: String): String{ + if (hostName(hostName.length - 1) == "/") //remove trailing slash + { + hostName = hostName.substring(0, hostName.length - 1); + } + return HTTP_URL_PREFIX + hostName + proxyPath; + } +} +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUserCredentials.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUserCredentials.as new file mode 100644 index 00000000000..118d917a247 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/common/ApiUserCredentials.as @@ -0,0 +1,63 @@ +package io.swagger.common { + +/** + * Api account credentials. + * + */ +public class ApiUserCredentials { + /** + * An apitoken that is passed along with the requests + */ + public var apiToken:String; + /** + * A valid auth_token which could be necessary for certain operations + */ + public var authToken:String; + /** + * The userId which could be required for certain operations + */ + public var userId:Number; + /** + * 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; + + /** + * 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; + } + +} +} \ 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 00000000000..b22890ad1d1 --- /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 00000000000..059de642a74 --- /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 00000000000..0b08066775b --- /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/io/swagger/swagger/event/ApiClientEvent.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/event/ApiClientEvent.as new file mode 100644 index 00000000000..d64cd304d49 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/event/ApiClientEvent.as @@ -0,0 +1,36 @@ +package io.swagger.event { +import io.swagger.event.Response; + +import flash.events.Event; + +/** + * Event dispatched by the SDK to communicate success events and failure events. + * 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{ + + /** + * Event type to indicate a unsuccessful invocation + */ + public static const FAILURE_EVENT:String = "unsuccesfulInvocation"; + + /** + * Event type to indicate a successful invocation + */ + public static const SUCCESS_EVENT:String = "successfulInvocation"; + + /** + * The Response object which contains response info + */ + 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/io/swagger/swagger/event/Response.as b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/event/Response.as new file mode 100644 index 00000000000..a43b7980a38 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swagger/swagger/event/Response.as @@ -0,0 +1,56 @@ +package io.swagger.event { + +/** + * Response contains info on the result of an API invocation. + * A completion listener will expect this Response object. + */ +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: "; + + 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){ + errorCode = String(errorCodeArray[0]); + } + 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 toString(): String { + return "Response (requestId:" + requestId + "; isSuccess:" + isSuccess + "; errorMessage:" + errorMessage + "; payload:" + payload + ")"; + } +} +} \ No newline at end of file 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 00000000000..e5ea46480aa --- /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 00000000000..c8ac95a5c59 --- /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/src/main/flex/io/swaggerbin/AirExecutorApp-app.xml b/samples/client/petstore/flash/src/main/flex/io/swaggerbin/AirExecutorApp-app.xml new file mode 100644 index 00000000000..1dbaf98e644 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swaggerbin/AirExecutorApp-app.xml @@ -0,0 +1,146 @@ + + + + + + + AirExecutorApp + + + AirExecutorApp + + + AirExecutorApp + + + v1 + + + + + + + + + + + + + + + AirExecutorApp.swf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ApiInvoker.as b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ApiInvoker.as new file mode 100644 index 00000000000..98d94052ec4 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ApiInvoker.as @@ -0,0 +1,255 @@ +package io.swagger.common { +import io.swagger.event.ApiClientEvent; +import io.swagger.event.Response; + +public class ApiInvoker extends EventDispatcher { + + private static const DELETE_DATA_DUMMY:String = "dummyDataRequiredForDeleteOverride"; + private static const X_HTTP_OVERRIDE_KEY:String = "X-HTTP-Method-Override"; + private static const CONTENT_TYPE_HEADER_KEY:String = "Content-Type"; + + public function ApiInvoker(apiUsageCredentials:ApiUserCredentials, eventNotifier:EventDispatcher, useProxy:Boolean = true) { + _apiUsageCredentials = apiUsageCredentials; + _useProxyServer = useProxy; + if (_apiUsageCredentials.hostName != null) { + _proxyHostName = _apiUsageCredentials.hostName; + } + _apiPath = _apiUsageCredentials.apiPath; + _proxyPath = _apiUsageCredentials.proxyPath; + _apiProxyServerUrl = _apiUsageCredentials.apiProxyServerUrl; + _apiEventNotifier = eventNotifier; + } + public var _apiEventNotifier:EventDispatcher; + internal var _apiProxyServerUrl:String = ""; + internal var _useProxyServer:Boolean = true; + private var _apiUsageCredentials:ApiUserCredentials; + private var _baseUrl:String = ""; + private var _proxyHostName:String = ""; + private var _apiPath:String = ""; + private var _proxyPath:String = ""; + + public function invokeAPI(resourceURL:String, method:String, queryParams:Dictionary, postObject:Object, headerParams:Dictionary):AsyncToken { + //make the communication + if (_useProxyServer) { + resourceURL = _apiProxyServerUrl + resourceURL; + } + else { + resourceURL = "http://" + _proxyHostName + _apiPath + resourceURL; + } + + var counter:int = 0; + var symbol:String = "&"; + var paramValue:Object; + for (var paramName:String in queryParams) { + paramValue = queryParams[paramName]; + //var key:String = paramName; + // do stuff + symbol = "&"; + if (counter == 0) { + symbol = "?"; + } + resourceURL = resourceURL + symbol + paramName + "=" + paramValue.toString(); + counter++; + + } +// trace(resourceURL); + //create a httpservice and invoke the rest url waiting for response + var requestHeader:Object = new Object(); + if (headerParams != null) { + for (var key:String in headerParams) { + requestHeader[key] = headerParams[key]; + } + } + + resourceURL = ApiUrlHelper.appendTokenInfo(resourceURL, requestHeader, _apiUsageCredentials); + + var bodyData:String = marshal(postObject).toString();//restRequest.postData; + + return doRestCall(resourceURL, onApiRequestResult, onApiRequestFault, method, bodyData, requestHeader, "application/xml"); + + + } + + public function marshal(source:Object):Object { +// trace("marshal got - " + source) + if (source is String) { + return source; + } else if (source is Array && source.length > 0) { + var writer:XMLWriter = new XMLWriter(); + var sourceArray:Array = source as Array; + var arrayEnclosure:String = getArrayEnclosure(sourceArray); + writer.xml.setName(arrayEnclosure); + + for (var i:int = 0; i < sourceArray.length; i++) { + var o:Object = sourceArray[i]; + writer.xml.appendChild(marshal(o)); + } + return writer.xml; + } else + return marshalObject(source); + } + + public function marshalObject(source:Object):XML { + var writer:XMLWriter = new XMLWriter(); + var objDescriptor:XML = describeType(source); + var property:XML; + var propertyType:String; + var propertyValue:Object; + + var qualifiedClassName:String = objDescriptor.@name; + qualifiedClassName = qualifiedClassName.replace("::", "."); + var className:String = qualifiedClassName.substring(qualifiedClassName.lastIndexOf(".") + 1); + className = className().toLowerCase() + className.substring(1); + writer.xml.setName(className); + + for each(property in objDescriptor.elements("variable")) { + propertyValue = source[property.@name]; + if (propertyValue != null) { + if (ObjectUtil.isSimple(propertyValue)) { + writer.addProperty(property.@name, propertyValue.toString()); + } + else { + writer.addProperty(property.@name, marshal(propertyValue).toXMLString()); + } + } + } + for each(property in objDescriptor.elements("accessor")) { + if (property.@access == "readonly") { + continue; + } + propertyValue = source[property.@name]; + if (source[property.@name] != null) { + if (ObjectUtil.isSimple(propertyValue)) { + writer.addProperty(property.@name, propertyValue.toString()); + } + else { + writer.addProperty(property.@name, marshal(propertyValue).toXMLString()); + } + } + } + return writer.xml; + } + + public function escapeString(str:String):String { + return str; + } + + private function doRestCall(url:String, resultFunction:Function, faultFunction:Function = null, + restMethod:String = "GET", + bodyData:Object = null, headers:Object = null, contentType:String = "application/xml"):AsyncToken { + var httpService:HTTPService = new HTTPService(); + + if (headers == null) { + headers = new Object(); + } + httpService.method = restMethod; + + if (restMethod.toUpperCase() != HTTPRequestMessage.GET_METHOD) { + //httpService.method = HTTPRequestMessage.POST_METHOD; - not required as we're using the proxy + if (bodyData == null) { + bodyData = new Object(); + } + + if (restMethod == HTTPRequestMessage.DELETE_METHOD) { + headers[X_HTTP_OVERRIDE_KEY] = HTTPRequestMessage.DELETE_METHOD; + bodyData = DELETE_DATA_DUMMY; + } + else if (restMethod == HTTPRequestMessage.PUT_METHOD) { + headers[X_HTTP_OVERRIDE_KEY] = HTTPRequestMessage.PUT_METHOD; + } + else { + headers[CONTENT_TYPE_HEADER_KEY] = contentType; + } + } + else { + //if the request type is GET and content type is xml then the Flex HTTPService converts it to a POST ... yeah + contentType = null; + } + + httpService.url = url; + httpService.contentType = contentType; + httpService.resultFormat = "e4x"; + httpService.headers = headers; + httpService.addEventListener(ResultEvent.RESULT, resultFunction); + if (faultFunction != null) { + httpService.addEventListener(FaultEvent.FAULT, faultFunction); + } + if (_useProxyServer) { + httpService.useProxy = true; + + var channelSet:ChannelSet = new ChannelSet(); + var httpChannel:HTTPChannel = new HTTPChannel(); + httpChannel.uri = ApiUrlHelper.getProxyUrl(_proxyHostName, _proxyPath); + channelSet.addChannel(httpChannel); + httpService.channelSet = channelSet; + } + + return httpService.send(bodyData); + } + + private function onApiRequestResult(event:ResultEvent):void { + var completionListener:Function = event.token.completionListener; + var result:Object = event.result; + var resultType:Class = event.token.returnType; + var resultObject:Object; + if (resultType != null) { + var context:ASAXBContext = ASAXBContext.newInstance(resultType); + var unmarshaller:Unmarshaller = context.createUnmarshaller(); + var resultXML:XML = new XML(event.result); + try { + resultObject = unmarshaller.unmarshal(resultXML); + } + catch (error:TypeError) { + var errorResponse:Response = new Response(false, null, "Could not unmarshall response"); + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var failureEvent:ApiClientEvent = new ApiClientEvent(event.token.completionEventType); + failureEvent.response = errorResponse; + _apiEventNotifier.dispatchEvent(failureEvent); + } + } + + if (resultObject is ListWrapper) { + resultObject = ListWrapper(resultObject).getList(); + } + } + + var response:Response = new Response(true, resultObject); + response.requestId = event.token.requestId; + var successEventType:String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.SUCCESS_EVENT; + + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var successEvent:ApiClientEvent = new ApiClientEvent(successEventType); + successEvent.response = response; + _apiEventNotifier.dispatchEvent(successEvent); + } + } + + private function onApiRequestFault(event:FaultEvent):void { + var completionListener:Function = event.token.completionListener; + if (completionListener != null) { + completionListener.call(null, new Response(false, null, event.fault.faultString)); + } + + var failureEventType:String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.FAILURE_EVENT; + + if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher + var failureEvent:ApiClientEvent = new ApiClientEvent(failureEventType); + failureEvent.response = new Response(false, null, event.fault.faultString); + _apiEventNotifier.dispatchEvent(failureEvent); + } + } + + private function getArrayEnclosure(arr:Array):String { + if (arr != null && arr.length > 0) { + var className:String = flash.utils.getQualifiedClassName(arr[0]) + if (className.indexOf("::") > 0) + className = className.substr(className.indexOf("::") + 2, className.length) + + return className.substring(0, 1).toLowerCase() + className.substring(1, className.length) + "s"; + } else + return ""; + } + + +} +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ApiUrlHelper.as b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ApiUrlHelper.as new file mode 100644 index 00000000000..4333c6c7e4c --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ApiUrlHelper.as @@ -0,0 +1,41 @@ +package io.swagger.common { +import io.swagger.common.ApiUserCredentials; + +/** + * @private + * Internal class for the Rest client + */ +internal class ApiUrlHelper { + + private static const API_URL_KEY:String = "api_key"; + private static const AUTH_TOKEN_URL_KEY:String = "auth_token"; + + private static const HTTP_URL_PREFIX:String = "http://"; + + 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){ + restUrl += ( "?" + API_URL_KEY + "=" + credentials.apiToken ); + } + else{ + restUrl += ( "&" + API_URL_KEY + "=" + credentials.apiToken ); + } + requestHeader.api_key = credentials.apiToken; + + if(credentials.authToken != null && credentials.authToken != ""){ + restUrl += ( "&" + AUTH_TOKEN_URL_KEY + "=" + credentials.authToken ); + requestHeader.auth_token = credentials.authToken; + } + + return restUrl; + } + + internal static function getProxyUrl(hostName: String, proxyPath: String): String{ + if (hostName(hostName.length - 1) == "/") //remove trailing slash + { + hostName = hostName.substring(0, hostName.length - 1); + } + return HTTP_URL_PREFIX + hostName + proxyPath; + } +} +} diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ApiUserCredentials.as b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ApiUserCredentials.as new file mode 100644 index 00000000000..118d917a247 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ApiUserCredentials.as @@ -0,0 +1,63 @@ +package io.swagger.common { + +/** + * Api account credentials. + * + */ +public class ApiUserCredentials { + /** + * An apitoken that is passed along with the requests + */ + public var apiToken:String; + /** + * A valid auth_token which could be necessary for certain operations + */ + public var authToken:String; + /** + * The userId which could be required for certain operations + */ + public var userId:Number; + /** + * 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; + + /** + * 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; + } + +} +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ListWrapper.as b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/ListWrapper.as new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggercommon/SwaggerApi.as b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/SwaggerApi.as new file mode 100644 index 00000000000..059de642a74 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/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/swaggercommon/XMLWriter.as b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/XMLWriter.as new file mode 100644 index 00000000000..0b08066775b --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swaggercommon/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/io/swaggerevent/ApiClientEvent.as b/samples/client/petstore/flash/src/main/flex/io/swaggerevent/ApiClientEvent.as new file mode 100644 index 00000000000..d64cd304d49 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swaggerevent/ApiClientEvent.as @@ -0,0 +1,36 @@ +package io.swagger.event { +import io.swagger.event.Response; + +import flash.events.Event; + +/** + * Event dispatched by the SDK to communicate success events and failure events. + * 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{ + + /** + * Event type to indicate a unsuccessful invocation + */ + public static const FAILURE_EVENT:String = "unsuccesfulInvocation"; + + /** + * Event type to indicate a successful invocation + */ + public static const SUCCESS_EVENT:String = "successfulInvocation"; + + /** + * The Response object which contains response info + */ + 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/io/swaggerevent/Response.as b/samples/client/petstore/flash/src/main/flex/io/swaggerevent/Response.as new file mode 100644 index 00000000000..a43b7980a38 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swaggerevent/Response.as @@ -0,0 +1,56 @@ +package io.swagger.event { + +/** + * Response contains info on the result of an API invocation. + * A completion listener will expect this Response object. + */ +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: "; + + 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){ + errorCode = String(errorCodeArray[0]); + } + 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 toString(): String { + return "Response (requestId:" + requestId + "; isSuccess:" + isSuccess + "; errorMessage:" + errorMessage + "; payload:" + payload + ")"; + } +} +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggerexception/ApiErrorCodes.as b/samples/client/petstore/flash/src/main/flex/io/swaggerexception/ApiErrorCodes.as new file mode 100644 index 00000000000..e5ea46480aa --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/io/swaggerexception/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/swaggerexception/ApiErrors.as b/samples/client/petstore/flash/src/main/flex/io/swaggerexception/ApiErrors.as new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ASAXB-0.1.1.swc b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ASAXB-0.1.1.swc new file mode 100644 index 00000000000..c9359026784 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ASAXB-0.1.1.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggerlib/as3corelib.swc b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/as3corelib.swc new file mode 100644 index 00000000000..12dd6b3b0a6 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/as3corelib.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc new file mode 100644 index 00000000000..e41bc68abd9 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc new file mode 100644 index 00000000000..8bbdf8b86a0 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc new file mode 100644 index 00000000000..b69064ac765 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc new file mode 100644 index 00000000000..a90af750bb5 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/io/swaggerlib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/lib/ASAXB-0.1.1.swc b/samples/client/petstore/flash/src/main/flex/lib/ASAXB-0.1.1.swc new file mode 100644 index 00000000000..c9359026784 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/lib/ASAXB-0.1.1.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/lib/as3corelib.swc b/samples/client/petstore/flash/src/main/flex/lib/as3corelib.swc new file mode 100644 index 00000000000..12dd6b3b0a6 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/lib/as3corelib.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/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 new file mode 100644 index 00000000000..e41bc68abd9 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/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 new file mode 100644 index 00000000000..8bbdf8b86a0 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/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 new file mode 100644 index 00000000000..b69064ac765 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/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 new file mode 100644 index 00000000000..a90af750bb5 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flex/lib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/api/pet_api.py b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/api/pet_api.py new file mode 100644 index 00000000000..c72965596ef --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/api/pet_api.py @@ -0,0 +1,276 @@ +package src/main/flex/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 src/main/flex/io.swagger/client/model.Pet; +import java.io.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, io.swagger.codegen.CodegenParameter@4afa1477, 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, io.swagger.codegen.CodegenParameter@6855b715, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "add_pet"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_status (status: Array[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(); + + + + 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[Pet]; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_tags (tags: Array[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(); + + + + 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[Pet]; + return requestId; + + } + + /* + * Returns Pet + */ + public function get_pet_by_id (pet_id: Number): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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 (pet_id: String, name: String, status: String): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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 (pet_id: Number, api_key: String): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + headerParams["api_key"] = toPathValue(api_key); + + + 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 (pet_id: Number, additional_metadata: String, file: File): String { + // create path and map variables + var path: String = "/pet/{petId}/uploadImage".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/api/store_api.py b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/api/store_api.py new file mode 100644 index 00000000000..f9db26357aa --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/api/store_api.py @@ -0,0 +1,151 @@ +package src/main/flex/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 src/main/flex/io.swagger/client/model.Dictionary; +import src/main/flex/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(str, Number) + */ + 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(str, Number); + 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, io.swagger.codegen.CodegenParameter@5366f936, 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 (order_id: String): String { + // create path and map variables + var path: String = "/store/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "order_id" + "}", getApiInvoker().escapeString(order_id)); + + // 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 (order_id: String): String { + // create path and map variables + var path: String = "/store/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "order_id" + "}", getApiInvoker().escapeString(order_id)); + + // 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/api/user_api.py b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/api/user_api.py new file mode 100644 index 00000000000..5376388feed --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/api/user_api.py @@ -0,0 +1,275 @@ +package src/main/flex/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 src/main/flex/io.swagger/client/model.User; +import java.util.List; + +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, io.swagger.codegen.CodegenParameter@d3d7fa1, 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[User]): 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, io.swagger.codegen.CodegenParameter@408629d1, 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[User]): 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, io.swagger.codegen.CodegenParameter@2823796f, 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, io.swagger.codegen.CodegenParameter@30f97aff, 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/category.py b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/category.py new file mode 100644 index 00000000000..6c73879401c --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/category.py @@ -0,0 +1,40 @@ +package src/main/flex/io.swagger/client/model { + + + [XmlRootNode(name="Category")] + public class Category { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + 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/src/main/flex/io/swagger/client/model/order.py b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/order.py new file mode 100644 index 00000000000..48b24c09c74 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/order.py @@ -0,0 +1,85 @@ +package src/main/flex/io.swagger/client/model { + + + [XmlRootNode(name="Order")] + public class Order { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="pet_id")] + + public var pet_id: Number = None; + + + + + + + [XmlElement(name="quantity")] + + public var quantity: Number = None; + + + + + + + [XmlElement(name="ship_date")] + + public var ship_date: Date = None; + + + + /* Order Status */ + + + + [XmlElement(name="status")] + + public var status: String = None; + + + + + + + [XmlElement(name="complete")] + + public var complete: Boolean = None; + + + + public function toString(): String { + var str: String = "Order: "; + + str += " (id: " + id + ")"; + + str += " (pet_id: " + pet_id + ")"; + + str += " (quantity: " + quantity + ")"; + + str += " (ship_date: " + ship_date + ")"; + + str += " (status: " + status + ")"; + + str += " (complete: " + complete + ")"; + + return str; + } + + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/pet.py b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/pet.py new file mode 100644 index 00000000000..9991a09ebcb --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/pet.py @@ -0,0 +1,86 @@ +package src/main/flex/io.swagger/client/model { + +import src/main/flex/io.swagger/client/model.Category; +import src/main/flex/io.swagger/client/model.Tag; +import java.util.List; + + [XmlRootNode(name="Pet")] + public class Pet { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="category")] + + public var category: Category = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + + + + + public var photo_urls: Array[String] = None; + + + + + + + + public var tags: Array[Tag] = None; + + + + /* pet status in the store */ + + + + [XmlElement(name="status")] + + public var status: String = None; + + + + public function toString(): String { + var str: String = "Pet: "; + + str += " (id: " + id + ")"; + + str += " (category: " + category + ")"; + + str += " (name: " + name + ")"; + + str += " (photo_urls: " + photo_urls + ")"; + + str += " (tags: " + tags + ")"; + + str += " (status: " + status + ")"; + + return str; + } + + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/tag.py b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/tag.py new file mode 100644 index 00000000000..0519f3ec33e --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/tag.py @@ -0,0 +1,40 @@ +package src/main/flex/io.swagger/client/model { + + + [XmlRootNode(name="Tag")] + public class Tag { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + 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/src/main/flex/io/swagger/client/model/user.py b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/user.py new file mode 100644 index 00000000000..2dabd7c0ee7 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/src/main/flex/io/swagger/client/model/user.py @@ -0,0 +1,107 @@ +package src/main/flex/io.swagger/client/model { + + + [XmlRootNode(name="User")] + public class User { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="username")] + + public var username: String = None; + + + + + + + [XmlElement(name="first_name")] + + public var first_name: String = None; + + + + + + + [XmlElement(name="last_name")] + + public var last_name: String = None; + + + + + + + [XmlElement(name="email")] + + public var email: String = None; + + + + + + + [XmlElement(name="password")] + + public var password: String = None; + + + + + + + [XmlElement(name="phone")] + + public var phone: String = None; + + + + /* User Status */ + + + + [XmlElement(name="user_status")] + + public var user_status: Number = None; + + + + public function toString(): String { + var str: String = "User: "; + + str += " (id: " + id + ")"; + + str += " (username: " + username + ")"; + + str += " (first_name: " + first_name + ")"; + + str += " (last_name: " + last_name + ")"; + + str += " (email: " + email + ")"; + + str += " (password: " + password + ")"; + + str += " (phone: " + phone + ")"; + + str += " (user_status: " + user_status + ")"; + + return str; + } + + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flex/swagger/client/apis/pet_api.py b/samples/client/petstore/flash/src/main/flex/swagger/client/apis/pet_api.py new file mode 100644 index 00000000000..b12bf3f19cb --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/swagger/client/apis/pet_api.py @@ -0,0 +1,276 @@ +package swagger.client/apis { + +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 swagger.client/models.Pet; +import java.io.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, io.swagger.codegen.CodegenParameter@5366f936, 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, io.swagger.codegen.CodegenParameter@d737301, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "add_pet"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_status (status: Array[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(); + + + + 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[Pet]; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_tags (tags: Array[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(); + + + + 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[Pet]; + return requestId; + + } + + /* + * Returns Pet + */ + public function get_pet_by_id (pet_id: Number): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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 (pet_id: String, name: String, status: String): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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 (pet_id: Number, api_key: String): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + headerParams["api_key"] = toPathValue(api_key); + + + 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 (pet_id: Number, additional_metadata: String, file: File): String { + // create path and map variables + var path: String = "/pet/{petId}/uploadImage".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/swagger/client/apis/store_api.py b/samples/client/petstore/flash/src/main/flex/swagger/client/apis/store_api.py new file mode 100644 index 00000000000..2f74c15d67f --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/swagger/client/apis/store_api.py @@ -0,0 +1,151 @@ +package swagger.client/apis { + +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 swagger.client/models.Dictionary; +import swagger.client/models.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(str, Number) + */ + 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(str, Number); + 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, io.swagger.codegen.CodegenParameter@16834d8d, 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 (order_id: String): String { + // create path and map variables + var path: String = "/store/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "order_id" + "}", getApiInvoker().escapeString(order_id)); + + // 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 (order_id: String): String { + // create path and map variables + var path: String = "/store/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "order_id" + "}", getApiInvoker().escapeString(order_id)); + + // 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/swagger/client/apis/user_api.py b/samples/client/petstore/flash/src/main/flex/swagger/client/apis/user_api.py new file mode 100644 index 00000000000..758bd0de276 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/swagger/client/apis/user_api.py @@ -0,0 +1,275 @@ +package swagger.client/apis { + +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 swagger.client/models.User; +import java.util.List; + +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, io.swagger.codegen.CodegenParameter@2823796f, 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[User]): 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, io.swagger.codegen.CodegenParameter@30f97aff, 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[User]): 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, io.swagger.codegen.CodegenParameter@4afa1477, 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, io.swagger.codegen.CodegenParameter@6855b715, 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/src/main/flex/swagger/client/models/category.py b/samples/client/petstore/flash/src/main/flex/swagger/client/models/category.py new file mode 100644 index 00000000000..ecc6fd2164a --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/swagger/client/models/category.py @@ -0,0 +1,40 @@ +package swagger.client/models { + + + [XmlRootNode(name="Category")] + public class Category { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + 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/swagger/client/models/order.py b/samples/client/petstore/flash/src/main/flex/swagger/client/models/order.py new file mode 100644 index 00000000000..f152dcd1912 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/swagger/client/models/order.py @@ -0,0 +1,85 @@ +package swagger.client/models { + + + [XmlRootNode(name="Order")] + public class Order { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="pet_id")] + + public var pet_id: Number = None; + + + + + + + [XmlElement(name="quantity")] + + public var quantity: Number = None; + + + + + + + [XmlElement(name="ship_date")] + + public var ship_date: Date = None; + + + + /* Order Status */ + + + + [XmlElement(name="status")] + + public var status: String = None; + + + + + + + [XmlElement(name="complete")] + + public var complete: Boolean = None; + + + + public function toString(): String { + var str: String = "Order: "; + + str += " (id: " + id + ")"; + + str += " (pet_id: " + pet_id + ")"; + + str += " (quantity: " + quantity + ")"; + + str += " (ship_date: " + ship_date + ")"; + + str += " (status: " + status + ")"; + + str += " (complete: " + complete + ")"; + + return str; + } + + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flex/swagger/client/models/pet.py b/samples/client/petstore/flash/src/main/flex/swagger/client/models/pet.py new file mode 100644 index 00000000000..45d3829fc23 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/swagger/client/models/pet.py @@ -0,0 +1,86 @@ +package swagger.client/models { + +import swagger.client/models.Category; +import swagger.client/models.Tag; +import java.util.List; + + [XmlRootNode(name="Pet")] + public class Pet { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="category")] + + public var category: Category = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + + + + + public var photo_urls: Array[String] = None; + + + + + + + + public var tags: Array[Tag] = None; + + + + /* pet status in the store */ + + + + [XmlElement(name="status")] + + public var status: String = None; + + + + public function toString(): String { + var str: String = "Pet: "; + + str += " (id: " + id + ")"; + + str += " (category: " + category + ")"; + + str += " (name: " + name + ")"; + + str += " (photo_urls: " + photo_urls + ")"; + + str += " (tags: " + tags + ")"; + + str += " (status: " + status + ")"; + + return str; + } + + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flex/swagger/client/models/tag.py b/samples/client/petstore/flash/src/main/flex/swagger/client/models/tag.py new file mode 100644 index 00000000000..68c1ec03e58 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/swagger/client/models/tag.py @@ -0,0 +1,40 @@ +package swagger.client/models { + + + [XmlRootNode(name="Tag")] + public class Tag { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + 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/swagger/client/models/user.py b/samples/client/petstore/flash/src/main/flex/swagger/client/models/user.py new file mode 100644 index 00000000000..a1a1a9c3f63 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flex/swagger/client/models/user.py @@ -0,0 +1,107 @@ +package swagger.client/models { + + + [XmlRootNode(name="User")] + public class User { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="username")] + + public var username: String = None; + + + + + + + [XmlElement(name="first_name")] + + public var first_name: String = None; + + + + + + + [XmlElement(name="last_name")] + + public var last_name: String = None; + + + + + + + [XmlElement(name="email")] + + public var email: String = None; + + + + + + + [XmlElement(name="password")] + + public var password: String = None; + + + + + + + [XmlElement(name="phone")] + + public var phone: String = None; + + + + /* User Status */ + + + + [XmlElement(name="user_status")] + + public var user_status: Number = None; + + + + public function toString(): String { + var str: String = "User: "; + + str += " (id: " + id + ")"; + + str += " (username: " + username + ")"; + + str += " (first_name: " + first_name + ")"; + + str += " (last_name: " + last_name + ")"; + + str += " (email: " + email + ")"; + + str += " (password: " + password + ")"; + + str += " (phone: " + phone + ")"; + + str += " (user_status: " + user_status + ")"; + + return str; + } + + +} + + +} diff --git a/samples/client/petstore/flash/src/main/flexbin/AirExecutorApp-app.xml b/samples/client/petstore/flash/src/main/flexbin/AirExecutorApp-app.xml new file mode 100644 index 00000000000..1dbaf98e644 --- /dev/null +++ b/samples/client/petstore/flash/src/main/flexbin/AirExecutorApp-app.xml @@ -0,0 +1,146 @@ + + + + + + + AirExecutorApp + + + AirExecutorApp + + + AirExecutorApp + + + v1 + + + + + + + + + + + + + + + AirExecutorApp.swf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/flash/src/main/flexlib/ASAXB-0.1.1.swc b/samples/client/petstore/flash/src/main/flexlib/ASAXB-0.1.1.swc new file mode 100644 index 00000000000..c9359026784 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flexlib/ASAXB-0.1.1.swc differ diff --git a/samples/client/petstore/flash/src/main/flexlib/as3corelib.swc b/samples/client/petstore/flash/src/main/flexlib/as3corelib.swc new file mode 100644 index 00000000000..12dd6b3b0a6 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flexlib/as3corelib.swc differ diff --git a/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc new file mode 100644 index 00000000000..e41bc68abd9 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc new file mode 100644 index 00000000000..8bbdf8b86a0 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc new file mode 100644 index 00000000000..b69064ac765 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc b/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc new file mode 100644 index 00000000000..a90af750bb5 Binary files /dev/null and b/samples/client/petstore/flash/src/main/flexlib/ext/flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc differ diff --git a/samples/client/petstore/flash/swagger/client/apis/pet_api.py b/samples/client/petstore/flash/swagger/client/apis/pet_api.py new file mode 100644 index 00000000000..05cacc079ca --- /dev/null +++ b/samples/client/petstore/flash/swagger/client/apis/pet_api.py @@ -0,0 +1,276 @@ +package swagger.client/apis { + +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 swagger.client/models.Pet; +import java.io.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, io.swagger.codegen.CodegenParameter@30f97aff, 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, io.swagger.codegen.CodegenParameter@4afa1477, headerParams); + + var requestId: String = getUniqueId(); + + token.requestId = requestId; + token.completionEventType = "add_pet"; + + token.returnType = null ; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_status (status: Array[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(); + + + + 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[Pet]; + return requestId; + + } + + /* + * Returns Array[Pet] + */ + public function find_pets_by_tags (tags: Array[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(); + + + + 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[Pet]; + return requestId; + + } + + /* + * Returns Pet + */ + public function get_pet_by_id (pet_id: Number): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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 (pet_id: String, name: String, status: String): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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 (pet_id: Number, api_key: String): String { + // create path and map variables + var path: String = "/pet/{petId}".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // query params + var queryParams: Dictionary = new Dictionary(); + var headerParams: Dictionary = new Dictionary(); + + + + + + headerParams["api_key"] = toPathValue(api_key); + + + 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 (pet_id: Number, additional_metadata: String, file: File): String { + // create path and map variables + var path: String = "/pet/{petId}/uploadImage".replace(/{format}/g,"xml").replace("{" + "pet_id" + "}", getApiInvoker().escapeString(pet_id)); + + // 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/swagger/client/apis/store_api.py b/samples/client/petstore/flash/swagger/client/apis/store_api.py new file mode 100644 index 00000000000..77644048989 --- /dev/null +++ b/samples/client/petstore/flash/swagger/client/apis/store_api.py @@ -0,0 +1,151 @@ +package swagger.client/apis { + +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 swagger.client/models.Dictionary; +import swagger.client/models.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(str, Number) + */ + 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(str, Number); + 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, io.swagger.codegen.CodegenParameter@6855b715, 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 (order_id: String): String { + // create path and map variables + var path: String = "/store/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "order_id" + "}", getApiInvoker().escapeString(order_id)); + + // 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 (order_id: String): String { + // create path and map variables + var path: String = "/store/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "order_id" + "}", getApiInvoker().escapeString(order_id)); + + // 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/swagger/client/apis/user_api.py b/samples/client/petstore/flash/swagger/client/apis/user_api.py new file mode 100644 index 00000000000..820a5628486 --- /dev/null +++ b/samples/client/petstore/flash/swagger/client/apis/user_api.py @@ -0,0 +1,275 @@ +package swagger.client/apis { + +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 swagger.client/models.User; +import java.util.List; + +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, io.swagger.codegen.CodegenParameter@21668d9, 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[User]): 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, io.swagger.codegen.CodegenParameter@d3d7fa1, 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[User]): 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, io.swagger.codegen.CodegenParameter@408629d1, 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, io.swagger.codegen.CodegenParameter@2823796f, 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; + + } + +} + +} \ No newline at end of file diff --git a/samples/client/petstore/flash/swagger/client/models/category.py b/samples/client/petstore/flash/swagger/client/models/category.py new file mode 100644 index 00000000000..ecc6fd2164a --- /dev/null +++ b/samples/client/petstore/flash/swagger/client/models/category.py @@ -0,0 +1,40 @@ +package swagger.client/models { + + + [XmlRootNode(name="Category")] + public class Category { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + public function toString(): String { + var str: String = "Category: "; + + str += " (id: " + id + ")"; + + str += " (name: " + name + ")"; + + return str; + } + + +} + + +} diff --git a/samples/client/petstore/flash/swagger/client/models/order.py b/samples/client/petstore/flash/swagger/client/models/order.py new file mode 100644 index 00000000000..f152dcd1912 --- /dev/null +++ b/samples/client/petstore/flash/swagger/client/models/order.py @@ -0,0 +1,85 @@ +package swagger.client/models { + + + [XmlRootNode(name="Order")] + public class Order { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="pet_id")] + + public var pet_id: Number = None; + + + + + + + [XmlElement(name="quantity")] + + public var quantity: Number = None; + + + + + + + [XmlElement(name="ship_date")] + + public var ship_date: Date = None; + + + + /* Order Status */ + + + + [XmlElement(name="status")] + + public var status: String = None; + + + + + + + [XmlElement(name="complete")] + + public var complete: Boolean = None; + + + + public function toString(): String { + var str: String = "Order: "; + + str += " (id: " + id + ")"; + + str += " (pet_id: " + pet_id + ")"; + + str += " (quantity: " + quantity + ")"; + + str += " (ship_date: " + ship_date + ")"; + + str += " (status: " + status + ")"; + + str += " (complete: " + complete + ")"; + + return str; + } + + +} + + +} diff --git a/samples/client/petstore/flash/swagger/client/models/pet.py b/samples/client/petstore/flash/swagger/client/models/pet.py new file mode 100644 index 00000000000..45d3829fc23 --- /dev/null +++ b/samples/client/petstore/flash/swagger/client/models/pet.py @@ -0,0 +1,86 @@ +package swagger.client/models { + +import swagger.client/models.Category; +import swagger.client/models.Tag; +import java.util.List; + + [XmlRootNode(name="Pet")] + public class Pet { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="category")] + + public var category: Category = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + + + + + public var photo_urls: Array[String] = None; + + + + + + + + public var tags: Array[Tag] = None; + + + + /* pet status in the store */ + + + + [XmlElement(name="status")] + + public var status: String = None; + + + + public function toString(): String { + var str: String = "Pet: "; + + str += " (id: " + id + ")"; + + str += " (category: " + category + ")"; + + str += " (name: " + name + ")"; + + str += " (photo_urls: " + photo_urls + ")"; + + str += " (tags: " + tags + ")"; + + str += " (status: " + status + ")"; + + return str; + } + + +} + + +} diff --git a/samples/client/petstore/flash/swagger/client/models/tag.py b/samples/client/petstore/flash/swagger/client/models/tag.py new file mode 100644 index 00000000000..68c1ec03e58 --- /dev/null +++ b/samples/client/petstore/flash/swagger/client/models/tag.py @@ -0,0 +1,40 @@ +package swagger.client/models { + + + [XmlRootNode(name="Tag")] + public class Tag { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="name")] + + public var name: String = None; + + + + public function toString(): String { + var str: String = "Tag: "; + + str += " (id: " + id + ")"; + + str += " (name: " + name + ")"; + + return str; + } + + +} + + +} diff --git a/samples/client/petstore/flash/swagger/client/models/user.py b/samples/client/petstore/flash/swagger/client/models/user.py new file mode 100644 index 00000000000..a1a1a9c3f63 --- /dev/null +++ b/samples/client/petstore/flash/swagger/client/models/user.py @@ -0,0 +1,107 @@ +package swagger.client/models { + + + [XmlRootNode(name="User")] + public class User { + + + + + + [XmlElement(name="id")] + + public var id: Number = None; + + + + + + + [XmlElement(name="username")] + + public var username: String = None; + + + + + + + [XmlElement(name="first_name")] + + public var first_name: String = None; + + + + + + + [XmlElement(name="last_name")] + + public var last_name: String = None; + + + + + + + [XmlElement(name="email")] + + public var email: String = None; + + + + + + + [XmlElement(name="password")] + + public var password: String = None; + + + + + + + [XmlElement(name="phone")] + + public var phone: String = None; + + + + /* User Status */ + + + + [XmlElement(name="user_status")] + + public var user_status: Number = None; + + + + public function toString(): String { + var str: String = "User: "; + + str += " (id: " + id + ")"; + + str += " (username: " + username + ")"; + + str += " (first_name: " + first_name + ")"; + + str += " (last_name: " + last_name + ")"; + + str += " (email: " + email + ")"; + + str += " (password: " + password + ")"; + + str += " (phone: " + phone + ")"; + + str += " (user_status: " + user_status + ")"; + + return str; + } + + +} + + +}