Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
protected String packageVersion;

protected String invokerPackage = "io.swagger";
protected String sourceFolder = "flash";
protected String sourceFolder = "src/main/flex";

public FlashClientCodegen() {
super();
Expand Down Expand Up @@ -83,7 +83,7 @@ public FlashClientCodegen() {
.defaultValue("1.0.0"));
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "source folder for generated " +
"code. e.g. flash"));
"code. e.g. src/main/flex"));

}

Expand Down Expand Up @@ -124,23 +124,23 @@ public void processOpts() {
//modelPackage = invokerPackage + File.separatorChar + "client" + File.separatorChar + "model";
//apiPackage = invokerPackage + File.separatorChar + "client" + File.separatorChar + "api";

final String invokerFolder = (sourceFolder + File.separator + "src/" + invokerPackage + File.separator).replace(".", File.separator).replace('.', File.separatorChar);
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", "ApiError.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("README.txt", sourceFolder, "README.txt"));
//supportingFiles.add(new SupportingFile("AirExecutorApp-app.xml", sourceFolder + File.separatorChar
// + "bin", "AirExecutorApp-app.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
Expand Down Expand Up @@ -181,13 +181,13 @@ public String escapeReservedWord(String name) {

@Override
public String apiFileFolder() {
return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar + "src/"
return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar
+ apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
}

@Override
public String modelFileFolder() {
return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar + "src/"
return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar
+ modelPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
}

Expand Down Expand Up @@ -253,7 +253,7 @@ public String toDefaultValue(Property p) {
} else if (p instanceof ArrayProperty) {
return "new Array()";
} else {
return "NaN";
return "null";
}
}

Expand Down
27 changes: 3 additions & 24 deletions modules/swagger-codegen/src/main/resources/flash/ApiInvoker.as
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@ package io.swagger.common {
import io.swagger.event.ApiClientEvent;
import io.swagger.event.Response;

import flash.events.EventDispatcher;
import flash.utils.*;
import mx.rpc.AsyncToken;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.utils.ObjectUtil;
import mx.rpc.http.HTTPService;
import mx.messaging.messages.HTTPRequestMessage;
import mx.messaging.ChannelSet;
import mx.messaging.channels.DirectHTTPChannel;
import asaxb.xml.bind.ASAXBContext;
import asaxb.xml.bind.Unmarshaller;

public class ApiInvoker extends EventDispatcher {

private static const DELETE_DATA_DUMMY:String = "dummyDataRequiredForDeleteOverride";
Expand Down Expand Up @@ -112,7 +99,7 @@ public class ApiInvoker extends EventDispatcher {
var qualifiedClassName:String = objDescriptor.@name;
qualifiedClassName = qualifiedClassName.replace("::", ".");
var className:String = qualifiedClassName.substring(qualifiedClassName.lastIndexOf(".") + 1);
className = className.toLowerCase() + className.substring(1);
className = className().toLowerCase() + className.substring(1);
writer.xml.setName(className);

for each(property in objDescriptor.elements("variable")) {
Expand Down Expand Up @@ -191,7 +178,7 @@ public class ApiInvoker extends EventDispatcher {
httpService.useProxy = true;

var channelSet:ChannelSet = new ChannelSet();
var httpChannel:DirectHTTPChannel = new DirectHTTPChannel("");
var httpChannel:HTTPChannel = new HTTPChannel();
httpChannel.uri = ApiUrlHelper.getProxyUrl(_proxyHostName, _proxyPath);
channelSet.addChannel(httpChannel);
httpService.channelSet = channelSet;
Expand All @@ -201,11 +188,6 @@ public class ApiInvoker extends EventDispatcher {
}

private function onApiRequestResult(event:ResultEvent):void {

// I put this in comments. Here, it's trying to parse XML and it fails if it's not XML.
// Therefore, it's better to have the raw result that we can parse as we want.
// TODO: Create different parser (JSON, XML, etc.)
/*
var completionListener:Function = event.token.completionListener;
var result:Object = event.result;
var resultType:Class = event.token.returnType;
Expand All @@ -232,9 +214,6 @@ public class ApiInvoker extends EventDispatcher {
}

var response:Response = new Response(true, resultObject);
*/

var response:Response = new Response(true, event.result);
response.requestId = event.token.requestId;
var successEventType:String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.SUCCESS_EVENT;

Expand Down Expand Up @@ -273,4 +252,4 @@ public class ApiInvoker extends EventDispatcher {


}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class ApiUrlHelper {
}

internal static function getProxyUrl(hostName: String, proxyPath: String): String{
if (hostName..charAt(hostName.length) == "/") //remove trailing slash
if (hostName(hostName.length - 1) == "/") //remove trailing slash
{
hostName = hostName.substring(0, hostName.length - 1);
}
Expand Down
65 changes: 0 additions & 65 deletions modules/swagger-codegen/src/main/resources/flash/README.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class {{classname}} extends SwaggerApi {
/*
* Returns {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}
*/
public function {{nickname}} ({{#allParams}}{{paramName}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): String {
public function {{nickname}} ({{#allParams}}{{paramName}}: {{{dataType}}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): String {
// create path and map variables
var path: String = "{{path}}".replace(/{format}/g,"xml"){{#pathParams}}.replace("{" + "{{paramName}}" + "}", getApiInvoker().escapeString({{{paramName}}})){{/pathParams}};

Expand Down
65 changes: 0 additions & 65 deletions samples/client/petstore/flash/flash/README.txt

This file was deleted.

29 changes: 0 additions & 29 deletions samples/client/petstore/flash/flash/build.properties

This file was deleted.

Loading