forked from loafle/openapi-generator-original
updated to 2.0
This commit is contained in:
parent
aa162b9393
commit
9e3fc6603f
@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"apiUrl":"http://localhost:8002/api/",
|
|
||||||
|
|
||||||
"apiKey":"special-key",
|
|
||||||
|
|
||||||
"defaultServiceBaseClass":"SwaggerApi",
|
|
||||||
|
|
||||||
"defaultModelBaseClass":"Object",
|
|
||||||
|
|
||||||
"serviceBaseClasses":{},
|
|
||||||
|
|
||||||
"defaultModelImports":[],
|
|
||||||
|
|
||||||
"defaultServiceImports":[],
|
|
||||||
|
|
||||||
"modelPackageName":"com.wordnik.swagger.model",
|
|
||||||
|
|
||||||
"apiPackageName":"com.wordnik.swagger.api",
|
|
||||||
|
|
||||||
"ignoreMethods":[],
|
|
||||||
|
|
||||||
"ignoreModels":[],
|
|
||||||
|
|
||||||
"outputDirectory":"../swagger-sample-app/sdk-libs/src/main/as3/com/wordnik/swagger/",
|
|
||||||
|
|
||||||
"libraryHome":"../swagger-sample-app/sdk-libs"
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
# 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/as3
|
|
||||||
|
|
||||||
# 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/as3
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# Home directory for flex sdk 3, change this to build for Mac or PC using # as comment
|
|
||||||
# SDK_HOME = C:/Program Files/Adobe/Flash Builder 4/sdks/3.5.0
|
|
||||||
# SDK_HOME = /Applications/Adobe Flash Builder 4/sdks/3.5.0
|
|
||||||
# SDK_HOME = /usr/local/flex_sdk_4.1.0/
|
|
||||||
# FLEX_HOME = /usr/local/flex_sdk_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
|
|
||||||
|
|
@ -1,182 +0,0 @@
|
|||||||
<!-- Flex Library Project ASDocs -->
|
|
||||||
|
|
||||||
<project name="AS3SDKCompile" default="compile" basedir=".">
|
|
||||||
|
|
||||||
<!-- import our build properties file -->
|
|
||||||
<property file="./build.properties"/>
|
|
||||||
<property environment="env"/>
|
|
||||||
<property name="FLEX_HOME" value="${FLEX4_SDK_HOME}"/>
|
|
||||||
<property name="FLEX4_HOME" value="${FLEX4_SDK_HOME}"/>
|
|
||||||
|
|
||||||
<!--<property name="flexunit.swc" value="../lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc" />
|
|
||||||
<property name="flexunit-uilistener.swc" value="../lib/ext/flexunit-uilistener-4.1.0_RC2-28-flex_3.5.0.12683.swc" />
|
|
||||||
<property name="flexunit-cilistener.swc" value="../lib/ext/flexunit-cilistener-4.1.0_RC2-28-flex_3.5.0.12683.swc" />-->
|
|
||||||
|
|
||||||
<!-- Flex Ant Tasks used to perform compc and mxml compiling more info at http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks -->
|
|
||||||
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar"/>
|
|
||||||
|
|
||||||
<target name="setup" description="perform an setup operations"/>
|
|
||||||
|
|
||||||
<!-- Execute the ASDoc Compile wich runs 3 seperate tasks in a series -->
|
|
||||||
<target name="compile" description="series of tasks to create docs and swc">
|
|
||||||
|
|
||||||
<!--<antcall target="cleanDir" description="clean the docs directory"/>-->
|
|
||||||
|
|
||||||
<!--<antcall target="asDocs" description="full build of asdocs"/>-->
|
|
||||||
|
|
||||||
<antcall target="buildSWC" description="build the SWC file"/>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="deploy" description="perform an deployment operations"/>
|
|
||||||
|
|
||||||
<target name="install" description="perform an installation operations"/>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
DELETE the existing output folder and files and then re-generate the output folder
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<target name="clean" description="DELETE the existing output folder and files and then re-generate the output folder">
|
|
||||||
|
|
||||||
<delete dir="${basedir}/${docsoutputfolder}" failonerror="true" includeemptydirs="true"/>
|
|
||||||
<delete file="${basedir}/${liboutputfolder}/${liboutputfile}"/>
|
|
||||||
<delete dir="${basedir}/dist" failonerror="true" includeemptydirs="true"/>
|
|
||||||
|
|
||||||
<mkdir dir="${basedir}/${docsoutputfolder}"/>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
Run the ASDoc executable and generate the ASDocs to the new output folder
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<target name="docs" description="Run the ASDoc executable and generate the ASDocs to the new output folder">
|
|
||||||
|
|
||||||
<exec executable="${env.SDK_HOME}/bin/asdoc" failonerror="true">
|
|
||||||
|
|
||||||
<arg line="-doc-sources ${sourcepath}"/>
|
|
||||||
<arg line="-source-path ${sourcepath}"/>
|
|
||||||
<arg line="-footer 'Copyright Wordnik'"/>
|
|
||||||
<arg line="-package com.wordnik.swagger.api 'Contains the apis which are used by clients to make calls to the services deployed'"/>
|
|
||||||
<arg line="-package com.wordnik.swagger.model 'Contains common classes which encapsulate data elements required'"/>
|
|
||||||
<arg line="-package com.wordnik.swagger.common 'Contains classes which are used by the api classes to invoke the deployed api like SwaggerApi - a base class, ApiUserCredentials, etc.''"/>
|
|
||||||
<arg line="-package com.wordnik.swagger.event 'Results of calls made to Wordnik are returned via dispatched events. This package contains such event classes. Right now thats just ApiClientEvent and Response.'"/>
|
|
||||||
<arg line="-package com.wordnik.swagger.exception 'Contains classes that encapsulate the errors generated'"/>
|
|
||||||
|
|
||||||
<arg value="-window-title"/>
|
|
||||||
<arg value="${title}"/>
|
|
||||||
|
|
||||||
<arg value="-main-title"/>
|
|
||||||
<arg value="${title}"/>
|
|
||||||
|
|
||||||
<arg value="-output"/>
|
|
||||||
<arg value="${basedir}/${docsoutputfolder}"/>
|
|
||||||
|
|
||||||
<arg value="-external-library-path"/>
|
|
||||||
<arg value="${basedir}/${libpath}"/>
|
|
||||||
|
|
||||||
</exec>
|
|
||||||
|
|
||||||
<echo>docs created</echo>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
Compile the SWC file library including lib folder and the path to our classes, we use compc for library,
|
|
||||||
check the docs for Flex Ant Tasks, http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks.
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<target name="buildSWC" description="Compile the SWC file for the Librayr Project">
|
|
||||||
|
|
||||||
<compc output="${basedir}/${liboutputfolder}/${liboutputfile}">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Include the path to any external SWC files used in the sdk, you may have to place name of SWC (ASAXB-0.1.1.swc) at end of path.
|
|
||||||
So file path would be file="${basedir}/${libpath}/ASAXB-0.1.1.swc"
|
|
||||||
-->
|
|
||||||
<include-libraries file="${basedir}/${libpath}/" />
|
|
||||||
|
|
||||||
<source-path path-element="${sourcepath}" />
|
|
||||||
|
|
||||||
<keep-as3-metadata name="XmlRootNode"/>
|
|
||||||
<keep-as3-metadata name="XmlElement"/>
|
|
||||||
<keep-as3-metadata name="XmlElements"/>
|
|
||||||
|
|
||||||
<!-- include our Class packages into the build (com folder) -->
|
|
||||||
<include-sources dir="${sourcepath}" includes="*" />
|
|
||||||
|
|
||||||
</compc>
|
|
||||||
|
|
||||||
<echo>SWC created</echo>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="dist" depends="clean, buildSWC, docs">
|
|
||||||
<mkdir dir="${basedir}/dist/lib"/>
|
|
||||||
<mkdir dir="${basedir}/dist/docs"/>
|
|
||||||
<mkdir dir="${basedir}/dist/sample"/>
|
|
||||||
|
|
||||||
<copy file="${basedir}/${liboutputfolder}/${liboutputfile}" todir="${basedir}/dist/lib/">
|
|
||||||
</copy>
|
|
||||||
<copy todir="${basedir}/dist/docs/">
|
|
||||||
<fileset dir="${basedir}/asdoc"/>
|
|
||||||
</copy>
|
|
||||||
|
|
||||||
|
|
||||||
<zip destfile="sample-as3-sdk.zip" basedir="${basedir}/dist" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- Compiles and creates a test app that can be run using the adl - AIR Debug Launcher from command line
|
|
||||||
Note: For the output file to be executed an xml file is needed which points to this output swf - this is not
|
|
||||||
generated here
|
|
||||||
-->
|
|
||||||
<target name="compile-test" depends="buildSWC">
|
|
||||||
<property name="FLEX_HOME" value="${FLEX4_SDK_HOME}"/>
|
|
||||||
<mxmlc
|
|
||||||
static-rsls="false"
|
|
||||||
fork="true"
|
|
||||||
maxmemory="512m"
|
|
||||||
file="${testsourcepath}/AirExecutorApp.mxml"
|
|
||||||
output="${basedir}/${liboutputfolder}/AirExecutorApp.swf"
|
|
||||||
warnings="false"
|
|
||||||
configname="air"
|
|
||||||
locale="en_US">
|
|
||||||
<load-config filename="${FLEX4_HOME}/frameworks/air-config.xml"/>
|
|
||||||
<source-path path-element="${FLEX_HOME}/frameworks"/>
|
|
||||||
|
|
||||||
<compiler.debug>true</compiler.debug>
|
|
||||||
|
|
||||||
|
|
||||||
<source-path path-element="${testsourcepath}" />
|
|
||||||
<!--<source-path path-element="${APP_ROOT}/locale/{locale}" />-->
|
|
||||||
|
|
||||||
<library-path dir="${FLEX_HOME}/frameworks/libs" append="true">
|
|
||||||
<include name="*.swc" />
|
|
||||||
</library-path>
|
|
||||||
<library-path dir="${FLEX_HOME}/frameworks/libs/air" append="true">
|
|
||||||
<include name="*.swc" />
|
|
||||||
</library-path>
|
|
||||||
<library-path dir="${FLEX_HOME}/frameworks/locale" append="true">
|
|
||||||
<include name="{locale}" />
|
|
||||||
</library-path>
|
|
||||||
<library-path dir="${basedir}/${libpath}" append="true">
|
|
||||||
<include name="*.swc" />
|
|
||||||
</library-path>
|
|
||||||
<library-path dir="${basedir}/${liboutputfolder}" append="true">
|
|
||||||
<include name="*.swc" />
|
|
||||||
</library-path>
|
|
||||||
<library-path dir="${basedir}/${libpath}/ext" append="true">
|
|
||||||
<include name="*.swc" />
|
|
||||||
</library-path>
|
|
||||||
|
|
||||||
<verbose-stacktraces>true</verbose-stacktraces>
|
|
||||||
</mxmlc>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"userList":[
|
|
||||||
{
|
|
||||||
"username":"testuser1",
|
|
||||||
"password":"password1",
|
|
||||||
"email":"test1@dummy.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username":"testuser2",
|
|
||||||
"password":"password2",
|
|
||||||
"email":"test2@dummy.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"petList":[
|
|
||||||
{
|
|
||||||
"id":101,
|
|
||||||
"name":"pet1",
|
|
||||||
"photoUrls":["url1","url2"],
|
|
||||||
"tags":[
|
|
||||||
{
|
|
||||||
"id":1,
|
|
||||||
"name":"tag1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":2,
|
|
||||||
"name":"tag2"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"status":"available",
|
|
||||||
"category":{"id":1,"name":"cat1"}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"orderList":[
|
|
||||||
{
|
|
||||||
"id":101,
|
|
||||||
"petId":1,
|
|
||||||
"quantity":1,
|
|
||||||
"status":"placed",
|
|
||||||
"shipDate":13456789
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,265 +0,0 @@
|
|||||||
{
|
|
||||||
"resources" : [
|
|
||||||
{
|
|
||||||
"id" : 1,
|
|
||||||
"name" : "Find Per by Id",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/{petId}",
|
|
||||||
"suggestedMethodName" : "getPetById"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 2,
|
|
||||||
"name" : "Find pets by status",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/findByStatus",
|
|
||||||
"suggestedMethodName" : "findPetsByStatus"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 3,
|
|
||||||
"name" : "Find pets by tags",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/findByTags",
|
|
||||||
"suggestedMethodName" : "findPetsByTags"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 4,
|
|
||||||
"name" : "Add a pet",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/pet.{format}",
|
|
||||||
"suggestedMethodName" : "addPet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 5,
|
|
||||||
"name" : "Update a pet",
|
|
||||||
"httpMethod" : "PUT",
|
|
||||||
"path" : "/pet.{format}",
|
|
||||||
"suggestedMethodName" : "updatePet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 6,
|
|
||||||
"name" : "Create user",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/user.{format}",
|
|
||||||
"suggestedMethodName" : "createUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 7,
|
|
||||||
"name" : "Update user",
|
|
||||||
"httpMethod" : "PUT",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "updateUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 8,
|
|
||||||
"name" : "Delete user",
|
|
||||||
"httpMethod" : "DELETE",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "deleteUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 9,
|
|
||||||
"name" : "Get user by user name",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "getUserByName"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 10,
|
|
||||||
"name" : "Login",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/login",
|
|
||||||
"suggestedMethodName" : "loginUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 11,
|
|
||||||
"name" : "Logout",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/logout",
|
|
||||||
"suggestedMethodName" : "logoutUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 12,
|
|
||||||
"name" : "Find order by id",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/store.{format}/order/{orderId}",
|
|
||||||
"suggestedMethodName" : "getOrderById"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 13,
|
|
||||||
"name" : "Delete order by id",
|
|
||||||
"httpMethod" : "DELETE",
|
|
||||||
"path" : "/store.{format}/order/{orderId}",
|
|
||||||
"suggestedMethodName" : "deleteOrder"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 14,
|
|
||||||
"name" : "Create order",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/store.{format}/order",
|
|
||||||
"suggestedMethodName" : "placeOrder"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"testSuites" : [
|
|
||||||
{
|
|
||||||
"id" : 1,
|
|
||||||
"name" : "Test User service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Create User",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 6,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.userList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Login User",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 10,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}",
|
|
||||||
"password":"${input.userList[0].password}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find user by name",
|
|
||||||
"id" : 3,
|
|
||||||
"resourceId" : 9,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.3).username}",
|
|
||||||
"condition" : "==",
|
|
||||||
"expectedOutput" : "${input.userList[0].username}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Delete user by name",
|
|
||||||
"id" : 4,
|
|
||||||
"resourceId" : 9,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.4)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 2,
|
|
||||||
"name" : "Test Pet service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Add pet",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 4,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.petList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find pet by id",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 1,
|
|
||||||
"input" : {
|
|
||||||
"petId":"1"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "NULL"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find pet by status",
|
|
||||||
"id" : 3,
|
|
||||||
"resourceId" : 2,
|
|
||||||
"input" : {
|
|
||||||
"status":"available,sold,pending"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.3).size}",
|
|
||||||
"condition" : ">",
|
|
||||||
"expectedOutput" : "0"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 3,
|
|
||||||
"name" : "Test Store service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Find order by id",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 12,
|
|
||||||
"input" : {
|
|
||||||
"orderId":"1"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(3.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "NULL"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Place order",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 14,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.orderList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,146 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
|
||||||
<application xmlns="http://ns.adobe.com/air/application/2.0">
|
|
||||||
|
|
||||||
<!-- Adobe AIR Application Descriptor File Template.
|
|
||||||
|
|
||||||
Specifies parameters for identifying, installing, and launching AIR applications.
|
|
||||||
|
|
||||||
xmlns - The Adobe AIR namespace: http://ns.adobe.com/air/application/2.0
|
|
||||||
The last segment of the namespace specifies the version
|
|
||||||
of the AIR runtime required for this application to run.
|
|
||||||
|
|
||||||
minimumPatchLevel - The minimum patch level of the AIR runtime required to run
|
|
||||||
the application. Optional.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- A universally unique application identifier. Must be unique across all AIR applications.
|
|
||||||
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
|
|
||||||
<id>AirExecutorApp</id>
|
|
||||||
|
|
||||||
<!-- Used as the filename for the application. Required. -->
|
|
||||||
<filename>AirExecutorApp</filename>
|
|
||||||
|
|
||||||
<!-- The name that is displayed in the AIR application installer.
|
|
||||||
May have multiple values for each language. See samples or xsd schema file. Optional. -->
|
|
||||||
<name>AirExecutorApp</name>
|
|
||||||
|
|
||||||
<!-- An application version designator (such as "v1", "2.5", or "Alpha 1"). Required. -->
|
|
||||||
<version>v1</version>
|
|
||||||
|
|
||||||
<!-- Description, displayed in the AIR application installer.
|
|
||||||
May have multiple values for each language. See samples or xsd schema file. Optional. -->
|
|
||||||
<!-- <description></description> -->
|
|
||||||
|
|
||||||
<!-- Copyright information. Optional -->
|
|
||||||
<!-- <copyright></copyright> -->
|
|
||||||
|
|
||||||
<!-- Publisher ID. Used if you're updating an application created prior to 1.5.3 -->
|
|
||||||
<!-- <publisherID></publisherID> -->
|
|
||||||
|
|
||||||
<!-- Settings for the application's initial window. Required. -->
|
|
||||||
<initialWindow>
|
|
||||||
<!-- The main SWF or HTML file of the application. Required. -->
|
|
||||||
<!-- Note: In Flash Builder, the SWF reference is set automatically. -->
|
|
||||||
<content>AirExecutorApp.swf</content>
|
|
||||||
|
|
||||||
<!-- The title of the main window. Optional. -->
|
|
||||||
<!-- <title></title> -->
|
|
||||||
|
|
||||||
<!-- The type of system chrome to use (either "standard" or "none"). Optional. Default standard. -->
|
|
||||||
<!-- <systemChrome></systemChrome> -->
|
|
||||||
|
|
||||||
<!-- Whether the window is transparent. Only applicable when systemChrome is none. Optional. Default false. -->
|
|
||||||
<!-- <transparent></transparent> -->
|
|
||||||
|
|
||||||
<!-- Whether the window is initially visible. Optional. Default false. -->
|
|
||||||
<!-- <visible></visible> -->
|
|
||||||
|
|
||||||
<!-- Whether the user can minimize the window. Optional. Default true. -->
|
|
||||||
<!-- <minimizable></minimizable> -->
|
|
||||||
|
|
||||||
<!-- Whether the user can maximize the window. Optional. Default true. -->
|
|
||||||
<!-- <maximizable></maximizable> -->
|
|
||||||
|
|
||||||
<!-- Whether the user can resize the window. Optional. Default true. -->
|
|
||||||
<!-- <resizable></resizable> -->
|
|
||||||
|
|
||||||
<!-- The window's initial width in pixels. Optional. -->
|
|
||||||
<!-- <width></width> -->
|
|
||||||
|
|
||||||
<!-- The window's initial height in pixels. Optional. -->
|
|
||||||
<!-- <height></height> -->
|
|
||||||
|
|
||||||
<!-- The window's initial x position. Optional. -->
|
|
||||||
<!-- <x></x> -->
|
|
||||||
|
|
||||||
<!-- The window's initial y position. Optional. -->
|
|
||||||
<!-- <y></y> -->
|
|
||||||
|
|
||||||
<!-- The window's minimum size, specified as a width/height pair in pixels, such as "400 200". Optional. -->
|
|
||||||
<!-- <minSize></minSize> -->
|
|
||||||
|
|
||||||
<!-- The window's initial maximum size, specified as a width/height pair in pixels, such as "1600 1200". Optional. -->
|
|
||||||
<!-- <maxSize></maxSize> -->
|
|
||||||
</initialWindow>
|
|
||||||
|
|
||||||
<!-- We recommend omitting the supportedProfiles element, -->
|
|
||||||
<!-- which in turn permits your application to be deployed to all -->
|
|
||||||
<!-- devices supported by AIR. If you wish to restrict deployment -->
|
|
||||||
<!-- (i.e., to only mobile devices) then add this element and list -->
|
|
||||||
<!-- only the profiles which your application does support. -->
|
|
||||||
<!-- <supportedProfiles>desktop extendedDesktop mobileDevice extendedMobileDevice</supportedProfiles> -->
|
|
||||||
|
|
||||||
<!-- The subpath of the standard default installation location to use. Optional. -->
|
|
||||||
<!-- <installFolder></installFolder> -->
|
|
||||||
|
|
||||||
<!-- The subpath of the Programs menu to use. (Ignored on operating systems without a Programs menu.) Optional. -->
|
|
||||||
<!-- <programMenuFolder></programMenuFolder> -->
|
|
||||||
|
|
||||||
<!-- The icon the system uses for the application. For at least one resolution,
|
|
||||||
specify the path to a PNG file included in the AIR package. Optional. -->
|
|
||||||
<!-- <icon>
|
|
||||||
<image16x16></image16x16>
|
|
||||||
<image32x32></image32x32>
|
|
||||||
<image48x48></image48x48>
|
|
||||||
<image128x128></image128x128>
|
|
||||||
</icon> -->
|
|
||||||
|
|
||||||
<!-- Whether the application handles the update when a user double-clicks an update version
|
|
||||||
of the AIR file (true), or the default AIR application installer handles the update (false).
|
|
||||||
Optional. Default false. -->
|
|
||||||
<!-- <customUpdateUI></customUpdateUI> -->
|
|
||||||
|
|
||||||
<!-- Whether the application can be launched when the user clicks a link in a web browser.
|
|
||||||
Optional. Default false. -->
|
|
||||||
<!-- <allowBrowserInvocation></allowBrowserInvocation> -->
|
|
||||||
|
|
||||||
<!-- Listing of file types for which the application can register. Optional. -->
|
|
||||||
<!-- <fileTypes> -->
|
|
||||||
|
|
||||||
<!-- Defines one file type. Optional. -->
|
|
||||||
<!-- <fileType> -->
|
|
||||||
|
|
||||||
<!-- The name that the system displays for the registered file type. Required. -->
|
|
||||||
<!-- <name></name> -->
|
|
||||||
|
|
||||||
<!-- The extension to register. Required. -->
|
|
||||||
<!-- <extension></extension> -->
|
|
||||||
|
|
||||||
<!-- The description of the file type. Optional. -->
|
|
||||||
<!-- <description></description> -->
|
|
||||||
|
|
||||||
<!-- The MIME content type. -->
|
|
||||||
<!-- <contentType></contentType> -->
|
|
||||||
|
|
||||||
<!-- The icon to display for the file type. Optional. -->
|
|
||||||
<!-- <icon>
|
|
||||||
<image16x16></image16x16>
|
|
||||||
<image32x32></image32x32>
|
|
||||||
<image48x48></image48x48>
|
|
||||||
<image128x128></image128x128>
|
|
||||||
</icon> -->
|
|
||||||
|
|
||||||
<!-- </fileType> -->
|
|
||||||
<!-- </fileTypes> -->
|
|
||||||
|
|
||||||
</application>
|
|
@ -1,32 +0,0 @@
|
|||||||
# 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/as3
|
|
||||||
|
|
||||||
# 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/as3
|
|
||||||
|
|
||||||
# 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 = ./test/main/as3
|
|
||||||
|
|
||||||
# Home directory for flex sdk 3, change this to build for Mac or PC using # as comment
|
|
||||||
# SDK_HOME = C:/Program Files/Adobe/Flash Builder 4/sdks/3.5.0
|
|
||||||
# SDK_HOME = /Applications/Adobe Flash Builder 4/sdks/3.5.0
|
|
||||||
# SDK_HOME = /usr/local/flex_sdk_4.1.0/
|
|
||||||
# FLEX_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
|
|
||||||
|
|
@ -1,182 +0,0 @@
|
|||||||
<!-- Flex Library Project ASDocs -->
|
|
||||||
|
|
||||||
<project name="AS3SDKCompile" default="compile" basedir=".">
|
|
||||||
|
|
||||||
<!-- import our build properties file -->
|
|
||||||
<property file="./build.properties"/>
|
|
||||||
<property environment="env"/>
|
|
||||||
<property name="FLEX_HOME" value="${FLEX4_SDK_HOME}"/>
|
|
||||||
<property name="FLEX4_HOME" value="${FLEX4_SDK_HOME}"/>
|
|
||||||
|
|
||||||
<!--<property name="flexunit.swc" value="../lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc" />
|
|
||||||
<property name="flexunit-uilistener.swc" value="../lib/ext/flexunit-uilistener-4.1.0_RC2-28-flex_3.5.0.12683.swc" />
|
|
||||||
<property name="flexunit-cilistener.swc" value="../lib/ext/flexunit-cilistener-4.1.0_RC2-28-flex_3.5.0.12683.swc" />-->
|
|
||||||
|
|
||||||
<!-- Flex Ant Tasks used to perform compc and mxml compiling more info at http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks -->
|
|
||||||
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar"/>
|
|
||||||
|
|
||||||
<target name="setup" description="perform an setup operations"/>
|
|
||||||
|
|
||||||
<!-- Execute the ASDoc Compile wich runs 3 seperate tasks in a series -->
|
|
||||||
<target name="compile" description="series of tasks to create docs and swc">
|
|
||||||
|
|
||||||
<!--<antcall target="cleanDir" description="clean the docs directory"/>-->
|
|
||||||
|
|
||||||
<!--<antcall target="asDocs" description="full build of asdocs"/>-->
|
|
||||||
|
|
||||||
<antcall target="buildSWC" description="build the SWC file"/>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="deploy" description="perform an deployment operations"/>
|
|
||||||
|
|
||||||
<target name="install" description="perform an installation operations"/>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
DELETE the existing output folder and files and then re-generate the output folder
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<target name="clean" description="DELETE the existing output folder and files and then re-generate the output folder">
|
|
||||||
|
|
||||||
<delete dir="${basedir}/${docsoutputfolder}" failonerror="true" includeemptydirs="true"/>
|
|
||||||
<delete file="${basedir}/${liboutputfolder}/${liboutputfile}"/>
|
|
||||||
<delete dir="${basedir}/dist" failonerror="true" includeemptydirs="true"/>
|
|
||||||
|
|
||||||
<mkdir dir="${basedir}/${docsoutputfolder}"/>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
Run the ASDoc executable and generate the ASDocs to the new output folder
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<target name="docs" description="Run the ASDoc executable and generate the ASDocs to the new output folder">
|
|
||||||
|
|
||||||
<exec executable="${env.SDK_HOME}/bin/asdoc" failonerror="true">
|
|
||||||
|
|
||||||
<arg line="-doc-sources ${sourcepath}"/>
|
|
||||||
<arg line="-source-path ${sourcepath}"/>
|
|
||||||
<arg line="-footer 'Copyright Wordnik'"/>
|
|
||||||
<arg line="-package com.wordnik.swagger.api 'Contains the apis which are used by clients to make calls to the services deployed'"/>
|
|
||||||
<arg line="-package com.wordnik.swagger.model 'Contains common classes which encapsulate data elements required'"/>
|
|
||||||
<arg line="-package com.wordnik.swagger.common 'Contains classes which are used by the api classes to invoke the deployed api like SwaggerApi - a base class, ApiUserCredentials, etc.''"/>
|
|
||||||
<arg line="-package com.wordnik.swagger.event 'Results of calls made to Wordnik are returned via dispatched events. This package contains such event classes. Right now thats just ApiClientEvent and Response.'"/>
|
|
||||||
<arg line="-package com.wordnik.swagger.exception 'Contains classes that encapsulate the errors generated'"/>
|
|
||||||
|
|
||||||
<arg value="-window-title"/>
|
|
||||||
<arg value="${title}"/>
|
|
||||||
|
|
||||||
<arg value="-main-title"/>
|
|
||||||
<arg value="${title}"/>
|
|
||||||
|
|
||||||
<arg value="-output"/>
|
|
||||||
<arg value="${basedir}/${docsoutputfolder}"/>
|
|
||||||
|
|
||||||
<arg value="-external-library-path"/>
|
|
||||||
<arg value="${basedir}/${libpath}"/>
|
|
||||||
|
|
||||||
</exec>
|
|
||||||
|
|
||||||
<echo>docs created</echo>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
Compile the SWC file library including lib folder and the path to our classes, we use compc for library,
|
|
||||||
check the docs for Flex Ant Tasks, http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks.
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<target name="buildSWC" description="Compile the SWC file for the Librayr Project">
|
|
||||||
|
|
||||||
<compc output="${basedir}/${liboutputfolder}/${liboutputfile}">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Include the path to any external SWC files used in the sdk, you may have to place name of SWC (ASAXB-0.1.1.swc) at end of path.
|
|
||||||
So file path would be file="${basedir}/${libpath}/ASAXB-0.1.1.swc"
|
|
||||||
-->
|
|
||||||
<include-libraries file="${basedir}/${libpath}/" />
|
|
||||||
|
|
||||||
<source-path path-element="${sourcepath}" />
|
|
||||||
|
|
||||||
<keep-as3-metadata name="XmlRootNode"/>
|
|
||||||
<keep-as3-metadata name="XmlElement"/>
|
|
||||||
<keep-as3-metadata name="XmlElements"/>
|
|
||||||
|
|
||||||
<!-- include our Class packages into the build (com folder) -->
|
|
||||||
<include-sources dir="${sourcepath}" includes="*" />
|
|
||||||
|
|
||||||
</compc>
|
|
||||||
|
|
||||||
<echo>SWC created</echo>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="dist" depends="clean, buildSWC, docs">
|
|
||||||
<mkdir dir="${basedir}/dist/lib"/>
|
|
||||||
<mkdir dir="${basedir}/dist/docs"/>
|
|
||||||
<mkdir dir="${basedir}/dist/sample"/>
|
|
||||||
|
|
||||||
<copy file="${basedir}/${liboutputfolder}/${liboutputfile}" todir="${basedir}/dist/lib/">
|
|
||||||
</copy>
|
|
||||||
<copy todir="${basedir}/dist/docs/">
|
|
||||||
<fileset dir="${basedir}/asdoc"/>
|
|
||||||
</copy>
|
|
||||||
|
|
||||||
|
|
||||||
<zip destfile="sample-as3-sdk.zip" basedir="${basedir}/dist" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- Compiles and creates a test app that can be run using the adl - AIR Debug Launcher from command line
|
|
||||||
Note: For the output file to be executed an xml file is needed which points to this output swf - this is not
|
|
||||||
generated here
|
|
||||||
-->
|
|
||||||
<target name="compile-test" depends="buildSWC">
|
|
||||||
<property name="FLEX_HOME" value="${FLEX4_SDK_HOME}"/>
|
|
||||||
<mxmlc
|
|
||||||
static-rsls="false"
|
|
||||||
fork="true"
|
|
||||||
maxmemory="512m"
|
|
||||||
file="${testsourcepath}/AirExecutorApp.mxml"
|
|
||||||
output="${basedir}/${liboutputfolder}/AirExecutorApp.swf"
|
|
||||||
warnings="false"
|
|
||||||
configname="air"
|
|
||||||
locale="en_US">
|
|
||||||
<load-config filename="${FLEX4_HOME}/frameworks/air-config.xml"/>
|
|
||||||
<source-path path-element="${FLEX_HOME}/frameworks"/>
|
|
||||||
|
|
||||||
<compiler.debug>true</compiler.debug>
|
|
||||||
|
|
||||||
|
|
||||||
<source-path path-element="${testsourcepath}" />
|
|
||||||
<!--<source-path path-element="${APP_ROOT}/locale/{locale}" />-->
|
|
||||||
|
|
||||||
<library-path dir="${FLEX_HOME}/frameworks/libs" append="true">
|
|
||||||
<include name="*.swc" />
|
|
||||||
</library-path>
|
|
||||||
<library-path dir="${FLEX_HOME}/frameworks/libs/air" append="true">
|
|
||||||
<include name="*.swc" />
|
|
||||||
</library-path>
|
|
||||||
<library-path dir="${FLEX_HOME}/frameworks/locale" append="true">
|
|
||||||
<include name="{locale}" />
|
|
||||||
</library-path>
|
|
||||||
<library-path dir="${basedir}/${libpath}" append="true">
|
|
||||||
<include name="*.swc" />
|
|
||||||
</library-path>
|
|
||||||
<library-path dir="${basedir}/${liboutputfolder}" append="true">
|
|
||||||
<include name="*.swc" />
|
|
||||||
</library-path>
|
|
||||||
<library-path dir="${basedir}/${libpath}/ext" append="true">
|
|
||||||
<include name="*.swc" />
|
|
||||||
</library-path>
|
|
||||||
|
|
||||||
<verbose-stacktraces>true</verbose-stacktraces>
|
|
||||||
</mxmlc>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
</project>
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,241 +0,0 @@
|
|||||||
package com.wordnik.swagger.common
|
|
||||||
{
|
|
||||||
import asaxb.xml.bind.ASAXBContext;
|
|
||||||
import asaxb.xml.bind.Unmarshaller;
|
|
||||||
|
|
||||||
import com.wordnik.swagger.event.ApiClientEvent;
|
|
||||||
import com.wordnik.swagger.event.Response;
|
|
||||||
import com.wordnik.swagger.common.ApiUserCredentials;
|
|
||||||
import com.wordnik.swagger.model.LibraryReferences;
|
|
||||||
|
|
||||||
import flash.events.EventDispatcher;
|
|
||||||
import flash.utils.Dictionary;
|
|
||||||
import flash.utils.describeType;
|
|
||||||
import flash.xml.XMLDocument;
|
|
||||||
import flash.xml.XMLNode;
|
|
||||||
|
|
||||||
import mx.messaging.ChannelSet;
|
|
||||||
import mx.messaging.channels.HTTPChannel;
|
|
||||||
import mx.messaging.messages.HTTPRequestMessage;
|
|
||||||
import mx.rpc.AsyncToken;
|
|
||||||
import mx.rpc.events.FaultEvent;
|
|
||||||
import mx.rpc.events.ResultEvent;
|
|
||||||
import mx.rpc.http.HTTPService;
|
|
||||||
import mx.rpc.xml.SimpleXMLEncoder;
|
|
||||||
import mx.utils.ObjectUtil;
|
|
||||||
|
|
||||||
|
|
||||||
public class ApiInvoker extends EventDispatcher
|
|
||||||
{
|
|
||||||
|
|
||||||
private var _apiUsageCredentials:ApiUserCredentials;
|
|
||||||
internal var _apiProxyServerUrl:String = "";
|
|
||||||
private var _baseUrl: String = "";
|
|
||||||
internal var _useProxyServer: Boolean = true;
|
|
||||||
private var _proxyHostName:String = "";
|
|
||||||
private var _apiPath: String = "";
|
|
||||||
|
|
||||||
public var _apiEventNotifier:EventDispatcher;
|
|
||||||
public var _apiLibraryReferences:LibraryReferences;
|
|
||||||
|
|
||||||
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;
|
|
||||||
_apiProxyServerUrl = _apiUsageCredentials.apiProxyServerUrl;
|
|
||||||
_apiEventNotifier = eventNotifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function invokeAPI(resourceURL: String, method: String, queryParams: Dictionary, postObject: Object, headerParams: Dictionary): AsyncToken {
|
|
||||||
//make the communication
|
|
||||||
if(_useProxyServer) {
|
|
||||||
resourceURL = resourceURL = _apiProxyServerUrl + resourceURL;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
resourceURL = 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++;
|
|
||||||
|
|
||||||
}
|
|
||||||
//create a httpservice and invoke the rest url waiting for response
|
|
||||||
var requestHeader:Object = new Object();
|
|
||||||
resourceURL = ApiUrlHelper.appendTokenInfo(resourceURL, requestHeader, _apiUsageCredentials);
|
|
||||||
var bodyData:String = marshal( postObject);//restRequest.postData;
|
|
||||||
|
|
||||||
return doRestCall(resourceURL, onApiRequestResult, onApiRequestFault, method, bodyData, requestHeader, "application/xml");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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{
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function marshal(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.charAt().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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package com.wordnik.swagger.common {
|
|
||||||
import com.wordnik.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 HOST_PROXY_PATH:String = "/v4/messagebroker/restproxy";
|
|
||||||
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): String{
|
|
||||||
if (hostName.charAt(hostName.length - 1) == "/") //remove trailing slash
|
|
||||||
{
|
|
||||||
hostName = hostName.substring(0, hostName.length - 1);
|
|
||||||
}
|
|
||||||
return HTTP_URL_PREFIX + hostName + HOST_PROXY_PATH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package com.wordnik.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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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(apiToken: String, authToken: String = null, hostName: String = null, userId: Number = -1,
|
|
||||||
apiPath: String = "", apiProxyServerUrl: String="") {
|
|
||||||
this.hostName = hostName;
|
|
||||||
this.apiToken = apiToken;
|
|
||||||
this.authToken = authToken;
|
|
||||||
this.userId = userId;
|
|
||||||
this.apiPath = apiPath;
|
|
||||||
this.apiProxyServerUrl = apiProxyServerUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.wordnik.swagger.common
|
|
||||||
{
|
|
||||||
public interface ListWrapper
|
|
||||||
{
|
|
||||||
|
|
||||||
function getList(): Array;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
package com.wordnik.swagger.common
|
|
||||||
{
|
|
||||||
import com.wordnik.swagger.common.ApiUserCredentials;
|
|
||||||
|
|
||||||
import flash.events.EventDispatcher;
|
|
||||||
import flash.events.IEventDispatcher;
|
|
||||||
|
|
||||||
import mx.utils.UIDUtil;
|
|
||||||
|
|
||||||
public class SwaggerApi extends EventDispatcher
|
|
||||||
{
|
|
||||||
|
|
||||||
protected var _apiUsageCredentials:ApiUserCredentials;
|
|
||||||
protected var _apiEventNotifier:EventDispatcher;
|
|
||||||
protected var _apiInvoker: ApiInvoker;
|
|
||||||
|
|
||||||
protected var _useProxyServer: Boolean = true;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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(",");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package com.wordnik.swagger.common
|
|
||||||
{
|
|
||||||
public class XMLWriter
|
|
||||||
{
|
|
||||||
public var xml:XML;
|
|
||||||
|
|
||||||
public function XMLWriter()
|
|
||||||
{
|
|
||||||
xml=<obj/>;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function reset():void {
|
|
||||||
xml=new XML();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addProperty(propertyName:String, propertyValue:String):XML {
|
|
||||||
var xmlProperty:XML=<new/>
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package com.wordnik.swagger.event {
|
|
||||||
import com.wordnik.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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package com.wordnik.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package com.wordnik.swagger.exception
|
|
||||||
{
|
|
||||||
public class ApiError extends Error
|
|
||||||
{
|
|
||||||
public function ApiError(id:*=0, message:*="")
|
|
||||||
{
|
|
||||||
super(message,id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package com.wordnik.swagger.exception
|
|
||||||
{
|
|
||||||
public class ApiErrorCodes
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* System exception.
|
|
||||||
*/
|
|
||||||
public static const SYSTEM_EXCEPTION: Number = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* With Arguments as current key.
|
|
||||||
*/
|
|
||||||
public static const API_KEY_NOT_VALID: Number = 1000;
|
|
||||||
/**
|
|
||||||
* With arguments as current token value
|
|
||||||
*/
|
|
||||||
public static const AUTH_TOKEN_NOT_VALID: Number = 1001;
|
|
||||||
/**
|
|
||||||
* With arguments as input JSON and output class anme
|
|
||||||
*/
|
|
||||||
public static const ERROR_CONVERTING_JSON_TO_JAVA: Number = 1002;
|
|
||||||
/**
|
|
||||||
* With arguments as JAVA class name
|
|
||||||
*/
|
|
||||||
public static const ERROR_CONVERTING_JAVA_TO_JSON: Number = 1003;
|
|
||||||
|
|
||||||
public static const ERROR_FROM_WEBSERVICE_CALL: Number = 1004;
|
|
||||||
/**
|
|
||||||
* With arguments as current API server name
|
|
||||||
*/
|
|
||||||
public static const API_SERVER_NOT_VALID: Number = 1005;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
|
|
||||||
xmlns:s="library://ns.adobe.com/flex/spark"
|
|
||||||
xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="runMe()" invoke="onInvoke(event)">
|
|
||||||
<fx:Declarations>
|
|
||||||
<!-- Place non-visual elements (e.g., services, value objects) here -->
|
|
||||||
</fx:Declarations>
|
|
||||||
<fx:Script>
|
|
||||||
<![CDATA[
|
|
||||||
import org.flexunit.listeners.AirCIListener;
|
|
||||||
import org.flexunit.runner.FlexUnitCore;
|
|
||||||
|
|
||||||
import test.TestExecutor;
|
|
||||||
|
|
||||||
private var core: FlexUnitCore;
|
|
||||||
|
|
||||||
public function runMe(): void{
|
|
||||||
core = new FlexUnitCore();
|
|
||||||
core.addListener(new AirCIListener());
|
|
||||||
core.run(test.TestExecutor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onInvoke(event: InvokeEvent): void{
|
|
||||||
var arguments: Array = event.arguments;
|
|
||||||
trace(arguments.toString());
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</fx:Script>
|
|
||||||
</s:WindowedApplication>
|
|
@ -1,432 +0,0 @@
|
|||||||
package test
|
|
||||||
{
|
|
||||||
import com.adobe.serialization.json.JSON;
|
|
||||||
import com.adobe.utils.DateUtil;
|
|
||||||
import com.wordnik.swagger.common.ApiInvoker;
|
|
||||||
import com.wordnik.swagger.common.ApiUserCredentials;
|
|
||||||
import com.wordnik.swagger.common.SwaggerApi;
|
|
||||||
import com.wordnik.swagger.event.ApiClientEvent;
|
|
||||||
import com.wordnik.swagger.event.Response;
|
|
||||||
|
|
||||||
import flash.desktop.NativeApplication;
|
|
||||||
import flash.events.Event;
|
|
||||||
import flash.events.EventDispatcher;
|
|
||||||
import flash.events.IEventDispatcher;
|
|
||||||
import flash.events.IOErrorEvent;
|
|
||||||
import flash.filesystem.File;
|
|
||||||
import flash.filesystem.FileMode;
|
|
||||||
import flash.filesystem.FileStream;
|
|
||||||
import flash.net.URLLoader;
|
|
||||||
import flash.net.URLRequest;
|
|
||||||
import flash.system.System;
|
|
||||||
import flash.utils.describeType;
|
|
||||||
import flash.utils.getDefinitionByName;
|
|
||||||
|
|
||||||
import flexunit.framework.TestCase;
|
|
||||||
|
|
||||||
import mx.core.ClassFactory;
|
|
||||||
import mx.rpc.events.FaultEvent;
|
|
||||||
import mx.utils.StringUtil;
|
|
||||||
|
|
||||||
public class TestExecutor extends TestCase
|
|
||||||
{
|
|
||||||
private var urlReq:URLRequest;
|
|
||||||
private var urlLdr:URLLoader;
|
|
||||||
|
|
||||||
private var apiInvoker: ApiInvoker;
|
|
||||||
|
|
||||||
private const MODEL_INFO_URL:String ="testData.json";
|
|
||||||
private const TIME_OUT:int = 5000;
|
|
||||||
|
|
||||||
private var testData: Object;
|
|
||||||
|
|
||||||
|
|
||||||
public function testApiMethod():void{
|
|
||||||
initializeRequest();
|
|
||||||
urlLdr.addEventListener(Event.COMPLETE, addAsync(executeTest, TIME_OUT));
|
|
||||||
urlLdr.addEventListener(IOErrorEvent.IO_ERROR, executeTest);
|
|
||||||
urlLdr.load(urlReq);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function initializeRequest():void {
|
|
||||||
/* Initialize the URLRequest object with the URL to the file of name/value pairs. */
|
|
||||||
urlReq = new URLRequest(MODEL_INFO_URL);
|
|
||||||
/* Initialize the URLLoader object, assign the various event listeners, and load the specified URLRequest object. */
|
|
||||||
urlLdr = new URLLoader();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function checkAndLoadModelXml(event:Event):Object {
|
|
||||||
var ldr:URLLoader = urlLdr;//event.currentTarget as URLLoader;
|
|
||||||
assertTrue("Test data info not found ", ldr.data != null);
|
|
||||||
|
|
||||||
var testData:Object = JSON.decode(ldr.data);
|
|
||||||
//var classList:XML = new XML(ldr.data);
|
|
||||||
assertTrue("Test data could not be loaded as xml ", testData != null);
|
|
||||||
return testData;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function executeTest(event:Event):void {
|
|
||||||
testData = checkAndLoadModelXml(event);
|
|
||||||
//figure out class and method to execute
|
|
||||||
var className: String = getServiceName(testData.resource);
|
|
||||||
var methodName: String = testData.methodName;
|
|
||||||
var servicePackageName: String = testData.apiPackageName;
|
|
||||||
var fullClassName: String = servicePackageName + "." + className;
|
|
||||||
|
|
||||||
var apiUrl: String = testData.apiUrl;
|
|
||||||
var apiHostName : String = apiUrl.substring(apiUrl.indexOf("//")+2,
|
|
||||||
apiUrl.indexOf("/",apiUrl.indexOf("//")+2) );
|
|
||||||
var apiPath: String = apiUrl.substring(apiUrl.indexOf(apiHostName)+ apiHostName.length,
|
|
||||||
apiUrl.indexOf("/", apiUrl.indexOf(apiHostName)+ apiHostName.length + 1));
|
|
||||||
var useProxyServer: Boolean = false;
|
|
||||||
if(testData.useProxyServer != null){
|
|
||||||
useProxyServer = testData.useProxyServer == "true" ? true : false;
|
|
||||||
}
|
|
||||||
var params: Array;
|
|
||||||
//execute the test
|
|
||||||
|
|
||||||
var classRef:Class;
|
|
||||||
try{
|
|
||||||
classRef = getDefinitionByName(fullClassName) as Class;
|
|
||||||
}
|
|
||||||
catch(error: ReferenceError){
|
|
||||||
var classFailure: Response = new Response(false, null, "Api Class not found");
|
|
||||||
writeToFile( JSON.encode(classFailure) );
|
|
||||||
}
|
|
||||||
|
|
||||||
var apiCredentials: ApiUserCredentials = new ApiUserCredentials(testData.apiKey,
|
|
||||||
testData.authToken, apiHostName, -1, apiPath, testData.proxyServerUrl);
|
|
||||||
|
|
||||||
var apiInstance : * = new classRef(apiCredentials);
|
|
||||||
apiInstance.useProxyServer(useProxyServer);
|
|
||||||
apiInstance.addEventListener(methodName, addAsync(onApiCallResponse, TIME_OUT, {} , apiTimeOutHandler) );
|
|
||||||
apiInstance.addEventListener(ApiClientEvent.FAILURE_EVENT, onApiCallFault );
|
|
||||||
|
|
||||||
var queryAndPathParams: Object = new Object();
|
|
||||||
|
|
||||||
queryAndPathParams = testData.queryAndPathParams;
|
|
||||||
|
|
||||||
params = getArgumentsForTestCaseExecution(methodName, apiInstance,
|
|
||||||
queryAndPathParams, testData.postData, className, testData.resource);
|
|
||||||
if(apiInstance.hasOwnProperty(methodName)){
|
|
||||||
var method:Function = apiInstance[methodName];
|
|
||||||
var returnValue:* = method.apply(apiInstance, params);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
//write out error
|
|
||||||
var failureResponse: Response = new Response(false, null, "Method not found");
|
|
||||||
writeToFile( JSON.encode(failureResponse) );
|
|
||||||
}
|
|
||||||
|
|
||||||
//write out test data result to json file
|
|
||||||
}
|
|
||||||
|
|
||||||
private function onApiCallResponse(event: ApiClientEvent, tokenObject: Object = null): void{
|
|
||||||
var result: Response = event.response;
|
|
||||||
trace("writing to file");
|
|
||||||
|
|
||||||
writeToFile( JSON.encode(result) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private function onApiCallFault(event:FaultEvent):void {
|
|
||||||
var failureResponse: Response = new Response(false, null, "Method invocation failure");
|
|
||||||
writeToFile( JSON.encode(failureResponse) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private function writeToFile(data: String) : void {
|
|
||||||
var localFile: File = File.documentsDirectory.resolvePath("testOutput.json");
|
|
||||||
var localFileStream:FileStream = new FileStream();
|
|
||||||
|
|
||||||
localFileStream.open(localFile, FileMode.WRITE);
|
|
||||||
|
|
||||||
localFileStream.writeMultiByte( data, "utf-8");
|
|
||||||
localFileStream.close();
|
|
||||||
trace(data);
|
|
||||||
applicationExit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function apiTimeOutHandler(o: Object):void {
|
|
||||||
//fail("test timed out");
|
|
||||||
trace("Execution timed out");
|
|
||||||
var failureResponse: Response = new Response(false, null, "Method Execution timed out");
|
|
||||||
writeToFile( JSON.encode(failureResponse) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate name of the service from resource path.
|
|
||||||
*
|
|
||||||
* Example: if input is /user.json the generated name for this path will be UserAPI
|
|
||||||
* If the input is /user.json/{userId}, the service name will still be generated as UserAPI
|
|
||||||
*
|
|
||||||
* @param resourcePath
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private function getServiceName(resourcePath: String): String {
|
|
||||||
var className:String = null;
|
|
||||||
var index: int = resourcePath.indexOf(".");
|
|
||||||
if(index >= 0) {
|
|
||||||
var resourceName: String = resourcePath.substring(1,index);
|
|
||||||
className = applyClassNamingPolicy(resourceName);
|
|
||||||
}else{
|
|
||||||
var paths: Array = resourcePath.split("/");
|
|
||||||
for each(var path: String in paths) {
|
|
||||||
if(path != null && path.length > 0) {
|
|
||||||
className = applyClassNamingPolicy(path);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return className+ "API";
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getArgumentsForTestCaseExecution(methodName: String, apiObject: Object, queryAndPathParameters: Object,
|
|
||||||
postData: String, className: String, resourcePath: String): Array{
|
|
||||||
|
|
||||||
var result: Array;
|
|
||||||
//get the xml data for the type
|
|
||||||
var classAsXML: XML = describeType(apiObject);
|
|
||||||
//get the parameters for the method
|
|
||||||
|
|
||||||
var argNamesArray: Array = [];
|
|
||||||
var argTypesArray: Array = [];
|
|
||||||
|
|
||||||
var list: XMLList = classAsXML.method;
|
|
||||||
var methodXml: XML;
|
|
||||||
var paramDefn: XML
|
|
||||||
var currentMethodName: String;
|
|
||||||
var methodParams: XMLList;
|
|
||||||
var methodArgumentNames: XMLList;
|
|
||||||
var argumentNames: String;
|
|
||||||
|
|
||||||
for each (methodXml in list) {
|
|
||||||
//get the names and types for the parameters
|
|
||||||
currentMethodName = methodXml.@name.toString();
|
|
||||||
if(methodName == currentMethodName){
|
|
||||||
methodParams = methodXml.parameter;
|
|
||||||
for each(paramDefn in methodParams){
|
|
||||||
argTypesArray.push(paramDefn.@type.toString());
|
|
||||||
}
|
|
||||||
methodArgumentNames = methodXml.metadata.(@name == "MethodArgumentNames");
|
|
||||||
if(methodArgumentNames.length() > 0){
|
|
||||||
argumentNames = methodArgumentNames.arg[0].@value.toString();
|
|
||||||
argNamesArray = argNamesArray.concat(argumentNames.split(","));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(argNamesArray != null && argNamesArray.length > 0){
|
|
||||||
result = [];
|
|
||||||
//get the value of the input type parameter
|
|
||||||
var inputClassName: String = getInputObjectName(className, resourcePath);
|
|
||||||
var argName: String;
|
|
||||||
var argType: String;
|
|
||||||
var argumentValue: Object;
|
|
||||||
for (var i: Number=0 ; i< argNamesArray.length ; i++){
|
|
||||||
argName = StringUtil.trim( argNamesArray[i].toString() );
|
|
||||||
argType = argTypesArray[i].toString();
|
|
||||||
//if the parameter type is of collated input type
|
|
||||||
if(argType == inputClassName){
|
|
||||||
//create an object of type input model and populate it
|
|
||||||
argumentValue = populateInputModelObject(argTypesArray[i], queryAndPathParameters);
|
|
||||||
}
|
|
||||||
//if it is a primitive type then
|
|
||||||
else if( isPrimitiveType(argType) ){
|
|
||||||
//get the value from the queryAndPathParameters
|
|
||||||
argumentValue = queryAndPathParameters[argName] ;
|
|
||||||
}
|
|
||||||
//if it is a POST param
|
|
||||||
else if( argName == "postData"){
|
|
||||||
//convert from JSON to object ? of type ?
|
|
||||||
if(postData.charAt(0) == "\"" && postData.charAt(postData.length - 1) == "\""){
|
|
||||||
postData = postData.slice(1, postData.length);
|
|
||||||
}
|
|
||||||
argumentValue = JSON.decode( postData.toString() );
|
|
||||||
argumentValue = mapToFlexObjects(argumentValue, argType);
|
|
||||||
}
|
|
||||||
else if(true){
|
|
||||||
//???some times input can be list of primitives for supporting multivalued values. however test case sends the input as comma separated values
|
|
||||||
//???so we need to convert comma separated string into JSON list format
|
|
||||||
argumentValue = queryAndPathParameters[argName].toString().split(",");
|
|
||||||
}
|
|
||||||
result.push(argumentValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an instance of type 'Object' to a type of 'argType'
|
|
||||||
*/
|
|
||||||
private function mapToFlexObjects(obj:Object, argType: String):Object {
|
|
||||||
var fullClassName: String = argType.replace("::",".");
|
|
||||||
var classRef:Class;
|
|
||||||
try{
|
|
||||||
classRef = getDefinitionByName(fullClassName) as Class;
|
|
||||||
}
|
|
||||||
catch(error: ReferenceError){
|
|
||||||
var classFailure: Response = new Response(false, null, "Api Class not found");
|
|
||||||
writeToFile( JSON.encode(classFailure) );
|
|
||||||
}
|
|
||||||
var returnObject : * = new classRef();
|
|
||||||
|
|
||||||
var propertyMap:XML = describeType(returnObject);
|
|
||||||
var propertyTypeClass:Class;
|
|
||||||
|
|
||||||
for each (var property:XML in propertyMap.variable) {
|
|
||||||
if ((obj as Object).hasOwnProperty(property.@name)) {
|
|
||||||
propertyTypeClass = getDefinitionByName(property.@type) as Class;
|
|
||||||
if (obj[property.@name] is (propertyTypeClass)) {
|
|
||||||
returnObject[property.@name] = obj[property.@name];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(property.@type == "Date"){
|
|
||||||
var dateValue:Date = DateUtil.parseW3CDTF( obj[property.@name] );
|
|
||||||
returnObject[property.@name] = dateValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !isPrimitiveType( property.@type )){
|
|
||||||
try{
|
|
||||||
var complexTypeObject: Object = mapToFlexObjects( obj[property.@name], property.@type );
|
|
||||||
returnObject[property.@name] = complexTypeObject;
|
|
||||||
}
|
|
||||||
catch(error: Error){
|
|
||||||
var mapToFlexFailure: Response = new Response(false, null, "Post data object could not be created");
|
|
||||||
writeToFile( JSON.encode(mapToFlexFailure) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function isPrimitiveType(type: String): Boolean {
|
|
||||||
if(type == "String" || type == "int" || type == "integer" || type == "double" ||
|
|
||||||
type == "boolean" || type == "float" || type == "long" || type == "Number" ){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the first character of the input into upper case .
|
|
||||||
* Example: If the input is word, the return value will be Word
|
|
||||||
* @param input
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private function applyClassNamingPolicy(input: String): String {
|
|
||||||
if(input != null && input.length > 0) {
|
|
||||||
return input.substring(0,1).toUpperCase() + input.substring(1);
|
|
||||||
}else{
|
|
||||||
throw new Error("Error converting input to first letter caps becuase of null or empty input");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getInputObjectName(serviceName: String, resourcePath: String): String {
|
|
||||||
//Since service name has API at the end remove that format he name
|
|
||||||
var inputobjectName: String = serviceName.substring(0, serviceName.length - 3);
|
|
||||||
|
|
||||||
var pathElements: Array = resourcePath.split("/");
|
|
||||||
var urlPath: String = "";
|
|
||||||
if(pathElements != null){
|
|
||||||
for each(var pathElement: String in pathElements){
|
|
||||||
if(pathElement != null && pathElement.length > 0) {
|
|
||||||
var position: int = pathElement.indexOf("{");
|
|
||||||
if(position < 0) {
|
|
||||||
inputobjectName = inputobjectName + applyClassNamingPolicy( pathElement ) + "Input";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return inputobjectName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Populates the swagger input model object.
|
|
||||||
*
|
|
||||||
* Input model is created when number of inputs to a method exceed certain limit.
|
|
||||||
* @param inputDefinitions
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private function populateInputModelObject(swaggerInputClassName: String, inputDefinitions: Object): Object {
|
|
||||||
var inputModelObjectClass: Class = getDefinitionByName(swaggerInputClassName) as Class;
|
|
||||||
var inputObject: Object = new inputModelObjectClass();
|
|
||||||
|
|
||||||
for(var attributeName: String in inputDefinitions){
|
|
||||||
if(inputObject.hasOwnProperty(attributeName)){
|
|
||||||
inputObject[attributeName] = inputDefinitions[attributeName];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return inputObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applicationExit():void {
|
|
||||||
var exitingEvent:Event = new Event(Event.EXITING, false, true);
|
|
||||||
NativeApplication.nativeApplication.dispatchEvent(exitingEvent);
|
|
||||||
if (!exitingEvent.isDefaultPrevented()) {
|
|
||||||
NativeApplication.nativeApplication.exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Gets the list of input query and path parameters and post data vlues and covenrt them to arguments that
|
|
||||||
// * can be used for calling the method. This logic will be different in each driver language depends on how method
|
|
||||||
// * input arguments are created.
|
|
||||||
// */
|
|
||||||
// private function populateArgumentsForTestCaseExecution(methodToExecute: Function, queryAndPathParameters: Object,
|
|
||||||
// postData: String, serviceName: String, resourcePath: String): Array {
|
|
||||||
// MethodArgumentNames argNames = methodToExecute.getAnnotation(MethodArgumentNames.class);
|
|
||||||
// String[] argNamesArray = null;
|
|
||||||
// if(argNames != null && argNames.value().length() > 0) {
|
|
||||||
// argNamesArray = argNames.value().split(",");
|
|
||||||
// }
|
|
||||||
// Class[] argTypesArray = methodToExecute.getParameterTypes();
|
|
||||||
// Object output = null;
|
|
||||||
// String inputClassName = namingPolicyProvider.getInputObjectName(serviceName, resourcePath);
|
|
||||||
//
|
|
||||||
// if(argNamesArray != null && argNamesArray.length > 0){
|
|
||||||
// Object[] arguments = new Object[argNamesArray.length];
|
|
||||||
//
|
|
||||||
// for(int i=0; i < argNamesArray.length; i++){
|
|
||||||
// Object argument = null;
|
|
||||||
// //if the method takes input model instead of individual arguments, convert individual arguments into input model object
|
|
||||||
// if(argTypesArray[i].getName().equalsIgnoreCase(inputClassName)){
|
|
||||||
// argument = populateInputModelObject(argTypesArray[i], queryAndPathParameters);
|
|
||||||
// }else if(datatypeMppingProvider.isPrimitiveType(argTypesArray[i].getName())){
|
|
||||||
// argument = queryAndPathParameters.get(argNamesArray[i].trim());
|
|
||||||
// }else if (argNamesArray[i].trim().equals(APITestRunner.POST_PARAM_NAME)){
|
|
||||||
// argument = APITestRunner.convertJSONStringToObject(postData, argTypesArray[i]);
|
|
||||||
// }else{
|
|
||||||
// //some times input can be list of primitives for supporting multivalued values. however test case sends the input as comma separated values
|
|
||||||
// //so we need to convert comma separated string into JSON list format
|
|
||||||
// if(List.class.isAssignableFrom(argTypesArray[i]) && !queryAndPathParameters.get(argNamesArray[i].trim()).startsWith("[")){
|
|
||||||
// String listInput= "[";
|
|
||||||
// int x = 0;
|
|
||||||
// String[] values = queryAndPathParameters.get(argNamesArray[i].trim()).split(",");
|
|
||||||
// for(String value : values){
|
|
||||||
// if(x > 0){listInput = listInput + ",";}
|
|
||||||
// listInput = listInput + "\""+ value + "\"";
|
|
||||||
// x++;
|
|
||||||
// }
|
|
||||||
// listInput = listInput + "]";
|
|
||||||
// argument = APITestRunner.convertJSONStringToObject(listInput, argTypesArray[i]);
|
|
||||||
// }else{
|
|
||||||
// argument = APITestRunner.convertJSONStringToObject(queryAndPathParameters.get(argNamesArray[i].trim()), argTypesArray[i]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// arguments[i] = argument;
|
|
||||||
// }
|
|
||||||
// return arguments;
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package $packageName$;
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $enum.description$
|
|
||||||
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
|
|
||||||
* @author deepak
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public enum $className$ {
|
|
||||||
|
|
||||||
$values: { value | $value.name$($value.value$)};separator=", "$;
|
|
||||||
|
|
||||||
final $enumValueType$ value;
|
|
||||||
|
|
||||||
$className$($enumValueType$ value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public $enumValueType$ getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
return String.valueOf(this.getValue());
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,30 +0,0 @@
|
|||||||
package $packageName$ {
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
|
|
||||||
* @author deepak
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
[XmlRootNode(name="$model.name$")]
|
|
||||||
public class $className$ extends $extends$ {
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $field.description$
|
|
||||||
* $if(field.required)$@Required$endif$
|
|
||||||
* $if(field.allowableValues)$[AllowableValues(value="$field.allowedValuesString$"]$endif$
|
|
||||||
*/
|
|
||||||
$if(!field.fieldDefinition.collectionItemType)$
|
|
||||||
[XmlElement(name="$field.fieldDefinition.name$")]$endif$
|
|
||||||
$if(field.fieldDefinition.collectionItemType)$
|
|
||||||
[XmlElements(name="$field.fieldDefinition.name$", type="$field.fieldDefinition.collectionItemType$")]$endif$
|
|
||||||
public var $field.fieldDefinition.name$: $field.fieldDefinition.returnType$ $field.fieldDefinition.initialization$;$\r$}$
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package $packageName$ {
|
|
||||||
|
|
||||||
import com.wordnik.swagger.api.*;
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class contains references for any classes that might not be directly referenced by the Api classes.
|
|
||||||
* The AS3 compiler will exclude any class that is not referenced directly somewhere in your code.
|
|
||||||
* This is an optimization that the compiler applies by design.
|
|
||||||
* This convenience class prevents the user from having to iclude an import and variable declaration for such classes.
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
|
|
||||||
* @author deepak
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class LibraryReferences {
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
private var $field.name$: $field.paramType$;$\r$}$
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,132 +0,0 @@
|
|||||||
package $packageName$ {
|
|
||||||
|
|
||||||
|
|
||||||
import $exceptionPackageName$.ApiErrorCodes;
|
|
||||||
import $exceptionPackageName$.ApiError;
|
|
||||||
import $modelPackageName$.*;
|
|
||||||
import com.wordnik.swagger.common.ApiUserCredentials;
|
|
||||||
import com.wordnik.swagger.event.Response;
|
|
||||||
import com.wordnik.swagger.common.SwaggerApi;
|
|
||||||
|
|
||||||
import mx.rpc.AsyncToken;
|
|
||||||
import mx.utils.UIDUtil;
|
|
||||||
import flash.utils.Dictionary;
|
|
||||||
import flash.events.EventDispatcher;
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
|
|
||||||
* @author deepak
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class $resource$ extends $extends$ {
|
|
||||||
|
|
||||||
$methods:{ method |
|
|
||||||
public var event_$method.name$: String = "$method.name$";$\r$}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for the $resource$ 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 $resource$(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) {
|
|
||||||
super(apiCredentials, eventDispatcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$methods:{ method |
|
|
||||||
/**
|
|
||||||
* $method.description$
|
|
||||||
$method.arguments:{ argument |
|
|
||||||
* @param $argument.name$ $argument.description$
|
|
||||||
$if(argument.allowedValues)$
|
|
||||||
* Allowed values are - $argument.allowedValues$
|
|
||||||
$endif$}$
|
|
||||||
*
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
|
|
||||||
*/
|
|
||||||
$if(method.hasArguments)$
|
|
||||||
[MethodArgumentNames(value="$method.argumentNames; separator=", "$")]$endif$
|
|
||||||
public function $method.name$($method.argumentDefinitions; separator=", "$): String {
|
|
||||||
|
|
||||||
$if(method.authToken)$
|
|
||||||
if(_apiUsageCredentials == null || _apiUsageCredentials.authToken == null || _apiUsageCredentials.authToken.length == 0) {
|
|
||||||
throw new ApiError(ApiErrorCodes.AUTH_TOKEN_NOT_VALID);
|
|
||||||
}$endif$
|
|
||||||
var requestId: String = getUniqueId();
|
|
||||||
//parse inputs
|
|
||||||
var resourcePath: String = "$method.resourcePath$";
|
|
||||||
resourcePath = resourcePath.replace("{format}","xml");
|
|
||||||
var method: String = "$method.methodType$";
|
|
||||||
var queryParams:Dictionary = new Dictionary();
|
|
||||||
var headerParams:Dictionary = new Dictionary();
|
|
||||||
$if(!method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if( $argument.name$ != null) {
|
|
||||||
queryParams["$argument.name$"] = toPathValue($argument.name$);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if( $argument.name$ != null) {
|
|
||||||
resourcePath = resourcePath.replace("{$argument.name$}", $argument.name$);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if( $argument.name$ != null) {
|
|
||||||
headerParams["$argument.name$"] = toPathValue($argument.name$);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
$if(method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
|
|
||||||
queryParams["$argument.name$"] = $argument.methodNameFromModelClass$;
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
|
|
||||||
resourcePath = resourcePath.replace("{$argument.name$}", $argument.methodNameFromModelClass$);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
|
|
||||||
headerParams["$argument.name$"] = $argument.methodNameFromModelClass$;
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
//make the API Call
|
|
||||||
$if(method.postObject)$
|
|
||||||
$if(method.authToken)$
|
|
||||||
var token:AsyncToken = getApiInvoker().invokeAPI(resourcePath, method, queryParams, postData, headerParams);
|
|
||||||
$endif$
|
|
||||||
$if(!method.authToken)$
|
|
||||||
var token:AsyncToken = getApiInvoker().invokeAPI(resourcePath, method, queryParams, postData, headerParams);
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
$if(!method.postObject)$
|
|
||||||
$if(method.authToken)$
|
|
||||||
var token:AsyncToken = getApiInvoker().invokeAPI(resourcePath, method, queryParams, null, headerParams);
|
|
||||||
$endif$
|
|
||||||
$if(!method.authToken)$
|
|
||||||
var token:AsyncToken = getApiInvoker().invokeAPI(resourcePath, method, queryParams, null, headerParams);
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
token.requestId = requestId;
|
|
||||||
token.completionEventType = "$method.name$";
|
|
||||||
|
|
||||||
//create output objects if the response has more than one object
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
token.returnType = $method.returnClassName$;
|
|
||||||
|
|
||||||
$endif$
|
|
||||||
return requestId;
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
package $packageName$ {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Maintains the compatible server version against which the drive is written
|
|
||||||
* @author deepak
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class VersionChecker {
|
|
||||||
|
|
||||||
private var compatibleVersion: String = "$apiVersion$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the version against which the driver code was written
|
|
||||||
*/
|
|
||||||
public function getCompatibleVersion(): String {
|
|
||||||
return compatibleVersion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package $packageName$ {
|
|
||||||
|
|
||||||
import com.wordnik.swagger.common.ListWrapper;
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
|
|
||||||
* @author deepak
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class $className$ extends $extends$ implements ListWrapper{
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
/**
|
|
||||||
* $field.description$
|
|
||||||
* $if(field.required)$@Required$endif$
|
|
||||||
* $if(field.allowableValues)$[AllowableValues(value="$field.allowedValuesString$"]$endif$
|
|
||||||
*/
|
|
||||||
$if(!field.fieldDefinition.collectionItemType)$
|
|
||||||
[XmlElement(name="$field.fieldDefinition.name$")]$endif$
|
|
||||||
$if(field.fieldDefinition.collectionItemType)$
|
|
||||||
[XmlElements(name="$field.fieldDefinition.collectionItemName$", type="$field.fieldDefinition.collectionItemType$")]$endif$
|
|
||||||
public var $field.fieldDefinition.name$: $field.fieldDefinition.returnType$ $field.fieldDefinition.initialization$;}$
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
/**
|
|
||||||
* Returns the list being wrapped by this wrapper class. There will be a single list item attribute in this class.
|
|
||||||
*/
|
|
||||||
$if(field.fieldDefinition.collectionItemType)$
|
|
||||||
public function getList(): $field.fieldDefinition.returnType${
|
|
||||||
return $field.fieldDefinition.name$;
|
|
||||||
}$endif$}$
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace SwaggerRuntime.Attributes
|
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
|
|
||||||
public class AllowableValuesAttribute : Attribute
|
|
||||||
{
|
|
||||||
private string _value = "";
|
|
||||||
|
|
||||||
public string Value
|
|
||||||
{
|
|
||||||
get { return _value; }
|
|
||||||
set { _value = value; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace SwaggerRuntime.Attributes
|
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Method)]
|
|
||||||
public class MethodArgumentNamesAttribute : Attribute
|
|
||||||
{
|
|
||||||
private string _value = "";
|
|
||||||
|
|
||||||
public string Value
|
|
||||||
{
|
|
||||||
get { return _value; }
|
|
||||||
set { _value = value; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace SwaggerRuntime.Attributes
|
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Property)]
|
|
||||||
public class RequiredAttribute : Attribute
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,161 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
using System.Web;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using SwaggerRuntime.Exceptions;
|
|
||||||
|
|
||||||
namespace SwaggerRuntime.Common
|
|
||||||
{
|
|
||||||
public abstract class ApiBase
|
|
||||||
{
|
|
||||||
private readonly string _apiBaseUrl;
|
|
||||||
private readonly ISecurityHandler _securityHandler;
|
|
||||||
|
|
||||||
protected ApiBase(string apiBaseUrl, ISecurityHandler securityHandler)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(apiBaseUrl))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Argument can't be null nor empty.", "apiBaseUrl");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (securityHandler == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("securityHandler");
|
|
||||||
}
|
|
||||||
|
|
||||||
_apiBaseUrl = apiBaseUrl;
|
|
||||||
_securityHandler = securityHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected string InvokeApi(string resourceUrl, string method, IDictionary<string, string> queryParams, Object postData, IDictionary<string, string> headerParams)
|
|
||||||
{
|
|
||||||
string absoluteResourceUrl = _apiBaseUrl + resourceUrl;
|
|
||||||
|
|
||||||
if (queryParams.Count > 0)
|
|
||||||
{
|
|
||||||
bool isFirst = true;
|
|
||||||
|
|
||||||
foreach (string queryParamName in queryParams.Keys)
|
|
||||||
{
|
|
||||||
absoluteResourceUrl += isFirst ? "?" : "&";
|
|
||||||
isFirst = false;
|
|
||||||
|
|
||||||
absoluteResourceUrl += queryParamName + "=" + EncodeUrl(queryParams[queryParamName]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var headers = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
_securityHandler.PopulateSecurityInfo(absoluteResourceUrl, headers);
|
|
||||||
|
|
||||||
var request = (HttpWebRequest)WebRequest.Create(absoluteResourceUrl);
|
|
||||||
|
|
||||||
request.Method = method;
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> headerKvp in headers)
|
|
||||||
{
|
|
||||||
request.Headers[headerKvp.Key] = headerKvp.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (headerParams != null)
|
|
||||||
{
|
|
||||||
foreach (KeyValuePair<string, string> headerKvp in headerParams)
|
|
||||||
{
|
|
||||||
request.Headers[headerKvp.Key] = headerKvp.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var response = (HttpWebResponse)request.GetResponse())
|
|
||||||
using (Stream responseStream = response.GetResponseStream())
|
|
||||||
{
|
|
||||||
if (responseStream == null)
|
|
||||||
{
|
|
||||||
throw new IOException("Couldn't get response stream.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.StatusCode != HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
throw new ApiException((int)response.StatusCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var sr = new StreamReader(responseStream))
|
|
||||||
{
|
|
||||||
return sr.ReadToEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected T Deserialize<T>(string response)
|
|
||||||
{
|
|
||||||
var jsonSerializer = new JsonSerializer();
|
|
||||||
|
|
||||||
using (var sr = new StringReader(response))
|
|
||||||
using (var jtr = new JsonTextReader(sr))
|
|
||||||
{
|
|
||||||
return jsonSerializer.Deserialize<T>(jtr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected string Serialize(object input)
|
|
||||||
{
|
|
||||||
var jsonSerializer = new JsonSerializer();
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
|
|
||||||
using (var sw = new StringWriter(sb))
|
|
||||||
{
|
|
||||||
jsonSerializer.Serialize(sw, input);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected string ToPathValue(string value)
|
|
||||||
{
|
|
||||||
return EncodeUrl(value ?? "");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected string ToPathValue(IEnumerable<object> objects)
|
|
||||||
{
|
|
||||||
StringBuilder outSb = new StringBuilder();
|
|
||||||
|
|
||||||
foreach (object obj in objects)
|
|
||||||
{
|
|
||||||
outSb.Append(obj.ToString());
|
|
||||||
outSb.Append(",");
|
|
||||||
}
|
|
||||||
|
|
||||||
string output = outSb.ToString();
|
|
||||||
|
|
||||||
if (output.IndexOf(",") != -1)
|
|
||||||
{
|
|
||||||
output = output.Substring(0, output.LastIndexOf(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
return EncodeUrl(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected string EncodeUrl(string value)
|
|
||||||
{
|
|
||||||
return HttpUtility.UrlEncode(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace SwaggerRuntime.Common
|
|
||||||
{
|
|
||||||
public class ApiKeyAuthTokenBasedSecurityHandler : ISecurityHandler
|
|
||||||
{
|
|
||||||
private readonly string _apiKey = "";
|
|
||||||
|
|
||||||
public ApiKeyAuthTokenBasedSecurityHandler(string apiKey)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(apiKey))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Argument can't be null nor empty.", "apiKey");
|
|
||||||
}
|
|
||||||
|
|
||||||
_apiKey = apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region ISecurityHandler members
|
|
||||||
|
|
||||||
public void PopulateSecurityInfo(string resourceURL, IDictionary<string, string> httpHeaders)
|
|
||||||
{
|
|
||||||
httpHeaders.Add("api_key", _apiKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace SwaggerRuntime.Common
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Provide methods that are responsible for handling security aspect while communicating with the backend server.
|
|
||||||
///
|
|
||||||
/// Example: For some cases API key may need to be passed in the headers for all server communication and some times
|
|
||||||
/// user authentication token may need to be passed along with api key.
|
|
||||||
///
|
|
||||||
/// Implementers of this class are responsible for handling storing information related to secutiry and sending it
|
|
||||||
/// along with all API calls.
|
|
||||||
/// </summary>
|
|
||||||
public interface ISecurityHandler
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Populate the security infomration in http headers map and/or reqsource URL.
|
|
||||||
///
|
|
||||||
/// Values populated in the http headers map will be set as http headers while making the server communication.
|
|
||||||
///
|
|
||||||
/// Depending on the usecase requried information can be added to either of them or both.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="resourceURL"></param>
|
|
||||||
/// <param name="httpHeaders"></param>
|
|
||||||
void PopulateSecurityInfo(string resourceURL, IDictionary<string, string> httpHeaders);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace SwaggerRuntime.Exceptions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// An exception that is thrown if there are any issues while invoking the API.
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class ApiException : Exception
|
|
||||||
{
|
|
||||||
public ApiException(int httpStatusCode)
|
|
||||||
: base(string.Format("Api exception ({0}).", httpStatusCode))
|
|
||||||
{
|
|
||||||
HttpStatusCode = httpStatusCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int HttpStatusCode { get; private set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace $packageName$
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// $enum.description; format="xml-safe"$
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
/// </remarks>
|
|
||||||
public enum $className$
|
|
||||||
{
|
|
||||||
$values: { value | $value.name$ };separator=",\r\n"$
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using SwaggerRuntime.Attributes;
|
|
||||||
$imports:{ import |
|
|
||||||
using $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
namespace $packageName$
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// $model.description; format="xml-safe"$
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
/// </remarks>
|
|
||||||
public class $className$ : $extends$
|
|
||||||
{
|
|
||||||
$fields:{ field |
|
|
||||||
/// <summary>
|
|
||||||
/// $field.description; format="xml-safe"$
|
|
||||||
/// </summary>
|
|
||||||
$if(field.required)$
|
|
||||||
[Required]
|
|
||||||
$endif$
|
|
||||||
$if(field.allowableValues)$
|
|
||||||
[AllowableValues(Value="$field.allowedValuesString$")]
|
|
||||||
$endif$
|
|
||||||
public $field.fieldDefinition.returnType$ $field.fieldDefinition.NameForMethod$ { get; set; }
|
|
||||||
}$
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using $modelPackageName$;
|
|
||||||
using SwaggerRuntime.Attributes;
|
|
||||||
using SwaggerRuntime.Common;
|
|
||||||
using SwaggerRuntime.Exceptions;
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
namespace $packageName$
|
|
||||||
{
|
|
||||||
/// <remarks>
|
|
||||||
/// NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
/// </remarks>
|
|
||||||
public class $resource$ : $extends$
|
|
||||||
{
|
|
||||||
public $resource$(string apiBaseUrl, ISecurityHandler securityHandler)
|
|
||||||
: base(apiBaseUrl, securityHandler)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
$methods:{ method |
|
|
||||||
/// <summary>
|
|
||||||
/// $method.title; format="xml-safe"$
|
|
||||||
$if(method.description)$
|
|
||||||
/// $method.description; format="xml-safe"$
|
|
||||||
$endif$</summary>
|
|
||||||
$method.arguments:{ argument | /// <param name="$argument.name; format="xml-safe"$">
|
|
||||||
/// $argument.description; format="xml-safe"$
|
|
||||||
$if(argument.allowedValues)$
|
|
||||||
/// Allowed values are - $argument.allowedValues; format="xml-safe"$
|
|
||||||
$endif$
|
|
||||||
/// </param> }$
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
/// <returns>
|
|
||||||
/// <see cref="$method.returnClassName; format="xml-safe"$">$method.returnValue; format="xml-safe"$</see>
|
|
||||||
/// </returns>
|
|
||||||
$endif$
|
|
||||||
/// <exception cref="ApiException">$method.exceptionDescription; format="xml-safe"$</exception>
|
|
||||||
$if(method.hasArguments)$
|
|
||||||
[MethodArgumentNames(Value = "$method.argumentNames; separator=", "$")]
|
|
||||||
$endif$
|
|
||||||
public $method.returnValue$ $method.name$($method.argumentDefinitions; separator=", "$)
|
|
||||||
{
|
|
||||||
// parse inputs
|
|
||||||
string resourcePath = "$method.resourcePath$";
|
|
||||||
|
|
||||||
resourcePath = resourcePath.Replace("{format}","json");
|
|
||||||
|
|
||||||
string method = "$method.methodType$";
|
|
||||||
|
|
||||||
var queryParams = new Dictionary<string, string>();
|
|
||||||
var headerParams = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
$if(!method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if( $argument.name$ != null) {
|
|
||||||
queryParams.Add("$argument.name$", ToPathValue($argument.name$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if ($argument.name$ != null)
|
|
||||||
{
|
|
||||||
resourcePath = resourcePath.Replace("{$argument.name$}", ToPathValue($argument.name$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if ($argument.name$ != null)
|
|
||||||
{
|
|
||||||
headerParams.Add("$argument.name$", ToPathValue($argument.name$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
|
|
||||||
$endif$
|
|
||||||
$if(method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if ($argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null)
|
|
||||||
{
|
|
||||||
queryParams.Add("$argument.name$", ToPathValue($argument.methodNameFromModelClass$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if ($argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null)
|
|
||||||
{
|
|
||||||
resourcePath = resourcePath.Replace("{$argument.name$}", ToPathValue($argument.methodNameFromModelClass$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if ($argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null)
|
|
||||||
{
|
|
||||||
headerParams.Add("$argument.name$", ToPathValue($argument.methodNameFromModelClass$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
// make the API Call
|
|
||||||
$if(method.postObject)$ $if(!method.responseVoid)$string response = $endif$InvokeApi(resourcePath, method, queryParams, postData, headerParams);$endif$
|
|
||||||
$if(!method.postObject)$ $if(!method.responseVoid)$string response = $endif$InvokeApi(resourcePath, method, queryParams, null, headerParams);$endif$
|
|
||||||
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
if (string.IsNullOrEmpty(response))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$if(!method.returnValueList)$
|
|
||||||
// create output objects if the response has more than one object
|
|
||||||
$method.returnValue$ responseObject = Deserialize<$method.returnClassName$>(response);
|
|
||||||
|
|
||||||
return responseObject;
|
|
||||||
$endif$
|
|
||||||
$if(method.returnValueList)$
|
|
||||||
return Deserialize<List<$method.returnClassName$>>(response);
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace $packageName$
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Maintains the compatible server version against which the drive is written.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
/// </remarks>
|
|
||||||
public static class VersionChecker
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The version against which the library code was written.
|
|
||||||
/// </summary>
|
|
||||||
public const string CompatibleVersion = "$apiVersion$";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,111 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<project name="swagger-sample-java-lib" xmlns:ivy="antlib:org.apache.ivy.ant" default="build.all" basedir=".">
|
|
||||||
<property environment="env" />
|
|
||||||
<property name="version.identifier" value="1.0" />
|
|
||||||
<property name="artifact.ext" value="jar" />
|
|
||||||
<property name="organization" value="wordnik" />
|
|
||||||
<property name="module" value="${ant.project.name}" />
|
|
||||||
|
|
||||||
<!-- default dirs for the build -->
|
|
||||||
<mkdir dir="lib"/>
|
|
||||||
<mkdir dir="lib/ext"/>
|
|
||||||
|
|
||||||
<condition property="scala.home" value="${env.SCALA_HOME}">
|
|
||||||
<isset property="env.SCALA_HOME" />
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<path id="scala.classpath">
|
|
||||||
<fileset dir="${scala.home}/lib">
|
|
||||||
<include name="scala**.jar" />
|
|
||||||
</fileset>
|
|
||||||
</path>
|
|
||||||
|
|
||||||
<ivy:settings file="ivysettings.xml" />
|
|
||||||
|
|
||||||
<taskdef resource="scala/tools/ant/antlib.xml">
|
|
||||||
<classpath>
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="scala**.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="${scala.home}/lib">
|
|
||||||
<include name="scala**.jar" />
|
|
||||||
</fileset>
|
|
||||||
</classpath>
|
|
||||||
</taskdef>
|
|
||||||
|
|
||||||
<!-- this is the output module -->
|
|
||||||
<property name="module" value="${ant.project.name}" />
|
|
||||||
|
|
||||||
<target name="build.all" depends="clean, resolve, fastcompile" description="builds the module (default target)" />
|
|
||||||
|
|
||||||
<target name="clean" description="cleans the project folder">
|
|
||||||
<mkdir dir="build" />
|
|
||||||
<echo message="deleting build files" />
|
|
||||||
<delete quiet="true">
|
|
||||||
<fileset dir="build">
|
|
||||||
<include name="*.jar" />
|
|
||||||
<include name="*.xml" />
|
|
||||||
</fileset>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete dir="build/main" quiet="true" />
|
|
||||||
|
|
||||||
<delete dir="dist" quiet="true" />
|
|
||||||
|
|
||||||
<!-- libraries handled by ivy -->
|
|
||||||
<echo message="deleting libs handled by ivy" />
|
|
||||||
<delete>
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="*.jar" />
|
|
||||||
<include name="*.zip" />
|
|
||||||
</fileset>
|
|
||||||
</delete>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- copies ONLY the swagger-sample jar to dist-->
|
|
||||||
<target name="fastdist" depends="fastcompile">
|
|
||||||
<copy todir="dist/lib">
|
|
||||||
<fileset dir="build">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
</copy>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- copies all dependencies into the lib folder -->
|
|
||||||
<target name="resolve" description="retreive dependencies with ivy">
|
|
||||||
<ivy:retrieve pattern="${basedir}/lib/[artifact]-[revision].[ext]" conf="build" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="fastcompile" description="builds the module without artifact resolution or cleaning">
|
|
||||||
<delete quiet="true" file="build/${organization}-${artifact}-*.${artifact.ext}" />
|
|
||||||
<mkdir dir="build" />
|
|
||||||
<mkdir dir="build/main" />
|
|
||||||
<mkdir dir="build/main/java" />
|
|
||||||
|
|
||||||
<javac srcdir="src/main/java" debug="true" destdir="build/main/java">
|
|
||||||
<classpath>
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="lib/ext">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<pathelement location="build/main/java" />
|
|
||||||
</classpath>
|
|
||||||
</javac>
|
|
||||||
<jar jarfile="build/${module}-${version.identifier}.${artifact.ext}">
|
|
||||||
<fileset dir="build/main/java" />
|
|
||||||
</jar>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- cleans up the dist -->
|
|
||||||
<target name="dist.clean" description="cleans the distribution folder">
|
|
||||||
<delete quiet="true" dir="dist" />
|
|
||||||
<delete quiet="true" file="dist.zip" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="dependency.tree" description="builds a graphml dependency diagram for viewing with yEd">
|
|
||||||
<ivy:report conf="build" graph="true" todir="." outputpattern="[artifact]-[revision].[ext]" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,31 +0,0 @@
|
|||||||
<ivy-module version="2.0">
|
|
||||||
<info organisation="wordnik" module="sample-java-lib"/>
|
|
||||||
<configurations>
|
|
||||||
<conf name="build" description="build wordnik-java"/>
|
|
||||||
<conf name="test" visibility="public"/>
|
|
||||||
<conf name="source" visibility="public"/>
|
|
||||||
<conf name="pom" visibility="public"/>
|
|
||||||
</configurations>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- jersey dependencies -->
|
|
||||||
<dependency org="junit" name="junit" rev="4.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-json" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-client" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-server" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-core" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="asm" name="asm-parent" rev="3.1" conf="build->default"/>
|
|
||||||
<dependency org="commons-beanutils" name="commons-beanutils" rev="1.8.0" conf="build->default"/>
|
|
||||||
<dependency org="org.antlr" name="stringtemplate" rev="3.2" conf="build->default"/>
|
|
||||||
<!-- jackson jars -->
|
|
||||||
<dependency org="org.codehaus.jackson" name="jackson-jaxrs" rev="1.7.1" conf="build->default"/>
|
|
||||||
<dependency org="org.codehaus.jackson" name="jackson-xc" rev="1.7.1" conf="build->default"/>
|
|
||||||
<dependency org="org.codehaus.jackson" name="jackson-mapper-asl" rev="1.7.1" conf="build->default"/>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency org="net.sourceforge.cobertura" name="cobertura" rev="1.9.2" conf="test->default">
|
|
||||||
<exclude org="asm" name="asm-tree"/>
|
|
||||||
<exclude org="asm" name="asm"/>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</ivy-module>
|
|
@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ivysettings>
|
|
||||||
<settings defaultResolver="chained" />
|
|
||||||
<property name="ivy.checksums" value=""/>
|
|
||||||
<property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local"
|
|
||||||
override="false" />
|
|
||||||
<property name="ivy.local.default.ivy.pattern"
|
|
||||||
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
|
|
||||||
override="false" />
|
|
||||||
<property name="ivy.local.default.artifact.pattern"
|
|
||||||
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
|
|
||||||
override="false" />
|
|
||||||
<resolvers>
|
|
||||||
<chain name="chained" returnFirst="true">
|
|
||||||
<filesystem name="local">
|
|
||||||
<ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}" />
|
|
||||||
<artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
|
|
||||||
</filesystem>
|
|
||||||
<ibiblio name="ibiblio" m2compatible="true" />
|
|
||||||
<ibiblio name="javanet" root="http://download.java.net/maven/2/" m2compatible="true" />
|
|
||||||
</chain>
|
|
||||||
</resolvers>
|
|
||||||
</ivysettings>
|
|
@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"apiUrl":"http://localhost:8002/api/",
|
|
||||||
|
|
||||||
"apiKey":"special-key",
|
|
||||||
|
|
||||||
"defaultServiceBaseClass":"Object",
|
|
||||||
|
|
||||||
"defaultModelBaseClass":"Object",
|
|
||||||
|
|
||||||
"serviceBaseClasses":{},
|
|
||||||
|
|
||||||
"defaultModelImports":[],
|
|
||||||
|
|
||||||
"defaultServiceImports":[],
|
|
||||||
|
|
||||||
"modelPackageName":"com.wordnik.swagger.sample.sdk.java.model",
|
|
||||||
|
|
||||||
"apiPackageName":"com.wordnik.swagger.sample.sdk.java.api",
|
|
||||||
|
|
||||||
"ignoreMethods":[],
|
|
||||||
|
|
||||||
"ignoreModels":[],
|
|
||||||
|
|
||||||
"outputDirectory":"../swagger-sample-app/sdk-libs/src/main/java/com/wordnik/swagger/sample/sdk/java",
|
|
||||||
|
|
||||||
"libraryHome":"../swagger-sample-app/sdk-libs"
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
{
|
|
||||||
"userList":[
|
|
||||||
{
|
|
||||||
"username":"testuser1",
|
|
||||||
"password":"password1",
|
|
||||||
"email":"test1@dummy.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username":"testuser2",
|
|
||||||
"password":"password2",
|
|
||||||
"email":"test2@dummy.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username":"user?10",
|
|
||||||
"password":"password2",
|
|
||||||
"email":"test2@dummy.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"petList":[
|
|
||||||
{
|
|
||||||
"id":101,
|
|
||||||
"name":"pet1",
|
|
||||||
"photoUrls":["url1","url2"],
|
|
||||||
"tags":[
|
|
||||||
{
|
|
||||||
"id":1,
|
|
||||||
"name":"tag1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":2,
|
|
||||||
"name":"tag2"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"status":"available",
|
|
||||||
"category":{"id":1,"name":"cat1"}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"orderList":[
|
|
||||||
{
|
|
||||||
"id":101,
|
|
||||||
"petId":1,
|
|
||||||
"quantity":1,
|
|
||||||
"status":"placed",
|
|
||||||
"shipDate":13456789
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,325 +0,0 @@
|
|||||||
{
|
|
||||||
"resources" : [
|
|
||||||
{
|
|
||||||
"id" : 1,
|
|
||||||
"name" : "Find Per by Id",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/{petId}",
|
|
||||||
"suggestedMethodName" : "getPetById"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 2,
|
|
||||||
"name" : "Find pets by status",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/findByStatus",
|
|
||||||
"suggestedMethodName" : "findPetsByStatus"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 3,
|
|
||||||
"name" : "Find pets by tags",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/findByTags",
|
|
||||||
"suggestedMethodName" : "findPetsByTags"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 4,
|
|
||||||
"name" : "Add a pet",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/pet.{format}",
|
|
||||||
"suggestedMethodName" : "addPet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 5,
|
|
||||||
"name" : "Update a pet",
|
|
||||||
"httpMethod" : "PUT",
|
|
||||||
"path" : "/pet.{format}",
|
|
||||||
"suggestedMethodName" : "updatePet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 6,
|
|
||||||
"name" : "Create user",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/user.{format}",
|
|
||||||
"suggestedMethodName" : "createUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 7,
|
|
||||||
"name" : "Update user",
|
|
||||||
"httpMethod" : "PUT",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "updateUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 8,
|
|
||||||
"name" : "Delete user",
|
|
||||||
"httpMethod" : "DELETE",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "deleteUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 9,
|
|
||||||
"name" : "Get user by user name",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "getUserByName"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 10,
|
|
||||||
"name" : "Login",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/login",
|
|
||||||
"suggestedMethodName" : "loginUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 11,
|
|
||||||
"name" : "Logout",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/logout",
|
|
||||||
"suggestedMethodName" : "logoutUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 12,
|
|
||||||
"name" : "Find order by id",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/store.{format}/order/{orderId}",
|
|
||||||
"suggestedMethodName" : "getOrderById"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 13,
|
|
||||||
"name" : "Delete order by id",
|
|
||||||
"httpMethod" : "DELETE",
|
|
||||||
"path" : "/store.{format}/order/{orderId}",
|
|
||||||
"suggestedMethodName" : "deleteOrder"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 14,
|
|
||||||
"name" : "Create order",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/store.{format}/order",
|
|
||||||
"suggestedMethodName" : "placeOrder"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 15,
|
|
||||||
"name" : "Get users with array input",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/user.{format}/usersWithArray",
|
|
||||||
"suggestedMethodName" : "getUserByNamesArray"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 16,
|
|
||||||
"name" : "get users with list",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/user.{format}/usersWithList",
|
|
||||||
"suggestedMethodName" : "getUserByNamesList"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"testSuites" : [
|
|
||||||
{
|
|
||||||
"id" : 1,
|
|
||||||
"name" : "Test User service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Create User",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 6,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.userList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Login User",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 10,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}",
|
|
||||||
"password":"${input.userList[0].password}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find user by name",
|
|
||||||
"id" : 3,
|
|
||||||
"resourceId" : 9,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.3).username}",
|
|
||||||
"condition" : "==",
|
|
||||||
"expectedOutput" : "${input.userList[0].username}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Delete user by name",
|
|
||||||
"id" : 4,
|
|
||||||
"resourceId" : 9,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.4)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find user by name with special characters",
|
|
||||||
"id" : 5,
|
|
||||||
"resourceId" : 9,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[2].username}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.5).username}",
|
|
||||||
"condition" : "==",
|
|
||||||
"expectedOutput" : "${input.userList[2].username}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find users with array of user names",
|
|
||||||
"id" : 6,
|
|
||||||
"resourceId" : 15,
|
|
||||||
"input" : {
|
|
||||||
"postData":"[\"testuser1\", \"testuser2\"]"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.6).size}",
|
|
||||||
"condition" : "==",
|
|
||||||
"expectedOutput" : "2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find users with list of user names",
|
|
||||||
"id" : 7,
|
|
||||||
"resourceId" : 16,
|
|
||||||
"input" : {
|
|
||||||
"postData":"[\"testuser1\", \"testuser2\"]"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.7).size}",
|
|
||||||
"condition" : "==",
|
|
||||||
"expectedOutput" : "2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 2,
|
|
||||||
"name" : "Test Pet service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Add pet",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 4,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.petList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find pet by id",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 1,
|
|
||||||
"input" : {
|
|
||||||
"petId":"1"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "NULL"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find pet by status",
|
|
||||||
"id" : 3,
|
|
||||||
"resourceId" : 2,
|
|
||||||
"input" : {
|
|
||||||
"status":"available,sold,pending"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.3).size}",
|
|
||||||
"condition" : ">",
|
|
||||||
"expectedOutput" : "0"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 3,
|
|
||||||
"name" : "Test Store service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Find order by id",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 12,
|
|
||||||
"input" : {
|
|
||||||
"orderId":"3"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(3.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "NULL"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Place order",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 14,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.orderList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package $packageName$;
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $enum.description$
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
* @author deepak
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public enum $className$ {
|
|
||||||
|
|
||||||
$values: { value | $value.name$($value.value$)};separator=", "$;
|
|
||||||
|
|
||||||
private $enumValueType$ value;
|
|
||||||
|
|
||||||
$className$($enumValueType$ value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public $enumValueType$ getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
return String.valueOf(this.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package $packageName$;
|
|
||||||
|
|
||||||
import com.wordnik.swagger.runtime.annotations.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
* @author ramesh
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class $className$ extends $extends$ {
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $field.description$
|
|
||||||
*/
|
|
||||||
private $field.fieldDefinition.returnType$ $field.fieldDefinition.name$ $field.fieldDefinition.initialization$;$\r$}$
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
/**
|
|
||||||
* $field.description$
|
|
||||||
* $if(field.required)$@Required$endif$
|
|
||||||
* $if(field.allowableValues)$@AllowableValues(value="$field.allowedValuesString$")$endif$
|
|
||||||
*/
|
|
||||||
public $field.fieldDefinition.returnType$ get$field.fieldDefinition.NameForMethod$() {
|
|
||||||
return $field.fieldDefinition.name$;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set$field.fieldDefinition.NameForMethod$($field.fieldDefinition.returnType$ $field.fieldDefinition.name$) {
|
|
||||||
this.$field.fieldDefinition.name$ = $field.fieldDefinition.name$;
|
|
||||||
}
|
|
||||||
|
|
||||||
}$
|
|
||||||
}
|
|
@ -1,152 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package $packageName$;
|
|
||||||
|
|
||||||
|
|
||||||
import $modelPackageName$.*;
|
|
||||||
|
|
||||||
import org.codehaus.jackson.map.DeserializationConfig.Feature;
|
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
|
||||||
import org.codehaus.jackson.type.TypeReference;
|
|
||||||
import com.wordnik.swagger.runtime.annotations.*;
|
|
||||||
import com.wordnik.swagger.runtime.common.*;
|
|
||||||
import com.wordnik.swagger.runtime.exception.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.lang.Long;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
* @author ramesh
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class $resource$ extends $extends$ {
|
|
||||||
|
|
||||||
private static APIInvoker apiInvoker = null;
|
|
||||||
|
|
||||||
$methods:{ method |
|
|
||||||
/**
|
|
||||||
* $method.title$
|
|
||||||
*
|
|
||||||
$if(method.description)$
|
|
||||||
* $method.description$
|
|
||||||
* $endif$
|
|
||||||
* $method.arguments:{ argument |@param $argument.name$ $argument.description$
|
|
||||||
* $if(argument.allowedValues)$
|
|
||||||
* Allowed values are - $argument.allowedValues$ $endif$ }$
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
|
|
||||||
* @throws APIException $method.exceptionDescription$
|
|
||||||
*/
|
|
||||||
$if(method.hasArguments)$
|
|
||||||
@MethodArgumentNames(value="$method.argumentNames; separator=", "$")
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
public static $method.returnValue$ $method.name$($method.argumentDefinitions; separator=", "$) throws APIException {
|
|
||||||
|
|
||||||
//parse inputs
|
|
||||||
String resourcePath = "$method.resourcePath$";
|
|
||||||
resourcePath = resourcePath.replace("{format}","json");
|
|
||||||
String method = "$method.methodType$";
|
|
||||||
Map<String, String> queryParams = new HashMap<String, String>();
|
|
||||||
Map<String, String> headerParams = new HashMap<String, String>();
|
|
||||||
$if(!method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if( $argument.name$ != null) {
|
|
||||||
queryParams.put("$argument.name$", APIInvoker.toPathValue($argument.name$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if( $argument.name$ != null) {
|
|
||||||
resourcePath = resourcePath.replace("{$argument.name$}", APIInvoker.toPathValue($argument.name$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if( $argument.name$ != null) {
|
|
||||||
headerParams.put("$argument.name$", APIInvoker.toPathValue($argument.name$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
|
|
||||||
$endif$
|
|
||||||
$if(method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
|
|
||||||
queryParams.put("$argument.name$", APIInvoker.toPathValue($argument.methodNameFromModelClass$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
|
|
||||||
resourcePath = resourcePath.replace("{$argument.name$}", APIInvoker.toPathValue($argument.methodNameFromModelClass$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
|
|
||||||
headerParams.put("$argument.name$", APIInvoker.toPathValue($argument.methodNameFromModelClass$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
//make the API Call
|
|
||||||
$if(method.postObject)$
|
|
||||||
String response = getApiInvoker().invokeAPI(resourcePath, method, queryParams, postData, headerParams);
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
$if(!method.postObject)$
|
|
||||||
String response = getApiInvoker().invokeAPI(resourcePath, method, queryParams, null, headerParams);
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
if(response == null || response.length() == 0){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$if(!method.returnValueList)$
|
|
||||||
//create output objects if the response has more than one object
|
|
||||||
$method.returnValue$ responseObject = ($method.returnValue$) getApiInvoker().deserialize(response, $method.returnClassName$.class);
|
|
||||||
return responseObject;
|
|
||||||
$endif$
|
|
||||||
$if(method.returnValueList)$
|
|
||||||
TypeReference<ArrayList<$method.returnClassName$>> typeRef = new TypeReference<ArrayList<$method.returnClassName$>>() {};
|
|
||||||
try {
|
|
||||||
List<$method.returnClassName$> responseObject = (List<$method.returnClassName$>) getApiInvoker().mapper.readValue(response, typeRef);
|
|
||||||
return responseObject;
|
|
||||||
} catch (IOException ioe) {
|
|
||||||
String[] args = new String[]{response, typeRef.toString()};
|
|
||||||
throw new APIException(APIExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe);
|
|
||||||
}
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
}
|
|
||||||
|
|
||||||
}$
|
|
||||||
|
|
||||||
public static APIInvoker getApiInvoker() {
|
|
||||||
if(apiInvoker == null){
|
|
||||||
apiInvoker = APIInvoker.getApiInvoker();
|
|
||||||
}
|
|
||||||
return apiInvoker;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setApiInvoker(APIInvoker invoker) {
|
|
||||||
apiInvoker = invoker;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package $packageName$;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Maintains the compatible server version against which the drive is written
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
* @author ramesh
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class VersionChecker {
|
|
||||||
|
|
||||||
private String compatibleVersion = "$apiVersion$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the version against which the library code was written
|
|
||||||
*/
|
|
||||||
public String getCompatibleVersion() {
|
|
||||||
return compatibleVersion;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"apiUrl":"http://localhost:8002/api/",
|
|
||||||
|
|
||||||
"apiKey":"special-key",
|
|
||||||
|
|
||||||
"defaultServiceBaseClass":"SwaggerApi",
|
|
||||||
|
|
||||||
"defaultModelBaseClass":"Object",
|
|
||||||
|
|
||||||
"serviceBaseClasses":{},
|
|
||||||
|
|
||||||
"defaultModelImports":[],
|
|
||||||
|
|
||||||
"defaultServiceImports":[],
|
|
||||||
|
|
||||||
"modelPackageName":"",
|
|
||||||
|
|
||||||
"apiPackageName":"",
|
|
||||||
|
|
||||||
"ignoreMethods":[],
|
|
||||||
|
|
||||||
"ignoreModels":[],
|
|
||||||
|
|
||||||
"outputDirectory":"../swagger-sample-app/sdk-libs/src/main/js/",
|
|
||||||
|
|
||||||
"libraryHome":"../swagger-sample-app/sdk-libs"
|
|
||||||
}
|
|
4
conf/js/structure/lib/jquery-1.6.4.min.js
vendored
4
conf/js/structure/lib/jquery-1.6.4.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,73 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>Swagger Javascript Lib Sandbox</title>
|
|
||||||
<script src="lib/jquery-1.6.4.min.js" type="text/javascript" charset="utf-8"></script>
|
|
||||||
<script src="api-lib.js" type="text/javascript" charset="utf-8"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" charset="utf-8">
|
|
||||||
function log(s) {
|
|
||||||
if(window.console) console.log(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
function logResponse(event) {
|
|
||||||
log("-----------------------------");
|
|
||||||
log(event.type);
|
|
||||||
log(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onUserCreated(event) {
|
|
||||||
logResponse(event);
|
|
||||||
|
|
||||||
// update the created user
|
|
||||||
var user = new User();
|
|
||||||
user.lastName = "Sanders Lama";
|
|
||||||
user.username = "vito";
|
|
||||||
user.phone = "405-607-8980";
|
|
||||||
user.email = "vito@sanders.com";
|
|
||||||
user.userStatus = 1;
|
|
||||||
user.firstName = "Vito";
|
|
||||||
user.password = "XXXXX";
|
|
||||||
UserAPI.updateUser("vito", user);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onUserUpdated(event) {
|
|
||||||
logResponse(event);
|
|
||||||
|
|
||||||
// delete the created user
|
|
||||||
UserAPI.deleteUser("vito");
|
|
||||||
}
|
|
||||||
|
|
||||||
ApiInvoker.init("http://localhost:8002/api/", null, null, false);
|
|
||||||
|
|
||||||
ApiInvoker.addListener(PetAPI.event_getPetById, logResponse);
|
|
||||||
ApiInvoker.addListener(StoreAPI.event_getOrderById, logResponse);
|
|
||||||
ApiInvoker.addListener(UserAPI.event_getUserByName, logResponse);
|
|
||||||
ApiInvoker.addListener(UserAPI.event_loginUser, logResponse);
|
|
||||||
ApiInvoker.addListener(UserAPI.event_createUser, onUserCreated);
|
|
||||||
ApiInvoker.addListener(UserAPI.event_updateUser, onUserUpdated);
|
|
||||||
ApiInvoker.addListener(UserAPI.event_deleteUser, logResponse);
|
|
||||||
|
|
||||||
// Get some data
|
|
||||||
StoreAPI.getOrderById("1");
|
|
||||||
PetAPI.getPetById("1");
|
|
||||||
UserAPI.getUserByName("user1");
|
|
||||||
|
|
||||||
// login
|
|
||||||
UserAPI.loginUser("user1", "XXXXXXXXXXX")
|
|
||||||
|
|
||||||
// create new user
|
|
||||||
var user = new User();
|
|
||||||
user.lastName = "Sanders";
|
|
||||||
user.username = "vito";
|
|
||||||
user.phone = "405-607-8980";
|
|
||||||
user.email = "vito@sanders.com";
|
|
||||||
user.userStatus = 1;
|
|
||||||
user.firstName = "Vito";
|
|
||||||
user.password = "XXXXX";
|
|
||||||
UserAPI.createUser(user);
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<body>
|
|
||||||
</body>
|
|
@ -1,233 +0,0 @@
|
|||||||
var ApiInvoker = new function() {
|
|
||||||
this.apiServer = null,
|
|
||||||
this.authToken = null,
|
|
||||||
this.apiKey = null,
|
|
||||||
this.loggingEnabled = false,
|
|
||||||
this.requestHeader = new Object(),
|
|
||||||
|
|
||||||
this.trace = function(obj) {
|
|
||||||
if (this.loggingEnabled && window.console) console.log(obj);
|
|
||||||
},
|
|
||||||
|
|
||||||
this.error = function(obj) {
|
|
||||||
if (window.console) console.log(obj);
|
|
||||||
},
|
|
||||||
|
|
||||||
this.init = function(apiServer, apiKey, authToken, loggingEnabled) {
|
|
||||||
if (apiServer != null && apiServer.length > 0) {
|
|
||||||
if (apiServer.substring(apiServer.length - 1) == ("/")) {
|
|
||||||
apiServer = apiServer.substring(0, apiServer.length - 1);
|
|
||||||
}
|
|
||||||
this.apiServer = apiServer;
|
|
||||||
this.apiKey = apiKey;
|
|
||||||
this.authToken = authToken;
|
|
||||||
this.loggingEnabled = (loggingEnabled === null) ? false : loggingEnabled;
|
|
||||||
|
|
||||||
if(this.apiKey)
|
|
||||||
this.requestHeader.api_key = this.apiKey;
|
|
||||||
|
|
||||||
if(this.authToken)
|
|
||||||
this.requestHeader.auth_token = this.authToken;
|
|
||||||
|
|
||||||
this.trace(this.requestHeader);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
this.invokeAPI = function(authToken, resourceURL, method, queryParams, postObject, completionEvent, requestId, returnType, callback) {
|
|
||||||
if (this.apiServer == null) {
|
|
||||||
throw new Error("Please call ApiInvoker.init() to initialize the library");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.trace("authToken = " + authToken);
|
|
||||||
this.trace("resourceURL = " + resourceURL);
|
|
||||||
this.trace("method = " + method);
|
|
||||||
// this.trace("returnType = " + returnType);
|
|
||||||
this.trace("completionEvent = " + completionEvent);
|
|
||||||
this.trace("requestId = " + requestId);
|
|
||||||
this.trace("queryParams:");
|
|
||||||
this.trace(queryParams);
|
|
||||||
this.trace("postObject:");
|
|
||||||
this.trace(postObject);
|
|
||||||
|
|
||||||
// create queryParam
|
|
||||||
var counter = 0;
|
|
||||||
var symbol = 0;
|
|
||||||
for (var headerKey in this.requestHeader) {
|
|
||||||
queryParams[headerKey] = this.requestHeader[headerKey]
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var paramName in queryParams) {
|
|
||||||
var paramValue = queryParams[paramName];
|
|
||||||
symbol = "&";
|
|
||||||
if (counter == 0) {
|
|
||||||
symbol = "?";
|
|
||||||
}
|
|
||||||
resourceURL = resourceURL + symbol + paramName + "=" + paramValue.toString();
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
var callURL = this.apiServer + resourceURL;
|
|
||||||
var responseDataType = (returnType === null || returnType == String) ? "html" : "json";
|
|
||||||
|
|
||||||
this.trace("callURL = " + callURL);
|
|
||||||
this.trace("responseDataType = " + responseDataType);
|
|
||||||
var ajaxRequest = null;
|
|
||||||
if (method == "GET") {
|
|
||||||
// $.get(callURL, postObject,
|
|
||||||
// function(response) {
|
|
||||||
// ApiInvoker.fire(completionEvent, returnType, requestId, response, callback);
|
|
||||||
// }, responseDataType).complete(this.showCompleteStatus).error(this.showErrorStatus);
|
|
||||||
ajaxRequest = $.ajax({
|
|
||||||
url: callURL,
|
|
||||||
data: JSON.stringify(postObject),
|
|
||||||
type: "GET",
|
|
||||||
dataType: "jsonp",
|
|
||||||
contentType: "application/json",
|
|
||||||
success: function(response) {
|
|
||||||
ApiInvoker.fire(completionEvent, returnType, requestId, response, callback);
|
|
||||||
}
|
|
||||||
}).complete(this.showCompleteStatus).error(this.showErrorStatus);
|
|
||||||
} else if (method == "POST") {
|
|
||||||
this.trace("sending post");
|
|
||||||
this.trace(JSON.stringify(postObject));
|
|
||||||
ajaxRequest = $.ajax({
|
|
||||||
url: callURL,
|
|
||||||
data: JSON.stringify(postObject),
|
|
||||||
type: "POST",
|
|
||||||
dataType: "json",
|
|
||||||
contentType: "application/json",
|
|
||||||
headers: this.requestHeader,
|
|
||||||
success: function(response) {
|
|
||||||
ApiInvoker.fire(completionEvent, returnType, requestId, response, callback);
|
|
||||||
}
|
|
||||||
}).complete(this.showCompleteStatus).error(this.showErrorStatus);
|
|
||||||
} else if (method == "PUT") {
|
|
||||||
ajaxRequest = $.ajax({
|
|
||||||
url: callURL,
|
|
||||||
data: JSON.stringify(postObject),
|
|
||||||
type: "PUT",
|
|
||||||
dataType: "json",
|
|
||||||
contentType: "application/json",
|
|
||||||
success: function(response) {
|
|
||||||
ApiInvoker.fire(completionEvent, returnType, requestId, response, callback);
|
|
||||||
}
|
|
||||||
}).complete(this.showCompleteStatus).error(this.showErrorStatus);
|
|
||||||
} else if (method == "DELETE") {
|
|
||||||
ajaxRequest = $.ajax({
|
|
||||||
url: callURL,
|
|
||||||
data: JSON.stringify(postObject),
|
|
||||||
type: "DELETE",
|
|
||||||
dataType: "json",
|
|
||||||
contentType: "application/json",
|
|
||||||
success: function(response) {
|
|
||||||
ApiInvoker.fire(completionEvent, returnType, requestId, response, callback);
|
|
||||||
}
|
|
||||||
}).complete(this.showCompleteStatus).error(this.showErrorStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ajaxRequest;
|
|
||||||
},
|
|
||||||
|
|
||||||
this.guid = function() {
|
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
|
|
||||||
function(c) {
|
|
||||||
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
||||||
return v.toString(16);
|
|
||||||
}).toUpperCase();
|
|
||||||
},
|
|
||||||
|
|
||||||
this._listeners = {},
|
|
||||||
|
|
||||||
this.addListener = function(type, listener) {
|
|
||||||
if (!this._listeners[type]) {
|
|
||||||
this._listeners[type] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
this._listeners[type].push(listener);
|
|
||||||
},
|
|
||||||
|
|
||||||
this.fire = function(completionEvent, returnType, requestId, response, callback) {
|
|
||||||
var event = new Object();
|
|
||||||
event.type = completionEvent;
|
|
||||||
event.requestId = requestId;
|
|
||||||
if (returnType === null || returnType == String) {
|
|
||||||
event.data = response;
|
|
||||||
} else {
|
|
||||||
event.data = eval("new " + returnType);
|
|
||||||
event.data.parse(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof event == "string") {
|
|
||||||
event = { type: event };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event.target) {
|
|
||||||
event.target = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event.type) {
|
|
||||||
throw new Error("Event object must have 'type' property");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.trace(event.data);
|
|
||||||
if(callback) {
|
|
||||||
this.trace("invoking callback");
|
|
||||||
callback(event);
|
|
||||||
} else {
|
|
||||||
this.trace("firing event " + event.type);
|
|
||||||
|
|
||||||
if (this._listeners[event.type]) {
|
|
||||||
var listeners = this._listeners[event.type];
|
|
||||||
for (var i = 0; i < listeners.length; i++) {
|
|
||||||
listeners[i].call(this, event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
this.removeListener = function(type, listener) {
|
|
||||||
if (this._listeners[type]) {
|
|
||||||
var listeners = this._listeners[type];
|
|
||||||
for (var i = 0; i < listeners.length; i++) {
|
|
||||||
if (listeners[i] === listener) {
|
|
||||||
listeners.splice(i, 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
this.showErrorStatus = function(data) {
|
|
||||||
ApiInvoker.trace(data);
|
|
||||||
if (data.status != 200) {
|
|
||||||
ApiInvoker.error("ERROR - " + data.status + ": " + data.statusText + " / " + data.responseText);
|
|
||||||
} else {
|
|
||||||
ApiInvoker.showStatus(data);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
this.showCompleteStatus = function(data) {
|
|
||||||
ApiInvoker.trace("complete " + data.status);
|
|
||||||
// ApiInvoker.showStatus(data);
|
|
||||||
},
|
|
||||||
|
|
||||||
this.showStatus = function(data) {
|
|
||||||
ApiInvoker.trace(data);
|
|
||||||
ApiInvoker.trace(data.getAllResponseHeaders());
|
|
||||||
},
|
|
||||||
|
|
||||||
this.toPathValue = function(value) {
|
|
||||||
if(typeof value == Array){
|
|
||||||
return this.arrayToPathValue(value);
|
|
||||||
} else
|
|
||||||
return value == null ? "" : value.toString();
|
|
||||||
},
|
|
||||||
|
|
||||||
this.arrayToPathValue = function(objects) {
|
|
||||||
return objects.join(",");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
@ -1,30 +0,0 @@
|
|||||||
package $packageName$;
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $enum.description$
|
|
||||||
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
|
|
||||||
* @author deepak
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public enum $className$ {
|
|
||||||
|
|
||||||
$values: { value | $value.name$($value.value$)};separator=", "$;
|
|
||||||
|
|
||||||
final $enumValueType$ value;
|
|
||||||
|
|
||||||
$className$($enumValueType$ value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public $enumValueType$ getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
return String.valueOf(this.getValue());
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,66 +0,0 @@
|
|||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*/
|
|
||||||
function $className$() {
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $field.description$
|
|
||||||
* $if(field.required)$@Required$endif$
|
|
||||||
* $if(field.allowableValues)$[AllowableValues(value="$field.allowedValuesString$"]$endif$
|
|
||||||
*/
|
|
||||||
this.$field.fieldDefinition.name$ = null;$\r$}$
|
|
||||||
|
|
||||||
|
|
||||||
this.parse = function(data) {
|
|
||||||
if(data) {
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
$! //$field.fieldDefinition.returnType$ (primitive=$field.fieldDefinition.hasPrimitiveType$) !$
|
|
||||||
$if(field.fieldDefinition.hasListResponse)$
|
|
||||||
$if(field.fieldDefinition.hasPrimitiveType)$
|
|
||||||
this.$field.fieldDefinition.name$ = data.$field.fieldDefinition.name$;
|
|
||||||
$else$
|
|
||||||
this.$field.fieldDefinition.name$ = $field.fieldDefinition.collectionItemType$Object.parseArray(data.$field.fieldDefinition.name$);
|
|
||||||
$endif$
|
|
||||||
$elseif(field.fieldDefinition.hasSetResponse)$
|
|
||||||
$if(field.fieldDefinition.hasPrimitiveType)$
|
|
||||||
this.$field.fieldDefinition.name$ = data.$field.fieldDefinition.name$;
|
|
||||||
$else$
|
|
||||||
this.$field.fieldDefinition.name$ = $field.fieldDefinition.collectionItemType$Collection.get(data.$field.fieldDefinition.name$);
|
|
||||||
$endif$
|
|
||||||
$elseif(field.fieldDefinition.hasMapResponse)$
|
|
||||||
this.$field.fieldDefinition.name$ = data.$field.fieldDefinition.name$;
|
|
||||||
$elseif(field.fieldDefinition.hasDateResponse)$
|
|
||||||
this.$field.fieldDefinition.name$ = new Date(Date.parse(data.$field.fieldDefinition.name$));
|
|
||||||
$else$
|
|
||||||
$if(field.fieldDefinition.hasPrimitiveType)$
|
|
||||||
this.$field.fieldDefinition.name$ = data.$field.fieldDefinition.name$;
|
|
||||||
$else$
|
|
||||||
this.$field.fieldDefinition.name$ = new $field.fieldDefinition.returnType$(); this.$field.fieldDefinition.name$.parse(data.$field.fieldDefinition.name$);
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
}$
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var $className$Object = new function() {
|
|
||||||
this.parseArray = function(arrayData) {
|
|
||||||
var responseArray = new Array();
|
|
||||||
|
|
||||||
if(arrayData != null && arrayData.length > 0) {
|
|
||||||
for(var i = 0; i < arrayData.length; i++) {
|
|
||||||
var o = new $className$();
|
|
||||||
o.parse(arrayData[i]);
|
|
||||||
responseArray.push(o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return responseArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
|||||||
/**
|
|
||||||
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
|
|
||||||
*/
|
|
||||||
var $resource$ = new function() {
|
|
||||||
|
|
||||||
$methods:{ method |
|
|
||||||
this.event_$method.name$ = "$resource$.$method.name$";$\r$}$
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Constructor for the $resource$ 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 $resource$(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) {
|
|
||||||
// super(apiCredentials, eventDispatcher);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
$methods:{ method |
|
|
||||||
/**
|
|
||||||
* $method.description$
|
|
||||||
$method.arguments:{ argument |
|
|
||||||
* @param $argument.name$ $argument.description$
|
|
||||||
$if(argument.allowedValues)$
|
|
||||||
* Allowed values are - $argument.allowedValues$
|
|
||||||
$endif$}$
|
|
||||||
*
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
|
|
||||||
* $if(method.hasArguments)$ $length(method.argumentNames)$ $endif$
|
|
||||||
*/
|
|
||||||
|
|
||||||
$if(method.hasArguments)$
|
|
||||||
this.$method.name$ = function($method.argumentNames; separator=", "$, callback)
|
|
||||||
$else$
|
|
||||||
this.$method.name$ = function(callback)
|
|
||||||
$endif$ {
|
|
||||||
|
|
||||||
$if(method.authToken)$
|
|
||||||
if(authToken == null || authToken.length == 0) {
|
|
||||||
throw new Error(ApiErrorCodes.AUTH_TOKEN_NOT_VALID);
|
|
||||||
}$endif$
|
|
||||||
var requestId = ApiInvoker.guid();
|
|
||||||
//parse inputs
|
|
||||||
var resourcePath = "$method.resourcePath$";
|
|
||||||
resourcePath = resourcePath.replace("{format}","json");
|
|
||||||
var method = "$method.methodType$";
|
|
||||||
var queryParams = new Object();
|
|
||||||
$if(!method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if( $argument.name$ != null) {
|
|
||||||
queryParams["$argument.name$"] = encodeURIComponent(ApiInvoker.toPathValue($argument.name$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if( $argument.name$ != null) {
|
|
||||||
resourcePath = resourcePath.replace("{$argument.name$}", encodeURIComponent($argument.name$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
$if(method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
|
|
||||||
queryParams["$argument.name$"] = encodeURIComponent($argument.methodNameFromModelClass$);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
|
|
||||||
resourcePath = resourcePath.replace("{$argument.name$}", encodeURIComponent($argument.methodNameFromModelClass$));
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
//make the API Call
|
|
||||||
var eventName = "$resource$.$method.name$";
|
|
||||||
var returnType = null;
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
returnType = $method.returnClassName$;
|
|
||||||
$endif$
|
|
||||||
var ajaxRequest = null;
|
|
||||||
$if(method.postObject)$
|
|
||||||
$if(method.authToken)$
|
|
||||||
ajaxRequest = ApiInvoker.invokeAPI(authToken, resourcePath, method, queryParams, postData, eventName, requestId, returnType, callback);
|
|
||||||
$endif$
|
|
||||||
$if(!method.authToken)$
|
|
||||||
ajaxRequest = ApiInvoker.invokeAPI(null, resourcePath, method, queryParams, postData, eventName, requestId, returnType, callback);
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
$if(!method.postObject)$
|
|
||||||
$if(method.authToken)$
|
|
||||||
ajaxRequest = ApiInvoker.invokeAPI(authToken, resourcePath, method, queryParams, null, eventName, requestId, returnType, callback);
|
|
||||||
$endif$
|
|
||||||
$if(!method.authToken)$
|
|
||||||
ajaxRequest = ApiInvoker.invokeAPI(null, resourcePath, method, queryParams, null, eventName, requestId, returnType, callback);
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
return {"requestId":requestId, "ajaxRequest":ajaxRequest};
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
/**
|
|
||||||
* Maintains the compatible server version against which the drive is written
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
var VersionChecker = new function() {
|
|
||||||
this.compatibleVersion = "$apiVersion$";
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
|||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
|
|
||||||
* @author deepak
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function $className$() {
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
/**
|
|
||||||
* $field.description$
|
|
||||||
* $if(field.required)$@Required$endif$
|
|
||||||
* $if(field.allowableValues)$[AllowableValues(value="$field.allowedValuesString$"]$endif$
|
|
||||||
*/
|
|
||||||
this.$field.fieldDefinition.name$ $field.fieldDefinition.initialization$;}$
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
/**
|
|
||||||
* Returns the list being wrapped by this wrapper class. There will be a single list item attribute in this class.
|
|
||||||
*/
|
|
||||||
$if(field.fieldDefinition.collectionItemType)$
|
|
||||||
this.getList = function() {
|
|
||||||
return this.$field.fieldDefinition.name$;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.parse = function(data) {
|
|
||||||
if(data) {
|
|
||||||
this.$field.fieldDefinition.name$ = $field.fieldDefinition.collectionItemType$Object.parseArray(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$endif$}$
|
|
||||||
}
|
|
@ -1,196 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* APIClient.php
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Autoload the model definition files */
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param string $className the class to attempt to load
|
|
||||||
*/
|
|
||||||
function __autoload($className) {
|
|
||||||
$currentDir = substr(__FILE__, 0, strrpos(__FILE__, '/'));
|
|
||||||
if (file_exists($currentDir . '/' . $className . '.php')) {
|
|
||||||
include $currentDir . '/' . $className . '.php';
|
|
||||||
} elseif (file_exists($currentDir . '/../model/' . $className . '.php')) {
|
|
||||||
include $currentDir . '/../model/' . $className . '.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class APIClient {
|
|
||||||
|
|
||||||
public static $POST = "POST";
|
|
||||||
public static $GET = "GET";
|
|
||||||
public static $PUT = "PUT";
|
|
||||||
public static $DELETE = "DELETE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $apiKey your API key
|
|
||||||
* @param string $apiServer the address of the API server
|
|
||||||
*/
|
|
||||||
function __construct($apiKey, $apiServer) {
|
|
||||||
$this->apiKey = $apiKey;
|
|
||||||
$this->apiServer = $apiServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $resourcePath path to method endpoint
|
|
||||||
* @param string $method method to call
|
|
||||||
* @param array $queryParams parameters to be place in query URL
|
|
||||||
* @param array $postData parameters to be placed in POST body
|
|
||||||
* @param array $headerParams parameters to be place in request header
|
|
||||||
* @return unknown
|
|
||||||
*/
|
|
||||||
public function callAPI($resourcePath, $method, $queryParams, $postData,
|
|
||||||
$headerParams) {
|
|
||||||
|
|
||||||
$headers = array();
|
|
||||||
$headers[] = "Content-type: application/json";
|
|
||||||
|
|
||||||
# Allow API key from $headerParams to override default
|
|
||||||
$added_api_key = False;
|
|
||||||
if ($headerParams != null) {
|
|
||||||
foreach ($headerParams as $key => $val) {
|
|
||||||
$headers[] = "$key: $val";
|
|
||||||
if ($key == 'api_key') {
|
|
||||||
$added_api_key = True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (! $added_api_key) {
|
|
||||||
$headers[] = "api_key: " . $this->apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_object($postData) or is_array($postData)) {
|
|
||||||
$postData = json_encode($postData);
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = $this->apiServer . $resourcePath;
|
|
||||||
|
|
||||||
$curl = curl_init();
|
|
||||||
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
|
|
||||||
// return the result on success, rather than just TRUE
|
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
|
||||||
|
|
||||||
if ($method == self::$GET) {
|
|
||||||
if (! empty($queryParams)) {
|
|
||||||
$url = ($url . '?' . http_build_query($queryParams));
|
|
||||||
}
|
|
||||||
} else if ($method == self::$POST) {
|
|
||||||
curl_setopt($curl, CURLOPT_POST, true);
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
|
||||||
} else if ($method == self::$PUT) {
|
|
||||||
$json_data = json_encode($postData);
|
|
||||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
|
||||||
} else if ($method == self::$DELETE) {
|
|
||||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
|
||||||
} else {
|
|
||||||
throw new Exception('Method ' . $method . ' is not recognized.');
|
|
||||||
}
|
|
||||||
|
|
||||||
curl_setopt($curl, CURLOPT_URL, $url);
|
|
||||||
|
|
||||||
// Make the request
|
|
||||||
$response = curl_exec($curl);
|
|
||||||
$response_info = curl_getinfo($curl);
|
|
||||||
|
|
||||||
// Handle the response
|
|
||||||
if ($response_info['http_code'] == 0) {
|
|
||||||
throw new Exception("TIMEOUT: api call to " . $url .
|
|
||||||
" took more than 5s to return" );
|
|
||||||
} else if ($response_info['http_code'] == 200) {
|
|
||||||
$data = json_decode($response);
|
|
||||||
} else if ($response_info['http_code'] == 401) {
|
|
||||||
throw new Exception("Unauthorized API request to " . $url .
|
|
||||||
": ".json_decode($response)->message );
|
|
||||||
} else if ($response_info['http_code'] == 404) {
|
|
||||||
$data = null;
|
|
||||||
} else {
|
|
||||||
throw new Exception("Can't connect to the api: " . $url .
|
|
||||||
" response code: " .
|
|
||||||
$response_info['http_code']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Take value and turn it into a string suitable for inclusion in
|
|
||||||
* the path or the header
|
|
||||||
* @param object $object an object to be serialized to a string
|
|
||||||
* @return string the serialized object
|
|
||||||
*/
|
|
||||||
public static function toPathValue($object) {
|
|
||||||
if (is_array($object)) {
|
|
||||||
return implode(',', $object);
|
|
||||||
} else {
|
|
||||||
return $object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Derialize a JSON string into an object
|
|
||||||
*
|
|
||||||
* @param object $object object or primitive to be deserialized
|
|
||||||
* @param string $class class name is passed as a string
|
|
||||||
* @return object an instance of $class
|
|
||||||
*/
|
|
||||||
public static function deserialize($object, $class) {
|
|
||||||
|
|
||||||
if (in_array($class, array('string', 'int', 'float', 'bool'))) {
|
|
||||||
settype($object, $class);
|
|
||||||
return $object;
|
|
||||||
} else {
|
|
||||||
$instance = new $class(); // this instantiates class named $class
|
|
||||||
$classVars = get_class_vars($class);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($object as $property => $value) {
|
|
||||||
|
|
||||||
// Need to handle possible pluralization differences
|
|
||||||
$true_property = $property;
|
|
||||||
|
|
||||||
if (! property_exists($class, $true_property)) {
|
|
||||||
if (substr($property, -1) == 's') {
|
|
||||||
$true_property = substr($property, 0, -1);
|
|
||||||
if (! property_exists($class, $true_property)) {
|
|
||||||
trigger_error("class $class has no property $property"
|
|
||||||
. " or $true_property", E_USER_WARNING);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
trigger_error("class $class has no property $property",
|
|
||||||
E_USER_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$type = $classVars['swaggerTypes'][$true_property];
|
|
||||||
if (in_array($type, array('string', 'int', 'float', 'bool'))) {
|
|
||||||
settype($value, $type);
|
|
||||||
$instance->{$true_property} = $value;
|
|
||||||
} elseif (preg_match("/array<(.*)>/", $type, $matches)) {
|
|
||||||
$sub_class = $matches[1];
|
|
||||||
$instance->{$true_property} = array();
|
|
||||||
foreach ($value as $sub_property => $sub_value) {
|
|
||||||
$instance->{$true_property}[] = self::deserialize($sub_value,
|
|
||||||
$sub_class);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$instance->{$true_property} = self::deserialize($value, $type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $enum.description$
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
abstract class $className$ {
|
|
||||||
|
|
||||||
$values: { value | public static \$$value.name$ = $value.value$};separator=";\n"$;
|
|
||||||
|
|
||||||
};
|
|
||||||
?>
|
|
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class $className$ {
|
|
||||||
|
|
||||||
static \$swaggerTypes = array(
|
|
||||||
$fields: { field | '$field.fieldDefinition.name$' => '$field.fieldDefinition.returnType$'};separator=",\n"$
|
|
||||||
);
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $field.description$
|
|
||||||
*/
|
|
||||||
public \$$field.fieldDefinition.name$$field.fieldDefinition.initialization$;// $field.fieldDefinition.returnType$
|
|
||||||
|
|
||||||
}$
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,120 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class $resource$ {
|
|
||||||
|
|
||||||
function __construct(\$apiClient) {
|
|
||||||
\$this->apiClient = \$apiClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
$methods:{ method |
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $method.title$
|
|
||||||
*
|
|
||||||
$if(method.description)$
|
|
||||||
* $method.description$
|
|
||||||
* $endif$
|
|
||||||
* $method.arguments:{ argument |@param $argument.name$ $argument.description$
|
|
||||||
* $if(argument.allowedValues)$
|
|
||||||
* Allowed values are - $argument.allowedValues$ $endif$ }$
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
|
|
||||||
* @throws APIException $method.exceptionDescription$
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function $method.name$($method.arguments: { argument | \$$argument.name$}; separator=", "$) {
|
|
||||||
|
|
||||||
//parse inputs
|
|
||||||
\$resourcePath = "$method.resourcePath$";
|
|
||||||
\$resourcePath = str_replace("{format}", "json", \$resourcePath);
|
|
||||||
\$method = "$method.methodType$";
|
|
||||||
\$queryParams = array();
|
|
||||||
\$headerParams = array();
|
|
||||||
|
|
||||||
$if(!method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if(\$$argument.name$ != null) {
|
|
||||||
\$queryParams['$argument.name$'] = \$this->apiClient->toPathValue(\$$argument.name$);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if(\$$argument.name$ != null) {
|
|
||||||
\$resourcePath = str_replace("{$argument.name$}", \$$argument.name$, \$resourcePath);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if(\$$argument.name$ != null) {
|
|
||||||
\$headerParams['$argument.name$'] = \$this->apiClient->toPathValue(\$$argument.name$);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
$if(method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if(\$$argument.inputModelClassArgument$ != null && \$$argument.inputModelClassArgument$->$argument.name$ != null) {
|
|
||||||
\$queryParams["$argument.name$"] = \$this->apiClient->toPathValue(\$$argument.inputModelClassArgument$->$argument.name$);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if(\$$argument.inputModelClassArgument$ != null && \$$argument.inputModelClassArgument$->$argument.name$ != null) {
|
|
||||||
\$resourcePath = str_replace("{$argument.name$}", \$$argument.inputModelClassArgument$->$argument.name$, \$resourcePath);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if(\$$argument.inputModelClassArgument$ != null && \$$argument.inputModelClassArgument$->$argument.name$ != null) {
|
|
||||||
\$headerParams['$argument.name$'] = \$this->apiClient->toPathValue(\$$argument.inputModelClassArgument$->$argument.name$);
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
//make the API Call
|
|
||||||
$if(method.postObject)$
|
|
||||||
\$response = \$this->apiClient->callAPI(\$resourcePath, \$method, \$queryParams, \$postData, \$headerParams);
|
|
||||||
$endif$
|
|
||||||
$if(!method.postObject)$
|
|
||||||
\$response = \$this->apiClient->callAPI(\$resourcePath, \$method, \$queryParams, null, \$headerParams);
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
if(! \$response){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$if(!method.returnValueList)$
|
|
||||||
//create output objects if the response has more than one object
|
|
||||||
\$responseObject = \$this->apiClient->deserialize(\$response, '$method.returnClassName$');
|
|
||||||
return \$responseObject;
|
|
||||||
|
|
||||||
$endif$
|
|
||||||
$if(method.returnValueList)$
|
|
||||||
\$responseObjects = array();
|
|
||||||
foreach (\$response as \$object) {
|
|
||||||
\$responseObjects[] = \$this->apiClient->deserialize(\$object, '$method.returnClassName$');
|
|
||||||
}
|
|
||||||
return \$responseObjects;
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
}
|
|
||||||
|
|
||||||
}$
|
|
||||||
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Maintains the compatible server version against which the drive is written
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
class VersionChecker {
|
|
||||||
|
|
||||||
public static compatibleVersion = "$apiVersion$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the version against which the library code was written
|
|
||||||
*/
|
|
||||||
public function getCompatibleVersion() {
|
|
||||||
return self::\$compatibleVersion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,131 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Wordnik.com's Swagger generic API client. This client handles the client-
|
|
||||||
server communication, and is invariant across implementations. Specifics of
|
|
||||||
the methods and models for each application are generated from the Swagger
|
|
||||||
templates."""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import urllib
|
|
||||||
import urllib2
|
|
||||||
import httplib
|
|
||||||
import json
|
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../')
|
|
||||||
import model
|
|
||||||
|
|
||||||
|
|
||||||
class APIClient:
|
|
||||||
"""Generic API client for Swagger client library builds"""
|
|
||||||
|
|
||||||
def __init__(self, apiKey=None, apiServer=None):
|
|
||||||
if apiKey == None:
|
|
||||||
raise Exception('You must pass an apiKey when instantiating the '
|
|
||||||
'APIClient')
|
|
||||||
self.apiKey = apiKey
|
|
||||||
self.apiServer = apiServer
|
|
||||||
|
|
||||||
def callAPI(self, resourcePath, method, queryParams, postData,
|
|
||||||
headerParams=None):
|
|
||||||
|
|
||||||
url = self.apiServer + resourcePath
|
|
||||||
headers = {}
|
|
||||||
if headerParams:
|
|
||||||
for param, value in headerParams.iteritems():
|
|
||||||
headers[param] = value
|
|
||||||
|
|
||||||
headers['Content-type'] = 'application/json'
|
|
||||||
headers['api_key'] = self.apiKey
|
|
||||||
|
|
||||||
data = None
|
|
||||||
if method == 'GET':
|
|
||||||
if queryParams:
|
|
||||||
# Need to remove None values, these should not be sent
|
|
||||||
sentQueryParams = {}
|
|
||||||
for param, value in queryParams.iteritems():
|
|
||||||
if value != None:
|
|
||||||
sentQueryParams[param] = value
|
|
||||||
url = url + '?' + urllib.urlencode(sentQueryParams)
|
|
||||||
request = urllib2.Request(url=url, headers=headers)
|
|
||||||
elif method in ['POST', 'PUT', 'DELETE']:
|
|
||||||
data = postData
|
|
||||||
if data:
|
|
||||||
if type(postData) not in [str, int, float, bool]:
|
|
||||||
data = json.dumps(postData.__dict__)
|
|
||||||
request = urllib2.Request(url=url, headers=headers, data=data)
|
|
||||||
if method in ['PUT', 'DELETE']:
|
|
||||||
# Monkey patch alert! Urllib2 doesn't really do PUT / DELETE
|
|
||||||
request.get_method = lambda: method
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise Exception('Method ' + method + ' is not recognized.')
|
|
||||||
|
|
||||||
# Make the request
|
|
||||||
response = urllib2.urlopen(request).read()
|
|
||||||
|
|
||||||
try:
|
|
||||||
data = json.loads(response)
|
|
||||||
except ValueError: # PUT requests don't return anything
|
|
||||||
data = None
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
def toPathValue(self, obj):
|
|
||||||
"""Serialize a list to a CSV string, if necessary.
|
|
||||||
Args:
|
|
||||||
obj -- data object to be serialized
|
|
||||||
Returns:
|
|
||||||
string -- json serialization of object
|
|
||||||
"""
|
|
||||||
if type(obj) == list:
|
|
||||||
return ','.join(obj)
|
|
||||||
else:
|
|
||||||
return obj
|
|
||||||
|
|
||||||
def deserialize(self, obj, objClass):
|
|
||||||
"""Derialize a JSON string into an object.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
obj -- string or object to be deserialized
|
|
||||||
objClass -- class literal for deserialzied object, or string
|
|
||||||
of class name
|
|
||||||
Returns:
|
|
||||||
object -- deserialized object"""
|
|
||||||
|
|
||||||
# Have to accept objClass as string or actual type. Type could be a
|
|
||||||
# native Python type, or one of the model classes.
|
|
||||||
if type(objClass) == str:
|
|
||||||
try:
|
|
||||||
objClass = eval(objClass)
|
|
||||||
except NameError: # not a native type, must be model class
|
|
||||||
objClass = eval('model.' + objClass + '.' + objClass)
|
|
||||||
|
|
||||||
if objClass in [str, int, float, bool]:
|
|
||||||
return objClass(obj)
|
|
||||||
|
|
||||||
instance = objClass()
|
|
||||||
|
|
||||||
for attr, attrType in instance.swaggerTypes.iteritems():
|
|
||||||
if attr in obj:
|
|
||||||
value = obj[attr]
|
|
||||||
if attrType in ['str', 'int', 'float', 'bool']:
|
|
||||||
attrType = eval(attrType)
|
|
||||||
try:
|
|
||||||
value = attrType(value)
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
value = unicode(value)
|
|
||||||
setattr(instance, attr, value)
|
|
||||||
elif 'list<' in attrType:
|
|
||||||
match = re.match('list<(.*)>', attrType)
|
|
||||||
subClass = match.group(1)
|
|
||||||
subValues = []
|
|
||||||
|
|
||||||
for subValue in value:
|
|
||||||
subValues.append(self.deserialize(subValue, subClass))
|
|
||||||
setattr(instance, attr, subValues)
|
|
||||||
else:
|
|
||||||
setattr(instance, attr, self.deserialize(value,
|
|
||||||
objClass))
|
|
||||||
|
|
||||||
return instance
|
|
@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Load all of the modules in the models directory."""
|
|
||||||
import os
|
|
||||||
|
|
||||||
for module in os.listdir(os.path.dirname(__file__)):
|
|
||||||
if module != '__init__.py' and module[-3:] == '.py':
|
|
||||||
__import__(module[:-3], locals(), globals())
|
|
@ -1,25 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2011 Wordnik, Inc.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
"""
|
|
||||||
|
|
||||||
class $className$:
|
|
||||||
"""
|
|
||||||
$enum.description$
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
def __init__():
|
|
||||||
$values: { value | self.$value.name$ = $value.value$};separator=";\n"$
|
|
@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2011 Wordnik, Inc.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
"""
|
|
||||||
|
|
||||||
class $className$:
|
|
||||||
"""
|
|
||||||
$model.description$
|
|
||||||
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
$fields: { field |'$field.fieldDefinition.name$': '$field.fieldDefinition.returnType$'};separator=",\n"$
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
|
|
||||||
# $field.description$
|
|
||||||
self.$field.fieldDefinition.name$ = None # $field.fieldDefinition.returnType$
|
|
||||||
|
|
||||||
}$
|
|
@ -1,118 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
$resource$.py
|
|
||||||
Copyright 2011 Wordnik, Inc.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../')
|
|
||||||
import model
|
|
||||||
|
|
||||||
class $resource$(object):
|
|
||||||
|
|
||||||
def __init__(self, apiClient):
|
|
||||||
self.apiClient = apiClient
|
|
||||||
|
|
||||||
$methods:{ method |
|
|
||||||
def $method.name$(self, $method.arguments: { argument | $if(argument.required)$$argument.name$, $endif$}$$method.arguments: { argument | $if(! argument.required)$$argument.name$=None, $endif$}$):
|
|
||||||
"""$method.title$
|
|
||||||
$if(method.description)$
|
|
||||||
$method.description$
|
|
||||||
$endif$
|
|
||||||
Args:
|
|
||||||
$method.arguments:{ argument |$argument.name$ -- $argument.description$
|
|
||||||
$if(argument.allowedValues)$
|
|
||||||
Allowed values are - $argument.allowedValues$
|
|
||||||
$endif$}$
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
Return:
|
|
||||||
$method.returnValue$ -- an instance of $method.returnClassName$
|
|
||||||
$endif$"""
|
|
||||||
|
|
||||||
# Parse inputs
|
|
||||||
resourcePath = '$method.resourcePath$'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = '$method.methodType$'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
$if(!method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
queryParams['$argument.name$'] = self.apiClient.toPathValue($argument.name$)
|
|
||||||
}$
|
|
||||||
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if $argument.name$ != None:
|
|
||||||
resourcePath = resourcePath.replace('{$argument.name$}', $argument.name$)
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if $argument.name$ != None:
|
|
||||||
headerParams['$argument.name$'] = self.apiClient.toPathValue($argument.name$)
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
$if(method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if $argument.inputModelClassArgument$ != None and $argument.inputModelClassArgument$.$argument.name$ != None:
|
|
||||||
queryParams['$argument.name$'] = self.apiClient.toPathValue($argument.inputModelClassArgument$.$argument.name$)
|
|
||||||
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if $argument.inputModelClassArgument$ != None and $argument.inputModelClassArgument$.$argument.name$ != None:
|
|
||||||
resourcePath = resourcePath.replace('{$argument.name$}', $argument.inputModelClassArgument$.$argument.name$)
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if $argument.inputModelClassArgument$ != None and $argument.inputModelClassArgument$.$argument.name$ != None:
|
|
||||||
headerParams['$argument.name$'] = self.apiClient.toPathValue($argument.inputModelClassArgument$.$argument.name$)
|
|
||||||
}$
|
|
||||||
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
# Make the API Call
|
|
||||||
$if(method.postObject)$
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
$if(!method.postObject)$
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
None, headerParams)
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
$if(!method.returnValueList)$
|
|
||||||
# Create output objects if the response has more than one object
|
|
||||||
responseObject = self.apiClient.deserialize(response,
|
|
||||||
model.$method.returnClassName$.$method.returnClassName$)
|
|
||||||
return responseObject
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
$if(method.returnValueList)$
|
|
||||||
responseObjects = []
|
|
||||||
for responseObject in response:
|
|
||||||
responseObjects.append(self.apiClient.deserialize(responseObject,
|
|
||||||
model.$method.returnClassName$.$method.returnClassName$))
|
|
||||||
return responseObjects
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
}$
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
"""
|
|
||||||
Copyright 2011 Wordnik, Inc.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class VersionChecker(object):
|
|
||||||
"""
|
|
||||||
Maintains the compatible server version against which the drive is writtena
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
_compatible_version = "$apiVersion$"
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def getCompatibleVersion(cls):
|
|
||||||
"""
|
|
||||||
Gets the version against which the library code was written
|
|
||||||
"""
|
|
||||||
return cls._compatible_version
|
|
@ -1,128 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<project name="swagger-sample-scala-lib" xmlns:ivy="antlib:org.apache.ivy.ant" default="build.all" basedir=".">
|
|
||||||
<property environment="env" />
|
|
||||||
<property name="version.identifier" value="1.0" />
|
|
||||||
<property name="artifact.ext" value="jar" />
|
|
||||||
<property name="organization" value="wordnik" />
|
|
||||||
<property name="module" value="${ant.project.name}" />
|
|
||||||
|
|
||||||
<!-- default dirs for the build -->
|
|
||||||
<mkdir dir="lib"/>
|
|
||||||
<mkdir dir="lib/ext"/>
|
|
||||||
|
|
||||||
<condition property="scala.home" value="${env.SCALA_HOME}">
|
|
||||||
<isset property="env.SCALA_HOME" />
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<path id="scala.classpath">
|
|
||||||
<fileset dir="${scala.home}/lib">
|
|
||||||
<include name="scala**.jar" />
|
|
||||||
</fileset>
|
|
||||||
</path>
|
|
||||||
|
|
||||||
<ivy:settings file="ivysettings.xml" />
|
|
||||||
|
|
||||||
<taskdef resource="scala/tools/ant/antlib.xml">
|
|
||||||
<classpath>
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="scala**.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="${scala.home}/lib">
|
|
||||||
<include name="scala**.jar" />
|
|
||||||
</fileset>
|
|
||||||
</classpath>
|
|
||||||
</taskdef>
|
|
||||||
|
|
||||||
<!-- this is the output module -->
|
|
||||||
<property name="module" value="${ant.project.name}" />
|
|
||||||
|
|
||||||
<target name="build.all" depends="clean, resolve, fastcompile" description="builds the module (default target)" />
|
|
||||||
|
|
||||||
<target name="clean" description="cleans the project folder">
|
|
||||||
<mkdir dir="build" />
|
|
||||||
<echo message="deleting build files" />
|
|
||||||
<delete quiet="true">
|
|
||||||
<fileset dir="build">
|
|
||||||
<include name="*.jar" />
|
|
||||||
<include name="*.xml" />
|
|
||||||
</fileset>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete dir="build/main" quiet="true" />
|
|
||||||
|
|
||||||
<delete dir="dist" quiet="true" />
|
|
||||||
|
|
||||||
<!-- libraries handled by ivy -->
|
|
||||||
<echo message="deleting libs handled by ivy" />
|
|
||||||
<delete>
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="*.jar" />
|
|
||||||
<include name="*.zip" />
|
|
||||||
</fileset>
|
|
||||||
</delete>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- copies ONLY the swagger-sample jar to dist-->
|
|
||||||
<target name="fastdist" depends="fastcompile">
|
|
||||||
<copy todir="dist/lib">
|
|
||||||
<fileset dir="build">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
</copy>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- copies all dependencies into the lib folder -->
|
|
||||||
<target name="resolve" description="retreive dependencies with ivy">
|
|
||||||
<ivy:retrieve pattern="${basedir}/lib/[artifact]-[revision].[ext]" conf="build" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="fastcompile" description="builds the module without artifact resolution or cleaning">
|
|
||||||
<delete quiet="true" file="build/${organization}-${artifact}-*.${artifact.ext}" />
|
|
||||||
<mkdir dir="build" />
|
|
||||||
<mkdir dir="build/main" />
|
|
||||||
<mkdir dir="build/main/java" />
|
|
||||||
|
|
||||||
<javac srcdir="src/main/java" debug="true" destdir="build/main/java">
|
|
||||||
<classpath>
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="lib/ext">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<pathelement location="build/main/java" />
|
|
||||||
</classpath>
|
|
||||||
</javac>
|
|
||||||
|
|
||||||
|
|
||||||
<scalac srcdir="src/main/java:src/main/scala" destdir="build/main/java">
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="build/main/java" />
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="lib/ext">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="${scala.home}/lib"/>
|
|
||||||
</classpath>
|
|
||||||
<include name="**/*.scala" />
|
|
||||||
<include name="**/*.java" />
|
|
||||||
</scalac>
|
|
||||||
|
|
||||||
<jar jarfile="build/${module}-${version.identifier}.${artifact.ext}">
|
|
||||||
<fileset dir="build/main/java" />
|
|
||||||
</jar>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- cleans up the dist -->
|
|
||||||
<target name="dist.clean" description="cleans the distribution folder">
|
|
||||||
<delete quiet="true" dir="dist" />
|
|
||||||
<delete quiet="true" file="dist.zip" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="dependency.tree" description="builds a graphml dependency diagram for viewing with yEd">
|
|
||||||
<ivy:report conf="build" graph="true" todir="." outputpattern="[artifact]-[revision].[ext]" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,31 +0,0 @@
|
|||||||
<ivy-module version="2.0">
|
|
||||||
<info organisation="wordnik" module="sample-java-lib"/>
|
|
||||||
<configurations>
|
|
||||||
<conf name="build" description="build wordnik-java"/>
|
|
||||||
<conf name="test" visibility="public"/>
|
|
||||||
<conf name="source" visibility="public"/>
|
|
||||||
<conf name="pom" visibility="public"/>
|
|
||||||
</configurations>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- jersey dependencies -->
|
|
||||||
<dependency org="junit" name="junit" rev="4.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-json" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-client" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-server" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-core" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="asm" name="asm-parent" rev="3.1" conf="build->default"/>
|
|
||||||
<dependency org="commons-beanutils" name="commons-beanutils" rev="1.8.0" conf="build->default"/>
|
|
||||||
<dependency org="org.antlr" name="stringtemplate" rev="3.2" conf="build->default"/>
|
|
||||||
<!-- jackson jars -->
|
|
||||||
<dependency org="org.codehaus.jackson" name="jackson-jaxrs" rev="1.7.1" conf="build->default"/>
|
|
||||||
<dependency org="org.codehaus.jackson" name="jackson-xc" rev="1.7.1" conf="build->default"/>
|
|
||||||
<dependency org="org.codehaus.jackson" name="jackson-mapper-asl" rev="1.7.1" conf="build->default"/>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency org="net.sourceforge.cobertura" name="cobertura" rev="1.9.2" conf="test->default">
|
|
||||||
<exclude org="asm" name="asm-tree"/>
|
|
||||||
<exclude org="asm" name="asm"/>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</ivy-module>
|
|
@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ivysettings>
|
|
||||||
<settings defaultResolver="chained" />
|
|
||||||
<property name="ivy.checksums" value=""/>
|
|
||||||
<property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local"
|
|
||||||
override="false" />
|
|
||||||
<property name="ivy.local.default.ivy.pattern"
|
|
||||||
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
|
|
||||||
override="false" />
|
|
||||||
<property name="ivy.local.default.artifact.pattern"
|
|
||||||
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
|
|
||||||
override="false" />
|
|
||||||
<resolvers>
|
|
||||||
<chain name="chained" returnFirst="true">
|
|
||||||
<filesystem name="local">
|
|
||||||
<ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}" />
|
|
||||||
<artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
|
|
||||||
</filesystem>
|
|
||||||
<ibiblio name="ibiblio" m2compatible="true" />
|
|
||||||
<ibiblio name="javanet" root="http://download.java.net/maven/2/" m2compatible="true" />
|
|
||||||
</chain>
|
|
||||||
</resolvers>
|
|
||||||
</ivysettings>
|
|
@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"apiUrl":"http://localhost:8002/api/",
|
|
||||||
|
|
||||||
"apiKey":"special-key",
|
|
||||||
|
|
||||||
"defaultServiceBaseClass":"Object",
|
|
||||||
|
|
||||||
"defaultModelBaseClass":"Object",
|
|
||||||
|
|
||||||
"serviceBaseClasses":{},
|
|
||||||
|
|
||||||
"defaultModelImports":[],
|
|
||||||
|
|
||||||
"defaultServiceImports":[],
|
|
||||||
|
|
||||||
"modelPackageName":"com.wordnik.swagger.sample.sdk.java.model",
|
|
||||||
|
|
||||||
"apiPackageName":"com.wordnik.swagger.sample.sdk.java.api",
|
|
||||||
|
|
||||||
"ignoreMethods":[],
|
|
||||||
|
|
||||||
"ignoreModels":[],
|
|
||||||
|
|
||||||
"outputDirectory":"../swagger-sample-app/sdk-libs/src/main/java/com/wordnik/swagger/sample/sdk/java",
|
|
||||||
|
|
||||||
"libraryHome":"../swagger-sample-app/sdk-libs"
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"userList":[
|
|
||||||
{
|
|
||||||
"username":"testuser1",
|
|
||||||
"password":"password1",
|
|
||||||
"email":"test1@dummy.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username":"testuser2",
|
|
||||||
"password":"password2",
|
|
||||||
"email":"test2@dummy.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"petList":[
|
|
||||||
{
|
|
||||||
"id":101,
|
|
||||||
"name":"pet1",
|
|
||||||
"photoUrls":["url1","url2"],
|
|
||||||
"tags":[
|
|
||||||
{
|
|
||||||
"id":1,
|
|
||||||
"name":"tag1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":2,
|
|
||||||
"name":"tag2"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"status":"available",
|
|
||||||
"category":{"id":1,"name":"cat1"}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"orderList":[
|
|
||||||
{
|
|
||||||
"id":101,
|
|
||||||
"petId":1,
|
|
||||||
"quantity":1,
|
|
||||||
"status":"placed",
|
|
||||||
"shipDate":13456789
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,265 +0,0 @@
|
|||||||
{
|
|
||||||
"resources" : [
|
|
||||||
{
|
|
||||||
"id" : 1,
|
|
||||||
"name" : "Find Per by Id",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/{petId}",
|
|
||||||
"suggestedMethodName" : "getPetById"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 2,
|
|
||||||
"name" : "Find pets by status",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/findByStatus",
|
|
||||||
"suggestedMethodName" : "findPetsByStatus"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 3,
|
|
||||||
"name" : "Find pets by tags",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/findByTags",
|
|
||||||
"suggestedMethodName" : "findPetsByTags"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 4,
|
|
||||||
"name" : "Add a pet",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/pet.{format}",
|
|
||||||
"suggestedMethodName" : "addPet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 5,
|
|
||||||
"name" : "Update a pet",
|
|
||||||
"httpMethod" : "PUT",
|
|
||||||
"path" : "/pet.{format}",
|
|
||||||
"suggestedMethodName" : "updatePet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 6,
|
|
||||||
"name" : "Create user",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/user.{format}",
|
|
||||||
"suggestedMethodName" : "createUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 7,
|
|
||||||
"name" : "Update user",
|
|
||||||
"httpMethod" : "PUT",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "updateUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 8,
|
|
||||||
"name" : "Delete user",
|
|
||||||
"httpMethod" : "DELETE",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "deleteUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 9,
|
|
||||||
"name" : "Get user by user name",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "getUserByName"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 10,
|
|
||||||
"name" : "Login",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/login",
|
|
||||||
"suggestedMethodName" : "loginUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 11,
|
|
||||||
"name" : "Logout",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/logout",
|
|
||||||
"suggestedMethodName" : "logoutUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 12,
|
|
||||||
"name" : "Find order by id",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/store.{format}/order/{orderId}",
|
|
||||||
"suggestedMethodName" : "getOrderById"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 13,
|
|
||||||
"name" : "Delete order by id",
|
|
||||||
"httpMethod" : "DELETE",
|
|
||||||
"path" : "/store.{format}/order/{orderId}",
|
|
||||||
"suggestedMethodName" : "deleteOrder"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 14,
|
|
||||||
"name" : "Create order",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/store.{format}/order",
|
|
||||||
"suggestedMethodName" : "placeOrder"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"testSuites" : [
|
|
||||||
{
|
|
||||||
"id" : 1,
|
|
||||||
"name" : "Test User service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Create User",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 6,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.userList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Login User",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 10,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}",
|
|
||||||
"password":"${input.userList[0].password}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find user by name",
|
|
||||||
"id" : 3,
|
|
||||||
"resourceId" : 9,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.3).username}",
|
|
||||||
"condition" : "==",
|
|
||||||
"expectedOutput" : "${input.userList[0].username}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Delete user by name",
|
|
||||||
"id" : 4,
|
|
||||||
"resourceId" : 9,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.4)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 2,
|
|
||||||
"name" : "Test Pet service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Add pet",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 4,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.petList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find pet by id",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 1,
|
|
||||||
"input" : {
|
|
||||||
"petId":"1"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "NULL"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find pet by status",
|
|
||||||
"id" : 3,
|
|
||||||
"resourceId" : 2,
|
|
||||||
"input" : {
|
|
||||||
"status":"available,sold,pending"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.3).size}",
|
|
||||||
"condition" : ">",
|
|
||||||
"expectedOutput" : "0"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 3,
|
|
||||||
"name" : "Test Store service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Find order by id",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 12,
|
|
||||||
"input" : {
|
|
||||||
"orderId":"1"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(3.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "NULL"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Place order",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 14,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.orderList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
# nothing to see yet
|
|
@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package $packageName$
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $enum.description$
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
* @author tony
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
object $className$ {
|
|
||||||
$values: { value | var $value.name$ = $value.value$};separator="\n"$
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
class $className$Model
|
|
||||||
attr_accessor $fields:{ field | :$field.fieldDefinition.name$};separator=", "$
|
|
||||||
$fields:{ field |
|
|
||||||
$if(field.required)$ validate_presence_of :$field.fieldDefinition.name$$endif$
|
|
||||||
}$
|
|
||||||
|
|
||||||
# TODO: move this to base class
|
|
||||||
def initialize(attributes = {})
|
|
||||||
attributes.symbolize_and_underscore_keys!
|
|
||||||
|
|
||||||
# loop over incoming attributes, only assign to valid attr_accessor props
|
|
||||||
$fields:{ field |
|
|
||||||
if(UserModel.respond_to? :$field.fieldDefinition.name$) self.$field.fieldDefinition.name$ = attributes[:$field.fieldDefinition.name$]
|
|
||||||
}$
|
|
||||||
|
|
||||||
# if(UserModel.respond_to? :word) self.word = attributes[:word]
|
|
||||||
# Zap any whitespace and bad encoding
|
|
||||||
# attributes[:name] &&= attributes[:name].strip.squeeze(' ').force_encoding('UTF-8')
|
|
||||||
# super(attributes)
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,47 +0,0 @@
|
|||||||
module $resource$
|
|
||||||
|
|
||||||
$methods:{ method |
|
|
||||||
def $method.name$(opts={})
|
|
||||||
$if(method.pathParameters)$ requiredKeys=[:$method.pathParameters:{ param | $param.name$};separator=", "$]$endif$
|
|
||||||
$if(method.queryParameters)$ queryparamKeys=[:$method.queryParameters:{ param | $param.name$};separator=", "$]$endif$
|
|
||||||
|
|
||||||
$if(method.pathParameters)$
|
|
||||||
#check required options
|
|
||||||
requiredKeys.each do |key|
|
|
||||||
raise "#{key} is required" unless options.has_key?(key)
|
|
||||||
end
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
$if(method.arguments)$$method.arguments:{ param | $if(param.defaultValue)$ :$param.name$="$param.defaultValue$"$endif$}$$endif$
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "$method.resourcePath$".sub('{format}', '.json')
|
|
||||||
|
|
||||||
$if(method.pathParameters)$
|
|
||||||
# sub pathparams
|
|
||||||
$method.pathParameters:{ param |
|
|
||||||
path.sub!('{$param.name$}', URI.encode(options[:$param.name$]))
|
|
||||||
}$$endif$
|
|
||||||
#pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
queryparamKeys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
$if(method.hasResponseValue)$
|
|
||||||
results = Swagger::request.new(:get, path, queryopts, nil)
|
|
||||||
$if(method.returnValueList)$
|
|
||||||
output = results.map {|result| $method.returnValue$.new(result)}
|
|
||||||
$else$
|
|
||||||
output = $method.returnValue$.new(result)
|
|
||||||
$endif$
|
|
||||||
$else$
|
|
||||||
Swagger::request.new(:get, path, queryopts, nil)
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
}$
|
|
@ -1,5 +0,0 @@
|
|||||||
module $resource$
|
|
||||||
def get_compatible_version(*args)
|
|
||||||
'$apiVersion$'
|
|
||||||
end
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<project name="swagger-sample-scala-lib" xmlns:ivy="antlib:org.apache.ivy.ant" default="build.all" basedir=".">
|
|
||||||
<property environment="env" />
|
|
||||||
<property name="version.identifier" value="1.0" />
|
|
||||||
<property name="artifact.ext" value="jar" />
|
|
||||||
<property name="organization" value="wordnik" />
|
|
||||||
<property name="module" value="${ant.project.name}" />
|
|
||||||
|
|
||||||
<!-- default dirs for the build -->
|
|
||||||
<mkdir dir="lib"/>
|
|
||||||
<mkdir dir="lib/ext"/>
|
|
||||||
|
|
||||||
<condition property="scala.home" value="${env.SCALA_HOME}">
|
|
||||||
<isset property="env.SCALA_HOME" />
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<path id="scala.classpath">
|
|
||||||
<fileset dir="${scala.home}/lib">
|
|
||||||
<include name="scala**.jar" />
|
|
||||||
</fileset>
|
|
||||||
</path>
|
|
||||||
|
|
||||||
<ivy:settings file="ivysettings.xml" />
|
|
||||||
|
|
||||||
<taskdef resource="scala/tools/ant/antlib.xml">
|
|
||||||
<classpath>
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="scala**.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="${scala.home}/lib">
|
|
||||||
<include name="scala**.jar" />
|
|
||||||
</fileset>
|
|
||||||
</classpath>
|
|
||||||
</taskdef>
|
|
||||||
|
|
||||||
<!-- this is the output module -->
|
|
||||||
<property name="module" value="${ant.project.name}" />
|
|
||||||
|
|
||||||
<target name="jar" description="creates jar file " depends="build.all">
|
|
||||||
<jar jarfile="build/${release.module}-${release.version}.${artifact.ext}">
|
|
||||||
<fileset dir="build/main/java" />
|
|
||||||
</jar>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="build.all" depends="clean, resolve, fastcompile" description="builds the module (default target)" />
|
|
||||||
|
|
||||||
<target name="clean" description="cleans the project folder">
|
|
||||||
<mkdir dir="build" />
|
|
||||||
<echo message="deleting build files" />
|
|
||||||
<delete quiet="true">
|
|
||||||
<fileset dir="build">
|
|
||||||
<include name="*.jar" />
|
|
||||||
<include name="*.xml" />
|
|
||||||
</fileset>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete dir="build/main" quiet="true" />
|
|
||||||
|
|
||||||
<delete dir="dist" quiet="true" />
|
|
||||||
|
|
||||||
<!-- libraries handled by ivy -->
|
|
||||||
<echo message="deleting libs handled by ivy" />
|
|
||||||
<delete>
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="*.jar" />
|
|
||||||
<include name="*.zip" />
|
|
||||||
</fileset>
|
|
||||||
</delete>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- copies all dependencies into the lib folder -->
|
|
||||||
<target name="resolve" description="retreive dependencies with ivy">
|
|
||||||
<ivy:retrieve pattern="${basedir}/lib/[artifact]-[revision].[ext]" conf="build" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="fastcompile" description="builds the module without artifact resolution or cleaning">
|
|
||||||
<delete quiet="true" file="build/${organization}-${artifact}-*.${artifact.ext}" />
|
|
||||||
<mkdir dir="build" />
|
|
||||||
<mkdir dir="build/main" />
|
|
||||||
<mkdir dir="build/main/java" />
|
|
||||||
|
|
||||||
<javac srcdir="src/main/java" debug="true" destdir="build/main/java">
|
|
||||||
<classpath>
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="lib/ext">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<pathelement location="build/main/java" />
|
|
||||||
</classpath>
|
|
||||||
</javac>
|
|
||||||
|
|
||||||
<scalac srcdir="src/main/java:src/main/scala" destdir="build/main/java">
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="build/main/java" />
|
|
||||||
<fileset dir="lib">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="lib/ext">
|
|
||||||
<include name="*.jar" />
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="${scala.home}/lib"/>
|
|
||||||
</classpath>
|
|
||||||
<include name="**/*.scala" />
|
|
||||||
<include name="**/*.java" />
|
|
||||||
</scalac>
|
|
||||||
|
|
||||||
<jar jarfile="build/${module}-${version.identifier}.${artifact.ext}">
|
|
||||||
<fileset dir="build/main/java" />
|
|
||||||
</jar>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="dependency.tree" description="builds a graphml dependency diagram for viewing with yEd">
|
|
||||||
<ivy:report conf="build" graph="true" todir="." outputpattern="[artifact]-[revision].[ext]" />
|
|
||||||
</target>
|
|
||||||
</project>
|
|
@ -1,31 +0,0 @@
|
|||||||
<ivy-module version="2.0">
|
|
||||||
<info organisation="wordnik" module="sample-java-lib"/>
|
|
||||||
<configurations>
|
|
||||||
<conf name="build" description="build wordnik-java"/>
|
|
||||||
<conf name="test" visibility="public"/>
|
|
||||||
<conf name="source" visibility="public"/>
|
|
||||||
<conf name="pom" visibility="public"/>
|
|
||||||
</configurations>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- jersey dependencies -->
|
|
||||||
<dependency org="junit" name="junit" rev="4.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-json" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-client" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-server" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="com.sun.jersey" name="jersey-core" rev="1.4" conf="build->default"/>
|
|
||||||
<dependency org="asm" name="asm-parent" rev="3.1" conf="build->default"/>
|
|
||||||
<dependency org="commons-beanutils" name="commons-beanutils" rev="1.8.0" conf="build->default"/>
|
|
||||||
<dependency org="org.antlr" name="stringtemplate" rev="3.2" conf="build->default"/>
|
|
||||||
<!-- jackson jars -->
|
|
||||||
<dependency org="org.codehaus.jackson" name="jackson-jaxrs" rev="1.7.1" conf="build->default"/>
|
|
||||||
<dependency org="org.codehaus.jackson" name="jackson-xc" rev="1.7.1" conf="build->default"/>
|
|
||||||
<dependency org="org.codehaus.jackson" name="jackson-mapper-asl" rev="1.7.1" conf="build->default"/>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency org="net.sourceforge.cobertura" name="cobertura" rev="1.9.2" conf="test->default">
|
|
||||||
<exclude org="asm" name="asm-tree"/>
|
|
||||||
<exclude org="asm" name="asm"/>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</ivy-module>
|
|
@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ivysettings>
|
|
||||||
<settings defaultResolver="chained" />
|
|
||||||
<property name="ivy.checksums" value=""/>
|
|
||||||
<property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local"
|
|
||||||
override="false" />
|
|
||||||
<property name="ivy.local.default.ivy.pattern"
|
|
||||||
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
|
|
||||||
override="false" />
|
|
||||||
<property name="ivy.local.default.artifact.pattern"
|
|
||||||
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
|
|
||||||
override="false" />
|
|
||||||
<resolvers>
|
|
||||||
<chain name="chained" returnFirst="true">
|
|
||||||
<filesystem name="local">
|
|
||||||
<ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}" />
|
|
||||||
<artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
|
|
||||||
</filesystem>
|
|
||||||
<ibiblio name="ibiblio" m2compatible="true" />
|
|
||||||
<ibiblio name="javanet" root="http://download.java.net/maven/2/" m2compatible="true" />
|
|
||||||
</chain>
|
|
||||||
</resolvers>
|
|
||||||
</ivysettings>
|
|
@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"apiUrl":"http://localhost:8002/api/",
|
|
||||||
|
|
||||||
"apiKey":"special-key",
|
|
||||||
|
|
||||||
"defaultServiceBaseClass":"Object",
|
|
||||||
|
|
||||||
"defaultModelBaseClass":"Object",
|
|
||||||
|
|
||||||
"serviceBaseClasses":{},
|
|
||||||
|
|
||||||
"defaultModelImports":[],
|
|
||||||
|
|
||||||
"defaultServiceImports":[],
|
|
||||||
|
|
||||||
"modelPackageName":"com.wordnik.swagger.sample.sdk.java.model",
|
|
||||||
|
|
||||||
"apiPackageName":"com.wordnik.swagger.sample.sdk.java.api",
|
|
||||||
|
|
||||||
"ignoreMethods":[],
|
|
||||||
|
|
||||||
"ignoreModels":[],
|
|
||||||
|
|
||||||
"outputDirectory":"../swagger-sample-app/sdk-libs/src/main/java/com/wordnik/swagger/sample/sdk/java",
|
|
||||||
|
|
||||||
"libraryHome":"../swagger-sample-app/sdk-libs"
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"userList":[
|
|
||||||
{
|
|
||||||
"username":"testuser1",
|
|
||||||
"password":"password1",
|
|
||||||
"email":"test1@dummy.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username":"testuser2",
|
|
||||||
"password":"password2",
|
|
||||||
"email":"test2@dummy.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"petList":[
|
|
||||||
{
|
|
||||||
"id":101,
|
|
||||||
"name":"pet1",
|
|
||||||
"photoUrls":["url1","url2"],
|
|
||||||
"tags":[
|
|
||||||
{
|
|
||||||
"id":1,
|
|
||||||
"name":"tag1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":2,
|
|
||||||
"name":"tag2"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"status":"available",
|
|
||||||
"category":{"id":1,"name":"cat1"}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"orderList":[
|
|
||||||
{
|
|
||||||
"id":101,
|
|
||||||
"petId":1,
|
|
||||||
"quantity":1,
|
|
||||||
"status":"placed",
|
|
||||||
"shipDate":13456789
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,265 +0,0 @@
|
|||||||
{
|
|
||||||
"resources" : [
|
|
||||||
{
|
|
||||||
"id" : 1,
|
|
||||||
"name" : "Find Per by Id",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/{petId}",
|
|
||||||
"suggestedMethodName" : "getPetById"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 2,
|
|
||||||
"name" : "Find pets by status",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/findByStatus",
|
|
||||||
"suggestedMethodName" : "findPetsByStatus"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 3,
|
|
||||||
"name" : "Find pets by tags",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/pet.{format}/findByTags",
|
|
||||||
"suggestedMethodName" : "findPetsByTags"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 4,
|
|
||||||
"name" : "Add a pet",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/pet.{format}",
|
|
||||||
"suggestedMethodName" : "addPet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 5,
|
|
||||||
"name" : "Update a pet",
|
|
||||||
"httpMethod" : "PUT",
|
|
||||||
"path" : "/pet.{format}",
|
|
||||||
"suggestedMethodName" : "updatePet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 6,
|
|
||||||
"name" : "Create user",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/user.{format}",
|
|
||||||
"suggestedMethodName" : "createUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 7,
|
|
||||||
"name" : "Update user",
|
|
||||||
"httpMethod" : "PUT",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "updateUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 8,
|
|
||||||
"name" : "Delete user",
|
|
||||||
"httpMethod" : "DELETE",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "deleteUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 9,
|
|
||||||
"name" : "Get user by user name",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/{username}",
|
|
||||||
"suggestedMethodName" : "getUserByName"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 10,
|
|
||||||
"name" : "Login",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/login",
|
|
||||||
"suggestedMethodName" : "loginUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 11,
|
|
||||||
"name" : "Logout",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/user.{format}/logout",
|
|
||||||
"suggestedMethodName" : "logoutUser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 12,
|
|
||||||
"name" : "Find order by id",
|
|
||||||
"httpMethod" : "GET",
|
|
||||||
"path" : "/store.{format}/order/{orderId}",
|
|
||||||
"suggestedMethodName" : "getOrderById"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 13,
|
|
||||||
"name" : "Delete order by id",
|
|
||||||
"httpMethod" : "DELETE",
|
|
||||||
"path" : "/store.{format}/order/{orderId}",
|
|
||||||
"suggestedMethodName" : "deleteOrder"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 14,
|
|
||||||
"name" : "Create order",
|
|
||||||
"httpMethod" : "POST",
|
|
||||||
"path" : "/store.{format}/order",
|
|
||||||
"suggestedMethodName" : "placeOrder"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"testSuites" : [
|
|
||||||
{
|
|
||||||
"id" : 1,
|
|
||||||
"name" : "Test User service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Create User",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 6,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.userList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Login User",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 10,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}",
|
|
||||||
"password":"${input.userList[0].password}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find user by name",
|
|
||||||
"id" : 3,
|
|
||||||
"resourceId" : 9,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.3).username}",
|
|
||||||
"condition" : "==",
|
|
||||||
"expectedOutput" : "${input.userList[0].username}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Delete user by name",
|
|
||||||
"id" : 4,
|
|
||||||
"resourceId" : 9,
|
|
||||||
"input" : {
|
|
||||||
"username":"${input.userList[0].username}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.4)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 2,
|
|
||||||
"name" : "Test Pet service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Add pet",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 4,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.petList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find pet by id",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 1,
|
|
||||||
"input" : {
|
|
||||||
"petId":"1"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "NULL"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Find pet by status",
|
|
||||||
"id" : 3,
|
|
||||||
"resourceId" : 2,
|
|
||||||
"input" : {
|
|
||||||
"status":"available,sold,pending"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(2.3).size}",
|
|
||||||
"condition" : ">",
|
|
||||||
"expectedOutput" : "0"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 3,
|
|
||||||
"name" : "Test Store service related APIs",
|
|
||||||
"testCases" : [
|
|
||||||
{
|
|
||||||
"name" : "Find order by id",
|
|
||||||
"id" : 1,
|
|
||||||
"resourceId" : 12,
|
|
||||||
"input" : {
|
|
||||||
"orderId":"1"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(3.1)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "NULL"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Place order",
|
|
||||||
"id" : 2,
|
|
||||||
"resourceId" : 14,
|
|
||||||
"input" : {
|
|
||||||
"postData":"${input.orderList[0]}"
|
|
||||||
},
|
|
||||||
"assertions" : [
|
|
||||||
{
|
|
||||||
"actualOutput" : "${output(1.2)}",
|
|
||||||
"condition" : "!=",
|
|
||||||
"expectedOutput" : "EXCEPTION"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package $packageName$
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$;
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $enum.description$
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
* @author tony
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
object $className$ {
|
|
||||||
$values: { value | var $value.name$ = $value.value$};separator="\n"$
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package $packageName$
|
|
||||||
|
|
||||||
import com.wordnik.swagger.runtime.annotations._
|
|
||||||
|
|
||||||
import scala.reflect.BeanProperty
|
|
||||||
|
|
||||||
import scala.collection.JavaConversions._
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
* @author tony
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class $className$ extends $extends$ {
|
|
||||||
|
|
||||||
$fields:{ field |
|
|
||||||
/**
|
|
||||||
* $field.description$
|
|
||||||
* $if(field.required)$@Required$endif$
|
|
||||||
* $if(field.allowableValues)$@AllowableValues(value="$field.allowedValuesString$")$endif$
|
|
||||||
*/
|
|
||||||
$if(field.fieldDefinition.hasListResponse)$
|
|
||||||
var $field.fieldDefinition.name$ $field.fieldDefinition.initialization$
|
|
||||||
def get$field.fieldDefinition.NameForMethod$:java.util.List[$field.fieldDefinition.collectionItemType$] = {
|
|
||||||
$field.fieldDefinition.name$.toList
|
|
||||||
}
|
|
||||||
def set$field.fieldDefinition.NameForMethod$(args:java.util.List[$field.fieldDefinition.collectionItemType$]) = {
|
|
||||||
$field.fieldDefinition.name$.clear
|
|
||||||
args.foreach(arg=>$field.fieldDefinition.name$ += arg)
|
|
||||||
}
|
|
||||||
$\r$
|
|
||||||
$else$
|
|
||||||
@BeanProperty
|
|
||||||
var $field.fieldDefinition.name$:$field.fieldDefinition.returnType$ $field.fieldDefinition.initialization$$\r\r$
|
|
||||||
$endif$
|
|
||||||
}$ override def toString:String = {
|
|
||||||
"[" +
|
|
||||||
$fields:{ field | "$field.fieldDefinition.name$:" + $field.fieldDefinition.name$};separator=" + \r "$ + "]"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,177 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package $packageName$
|
|
||||||
|
|
||||||
import $modelPackageName$._
|
|
||||||
|
|
||||||
import org.codehaus.jackson.map.DeserializationConfig.Feature
|
|
||||||
import org.codehaus.jackson.map.ObjectMapper
|
|
||||||
import org.codehaus.jackson.`type`.TypeReference
|
|
||||||
import com.wordnik.swagger.runtime.annotations._
|
|
||||||
import com.wordnik.swagger.runtime.common._
|
|
||||||
import com.wordnik.swagger.runtime.exception._
|
|
||||||
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
import scala.collection.mutable._
|
|
||||||
import scala.collection.JavaConversions._
|
|
||||||
|
|
||||||
$imports:{ import |
|
|
||||||
import $import$
|
|
||||||
}$
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
* @author tony
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
object $resource$ {
|
|
||||||
|
|
||||||
var apiInvoker:APIInvoker = null;
|
|
||||||
|
|
||||||
$methods:{ method |
|
|
||||||
/**
|
|
||||||
* $method.title$
|
|
||||||
*
|
|
||||||
$if(method.description)$
|
|
||||||
* $method.description$
|
|
||||||
* $endif$
|
|
||||||
* $method.arguments:{ argument |@param $argument.name$ $argument.description$
|
|
||||||
$if(argument.allowedValues)$
|
|
||||||
* Allowed values are - $argument.allowedValues$ $endif$ }$
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
|
|
||||||
* @throws APIException $method.exceptionDescription$
|
|
||||||
*/
|
|
||||||
$if(method.hasArguments)$
|
|
||||||
@MethodArgumentNames(value="$method.argumentNames; separator=", "$")
|
|
||||||
$endif$
|
|
||||||
|
|
||||||
@throws(classOf[APIException])
|
|
||||||
def $method.name$($method.argumentDefinitions; separator=", "$)$if(method.hasResponseValue)$: $if(method.returnValueList)$$method.returnValue$$else$Option[$method.returnValue$]$endif$$endif$ = {
|
|
||||||
//parse inputs
|
|
||||||
var resourcePath = "$method.resourcePath$".replace("{format}","json")
|
|
||||||
val method = "$method.methodType$";
|
|
||||||
var queryParams = new HashMap[String, String]
|
|
||||||
var headerParams = new HashMap[String, String]
|
|
||||||
|
|
||||||
$if(!method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if(null != $argument.name$) {
|
|
||||||
queryParams += "$argument.name$" -> APIInvoker.toPathValue($argument.name$)
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if(null != $argument.name$) {
|
|
||||||
headerParams += "$argument.name$" -> APIInvoker.toPathValue($argument.name$)
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if(null != $argument.name$) {
|
|
||||||
resourcePath = resourcePath.replace("{$argument.name$}", APIInvoker.toPathValue($argument.name$))
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
$if(method.inputModel)$
|
|
||||||
$method.queryParameters:{ argument |
|
|
||||||
if(null != $argument.inputModelClassArgument$ && null != $argument.methodNameFromModelClass$ ) {
|
|
||||||
queryParams += "$argument.name$" -> APIInvoker.toPathValue($argument.methodNameFromModelClass$)
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.headerParameters:{ argument |
|
|
||||||
if(null != $argument.inputModelClassArgument$ && null != $argument.methodNameFromModelClass$ ) {
|
|
||||||
headerParams += "$argument.name$" -> APIInvoker.toPathValue($argument.methodNameFromModelClass$)
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$method.pathParameters:{ argument |
|
|
||||||
if(null != $argument.inputModelClassArgument$ && null != $argument.methodNameFromModelClass$ ) {
|
|
||||||
resourcePath = resourcePath.replace("{$argument.name$}", APIInvoker.toPathValue($argument.methodNameFromModelClass$))
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
$endif$
|
|
||||||
//make the API Call
|
|
||||||
$if(method.hasResponseValue)$
|
|
||||||
var response: String = null
|
|
||||||
try {
|
|
||||||
$if(method.postObject)$
|
|
||||||
response = apiInvoker.invokeAPI(resourcePath, method, queryParams, postData, headerParams)
|
|
||||||
$else$
|
|
||||||
response = apiInvoker.invokeAPI(resourcePath, method, queryParams, null, headerParams)
|
|
||||||
$endif$
|
|
||||||
} catch {
|
|
||||||
case ex: APIException if ex.getCode == 404 =>
|
|
||||||
$if(method.returnValueList)$ return List()
|
|
||||||
$else$ return None
|
|
||||||
$endif$
|
|
||||||
case ex: APIException => throw ex
|
|
||||||
}
|
|
||||||
$else$
|
|
||||||
$if(method.postObject)$
|
|
||||||
apiInvoker.invokeAPI(resourcePath, method, queryParams, postData, headerParams)
|
|
||||||
$else$
|
|
||||||
apiInvoker.invokeAPI(resourcePath, method, queryParams, null, headerParams)
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
$if(!method.responseVoid)$
|
|
||||||
|
|
||||||
$if(method.hasResponseValue)$
|
|
||||||
$if(!method.returnValueList)$
|
|
||||||
if(null == response){
|
|
||||||
return None
|
|
||||||
}
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
$if(!method.returnValueList)$
|
|
||||||
$if(method.hasResponseValue)$
|
|
||||||
//create output objects if the response has more than one object
|
|
||||||
val responseObject = APIInvoker.deserialize(response, classOf[$method.returnClassName$]).asInstanceOf[$method.returnValue$]
|
|
||||||
|
|
||||||
$if(method.returnValueList)$
|
|
||||||
responseObject
|
|
||||||
$else$
|
|
||||||
Some(responseObject)
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
$if(method.returnValueList)$
|
|
||||||
val typeRef = new TypeReference[Array[$method.returnClassName$]] {}
|
|
||||||
try {
|
|
||||||
val responseObject = APIInvoker.mapper.readValue(response, typeRef).asInstanceOf[Array[$method.returnClassName$]]
|
|
||||||
responseObject.toList
|
|
||||||
} catch {
|
|
||||||
case ioe:IOException => {
|
|
||||||
val args = Array(response, typeRef.toString())
|
|
||||||
throw new APIException(APIExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe)
|
|
||||||
}
|
|
||||||
case _ => throw new APIException(APIExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, "Error in converting response json value to java object")
|
|
||||||
}
|
|
||||||
$endif$
|
|
||||||
$endif$
|
|
||||||
}
|
|
||||||
}$
|
|
||||||
|
|
||||||
def getApiInvoker():APIInvoker = {
|
|
||||||
if(null == apiInvoker){
|
|
||||||
apiInvoker = APIInvoker.getApiInvoker();
|
|
||||||
}
|
|
||||||
return apiInvoker;
|
|
||||||
}
|
|
||||||
|
|
||||||
def setApiInvoker(invoker:APIInvoker) = {
|
|
||||||
apiInvoker = invoker;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package $packageName$
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Maintains the compatible server version against which the drive is written
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
* @author tony
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class VersionChecker {
|
|
||||||
var compatibleVersion = "$apiVersion$"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the version against which the library code was written
|
|
||||||
*/
|
|
||||||
def getCompatibleVersion():String = compatibleVersion
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user