Whatever message this page gives is out now! Go check it out!
wwwroot) of ColdFusion server. // student.cfc
component
{
property string name;
property numeric age;
}// address.cfc
component
{
property string buildingName;
property numeric flatNumber;
property string locality;
property string province;
}<cfset this.restsettings.generateRestDoc="false">application.cfc file is shown below for your reference. <cfcomponent>
<cfset this.name="info" />
<cfset this.sessionmanagement = true />
<cfset this.restsettings.generateRestDoc="true">
<cfset this.restsettings.restDocInfo.title="this is title">
<cfset this.restsettings.restDocInfo.apiVersion="2.0">
<cfset this.restsettings.restDocInfo.description="this is description">
<cfset this.restsettings.restDocInfo.termOfServiceUrl="url is here">
<cfset this.restsettings.restDocInfo.contact="xyz@adobe.com">
<cfset this.restsettings.restDocInfo.license="adobe 1.0">
<cfset this.restsettings.restDocInfo.licenseUrl="http://abc.com">
</cfcomponent>responseMessages has been introduced in Adobe ColdFusion (2016 release). You can use this attribute in REST CFC file as shown in the sample file below. <cfcomponent rest="true" restPath="/cookieService" produces="text/plain" >
<!--- Test with various produces --->
<cffunction name="sayPlainHelloUser" responseMessages="404:Not Found,200:successful,10:notdefine" access="remote" returnType="String" httpMethod="GET" produces="text/plain">
<cfargument name="nAme" type="string" restargsource="cOOkie" required="false" default="CF">
<cfset res="Hello " & name>
<cfreturn res>
</cffunction>
</cfcomponent><ColdFusion server URL path:port number>/<Service Mapping name>/api-docs/<resourcePath name><ColdFusion server URL path:port number>/Service Mapping name>/api-docs) localhost:8500/test/api-docs/studentServicestudentservice.cfc REST CFC file appears as shown in the following api document: {
"swaggerVersion":"1.2",
"apiVersion":"1.0",
"basePath":"localhost:8500/rest/test",
"resourcePath":"/studentService",
"apis":[
{
"path":"/studentService/",
"description":"",
"operations":[
{
"nickname":"addStudents",
"method":"POST",
"summary":"add students",
"type":"void",
"parameters":[
{
"name":"name",
"paramType":"body",
"allowMultiple":false,
"required":true,
"type":"array",
"items":{
"$ref":"student"
}
}
]
},
{
"nickname":"deleteStudent1",
"method":"DELETE",
"summary":"delete students",
"type":"void",
"parameters":[
{
"name":"students",
"paramType":"body",
"allowMultiple":false,
"required":true,
"type":"array",
"items":{
"$ref":"student"
}
}
]
},
{
"nickname":"addStudent",
"method":"PUT",
"summary":"add student",
"type":"void",
"parameters":[
{
"name":"name",
"paramType":"form",
"allowMultiple":false,
"required":true,
"type":"string"
},
{
"name":"age",
"paramType":"form",
"allowMultiple":false,
"required":true,
"type":"number"
}
]
}
]
},
{
"path":"/studentService/{name}-{age}",
"description":"",
"operations":[
{
"nickname":"getStudent",
"method":"GET",
"summary":"retrieve student",
"type":"student",
"produces":[
"application/json"
],
"parameters":[
{
"name":"name",
"paramType":"path",
"allowMultiple":false,
"required":true,
"type":"string"
},
{
"name":"age",
"paramType":"path",
"allowMultiple":false,
"required":true,
"type":"string"
}
],
"responseMessages":[
{
"code":404,
"message":"Not found"
},
{
"code":200,
"message":"Successfull",
"responseModel":"student"
}
]
}
]
},
{
"path":"/studentService/{studentId}",
"description":"",
"operations":[
{
"nickname":"updateStudentAddress",
"method":"POST",
"summary":"modify student address",
"notes":"modify the address for given studentId",
"type":"address",
"parameters":[
{
"name":"studentId",
"paramType":"path",
"allowMultiple":false,
"required":true,
"type":"number"
},
{
"name":"address",
"paramType":"body",
"allowMultiple":false,
"required":true,
"type":"address"
}
]
}
]
}
],
"models":{
"address":{
"id":"address",
"description":"this is a address component",
"required":[
],
"properties":{
"country":{
"type":"string"
},
"street":{
"type":"string"
},
"houseNo":{
"type":"number",
"format":"double"
},
"state":{
"type":"string"
}
}
},
"student":{
"id":"student",
"description":"this is a student component",
"required":[
"address",
"name",
"age"
],
"properties":{
"address":{
"$ref":"IndiaAddress"
},
"name":{
"type":"string"
},
"age":{
"type":"number",
"format":"double"
}
}
},
"IndiaAddress":{
"id":"IndiaAddress",
"description":"India address fromat",
"required":[
],
"properties":{
"country":{
"type":"string"
},
"pin":{
"type":"number",
"format":"double"
},
"street":{
"type":"string"
},
"district":{
"type":"string"
},
"houseNo":{
"type":"number",
"format":"double"
},
"state":{
"type":"string"
}
}
}
}
} cfusion /ApiManager path. For more information, refer to ColdFusion and API Manager integration feature. Swagger doc Field Name | Type | Description | CF Fields |
SwaggerVersion | String | Required. Specifies the Swagger Specification version being used. | Update programmatically using API Manager |
apis | Resource Object | Required. Lists the resources of the specification. The array can have 0 or more elements | N/A |
apiVersion | string | Provides the version of the application API | Modify using application.cfc file |
info | Info Object | Provides metadata about the API. The clients can use this metadata, and can be presented in the Swagger-UI for convenience. | Modify using application.cfc file |
authorizations | Authorizations Object | Provides information about the authorization schemes allowed on this API. The type of the authorization scheme. Values MUST be either"basicAuth", "apiKey", or "oauth2". | Update programmatically using API Manager |
Swagger doc Field Name | Type | Description | CF Field |
basePath | string | Required. The root URL serving the API. | Add programmatically while parsing CFC |
consumes | [string] | A list of MIME types the APIs on this resource can consume. The MIME types are global to all APIs but can be overridden on specific API calls. | Cfcomponent.consumes |
produces | [string] | A list of MIME types the APIs on this resource can produce. The MIME types are global to all APIs but can be overridden on specific API calls. | Cfcomponent.produces |
resourcePath | string | The relative path to the resource, from the basePath, which this API Specification describes. | Cfcomponent.restpath |
apis | [API Object] | Required. A list of the APIs exposed on this resource. There MUST NOT be more than one API Object per path in the array. | Details in API Object |
apiVersion | string | Provides the version of the application API (not to be confused by the (specification version). | N/A |
swaggerVersion | string | Required. Specifies the Swagger Specification version being used. | N/A |
authorizations | Authorizations Object | A list of authorizations schemes required for the operations listed in this API declaration. Individual operations override this setting. If there are multiple authorization schemes described here, it means they're all applied. | Add programmatically as API Manager updates Authorization info |
models | Models Object | A list of the models available to this resource. Expose the models separately for each API Declaration. | Generate programmatically |
Swagger doc Field Name | Type | Description | CF Field |
description | String | A short description of the resource. | Cffunction.description |
operations | [Operation Object] | Required. A list of the API operations available on this path. The array includes zero or more operations. | Details in Operation Object |
Path | String | Required. The relative path to the operation, from the basePath, which this operation describes. The value SHOULD be in a relative (URL) path format. | Component.restpath + Cffunction.restpath |
Swagger doc Field Name | Type | Description | CF Field |
authorization | Authorizations Object | A list of authorizations required to execute this operation | Programmatically from API Manager |
consumes | [string] | A list of MIME types this operation can consume. | Cffunction.consumes |
method | String | Required. The HTTP method required to call the operation.The value MUST be one of the following values: "GET", "HEAD", "POST", "PUT","PATCH", "DELETE", "OPTIONS". The values MUST be in uppercase. | Cffunction. httpmethod |
nickname | String | Required. A unique id for the operation that is used by tools reading the output for further and easier manipulation | Cffunction.name |
notes | String | A verbose explanation of the operation behavior. | Cffunction.hint |
parameters | [Parameter Object] | Required. The inputs to the operation. If no parameters are needed, an empty array MUST be included. | Details in parameter object |
produces | [string] | A list of MIME types this operation can produce. | Cffunction.produces |
responseMessages | [Response Message Object] | Lists the possible response statuses that can return from the operation. | New parameter introduced in Cfunction |
summary | String | A short summary of what the operation does. For maximum readability in the swagger-ui, this field SHOULD be fewer than 120 characters. | Cffunction.description |
Swagger doc Field Name | Type | Description | CF Field |
allowMultiple | boolean | Another way to allow multiple values for a "query", "header" or "path" parameter. | Not available in ColdFusion. |
description | string | Recommended. A brief description of this parameter. | Cfargument.hint |
name | string | Required. The unique name for the parameter. | Cfargument.name |
paramType | string | Required. The type of the parameter.The value MUST be one of these values: "path", "query", "body","header", "form" Note: As per spec swagger dosen’t support "Cookie", "Matrix" paramtype in ColdFusion | Cfargument. restargsource |
required | boolean | A flag to note whether this parameter is mandatory. | Cfargument.required |
| CFC | Swagger | Java | Additional information |
| string | string | string | |
| uuid | string | string | |
| guid | string | string | |
| query | custom model | coldfusion.xml.rpc.DocumentQueryBean | |
| void | void | for argument map to "body" | |
| numeric | number(format double) | Double | |
| boolean | boolean | boolean | |
| date | string(format date) | java.util.Calendar | |
| any | object | java.lang.Object | |
| array | array of objects | java.lang.Object[] | |
| binary | array of byte | byte[] | |
| struct | custom model | java.util.Map | |
| xml | string | org.w3c.dom.Documents |