![JAR search and dependency download from the Maven repository](/logo.png)
crest-doclet.1.23.source-code.api_resource.vm Maven / Gradle / Ivy
The newest version!
##################################################################
## Create macro to get {*} attributes from array and
## return , seperated string
##################################################################
#macro( getGlobal $url $seperator)
#if($url.indexOf("{") != "-1")
#set($global = $url.substring($url.indexOf("{"),$url.indexOf("}")))
#set($global = $global.substring(1,$global.length()))
#if($global != "") $seperator$global #set($url = $url.replace("{${global}}","")) #getGlobal(${url} ",")
#end
#end
#end{
"apiVersion": "0.2",
"swaggerVersion": "1.1",
"basePath": "${baseUrl}",
##################################################################
## Get all the variables from the path and create a unique array
##################################################################
#set($allGlobals = [])
#foreach( $rp in $resource.paths )
#set($globals = "#getGlobal(${rp} '')")
#set($globals = $globals.replace(" ",""))
#set ($globalsList = $globals.split(",") )
#foreach( $global in $globalsList )
#if($global != "")
#set($alreadyDone = false)
#foreach($done in $allGlobals)
#if($done == $global)
#set($alreadyDone = true)
#end
#end
#if($alreadyDone == false)
#set($dummy = $allGlobals.add(${global}))
#end
#end
#end
#end
##################################################################
## Create globals attribute in json feed
##################################################################
#set($areGlobals = false)
#foreach( $global in $allGlobals )
#set($areGlobals = true)
#if($velocityCount == 1)
"globals":[
#else ,#end{"name":"${global}","type":"text","unique_name":"${global}_$resource.count"}
#end
#if($areGlobals ==true)
],
#end
"apis": [
#set($unique_identify = 0)
#foreach( $resource in $resources )
#if( $velocityCount > 1),#end
#foreach( $method in $resource.methods )
#if( $velocityCount > 1),#end
#foreach( $rp in $resource.paths )
#if( $velocityCount > 1),#end
#foreach( $mp in $method.paths )
#set($unique_identify = $unique_identify+1)
#if( $velocityCount > 1),#end
{
"path": "/${rp}/${mp}",
"description": "${resource.classDoc.qualifiedName()}",
"operations": [
{
"httpMethod": "${method.method}",
"nickname": "${method.name}$unique_identify",
#set( $new_json = $method.json.replace('"',"""))
"notes": "${method.methodDoc.commentText()}
Response Example
${new_json}
",
"summary":"${method.methodDoc.commentText()}()",
"parameters":[
#set( $foo = "" )
#foreach( $param in $method.pathVariables )
#if( $velocityCount > 1),#end
{
"name":"${param.name}"
,"description":"${param.comment}"
,"required":false,"dataType":"${param.type}"
,"allowMultiple":false,"paramType":"path"
}
#set( $foo = "," )
#end
#foreach( $param in $method.parameters )
#if( $velocityCount > 1),#end
$foo
#set( $foo = "" )
{
"name":"${param.name}"
,"description":"${param.comment}"
,"required":false,"dataType":"${param.type}"
,"allowMultiple":false,"paramType":"query"
}
#end
],
"errorResponses":[
#set( $foo = "" )
#foreach( $element in $method.restReturn.elementValues() )
#if( $element.element().name() == "code" )
#set( $codes = $element.value().value() )
#foreach( $code in $codes )
#set( $responseMessage = "" )
#foreach( $e in $code.value().elementValues() )
#if( $e.element().name() == "code" ) #set( $responseCode = $e.value().value() ) #end
#if( $e.element().name() == "description" ) #set( $responseDescription = $e.value().value() ) #end
#if( $e.element().name() == "message" ) #set( $responseMessage = $e.value().value() ) #end
#end
$foo{"reason":"${responseMessage}"
,"code":${responseCode}}
#set( $foo = "," )
#end
#end
#end
],
#if(${method.entityType} != ${method.returnType})
#set( $new_return = $method.returnType.replace("java.util.List<", "List[") )
#set( $new_return = $new_return.replace(">", "]") )
#if(${new_return} != ${method.returnType})
"responseTypeInternal":"${new_return}"
#else
"responseTypeInternal":"${method.entityType}"
#end
#else
"responseTypeInternal":"${method.entityType}"
#end
}
]
}
#end
#end
#end
#end
],
"models":{
#foreach( $entry in $jsonDoc.entrySet() )
#if( $velocityCount > 1),#end
"${entry.value}":{
"properties":{
#set( $jd = $entry.value )
#set( $foo = "" )
#foreach( $m in $jd.methods(false) )
#if( $helper.isGetter($m.name()) )
#set( $memberName = $helper.getMemberName($m.name()) )
#set( $memberType = $m.returnType().qualifiedTypeName() )
$foo"${memberName}":{"type":"${memberType}"}
#set( $foo = "," )
#end
#end
}
}
#end
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy