66*/
77component name = " OpenAPIUtil" accessors = " true" {
88
9- public function init (){
9+ /**
10+ * Constructor
11+ */
12+ function init (){
1013 return this ;
1114 }
1215
16+ /**
17+ * Generate a new template for the Open API spec
18+ */
1319 any function newTemplate (){
1420 // We need to use Linked Hashmaps to maintain struct order for serialization and deserialization
15- var template = createLinkedHashMap ( );
21+ var template = structNew ( " ordered " );
1622 var templateDefaults = [
1723 {" openapi" : " 3.0.2" },
1824 {
@@ -21,12 +27,12 @@ component name="OpenAPIUtil" accessors="true" {
2127 " title" : " " ,
2228 " description" : " " ,
2329 " termsOfService" : " " ,
24- " contact" : createLinkedHashMap ( ),
25- " license" : createLinkedHashMap ( )
30+ " contact" : structNew ( " ordered " ),
31+ " license" : structNew ( " ordered " )
2632 }
2733 },
2834 {" servers" : []},
29- {" paths" : createLinkedHashMap ( )},
35+ {" paths" : structNew ( " ordered " )},
3036 {" security" : []},
3137 {
3238 " externalDocs" : {
@@ -44,9 +50,12 @@ component name="OpenAPIUtil" accessors="true" {
4450 return template ;
4551 }
4652
53+ /**
54+ * Create a new method representation
55+ */
4756 any function newMethod (){
48- var method = createLinkedHashMap ( );
49- var descMap = createLinkedHashMap ( );
57+ var method = structNew ( " ordered " );
58+ var descMap = structNew ( " ordered " );
5059 descMap .put ( " description" , " " );
5160 // Other supported options are requestBody and tag will be added runtime
5261 var methodDefaults = [
@@ -68,14 +77,25 @@ component name="OpenAPIUtil" accessors="true" {
6877 return method ;
6978 }
7079
71- any function defaultMethods (){
80+ /**
81+ * Get an array of default methods
82+ */
83+ array function defaultMethods (){
7284 return [ " GET" , " PUT" , " POST" , " PATCH" , " DELETE" , " HEAD" ];
7385 }
7486
75- any function defaultSuccessResponses (){
87+ /**
88+ * Get an array of default response codes
89+ */
90+ array function defaultSuccessResponses (){
7691 return [ 200 , 200 , 201 , 200 , 204 , 204 ];
7792 }
7893
94+ /**
95+ * Translate path from URL Path
96+ *
97+ * @URLPath
98+ */
7999 string function translatePath ( required string URLPath ){
80100 var pathArray = listToArray ( arguments .URLPath , ' /' );
81101 for ( var i = 1 ; i <= arrayLen ( pathArray ); i ++ ){
@@ -88,42 +108,46 @@ component name="OpenAPIUtil" accessors="true" {
88108
89109 }
90110
91-
92111 /**
93- * Converts a Java object to native CFML structure
94- * @param Object Map The Java map object or array to be converted
95- */
96- function toCF ( Map ){
112+ * Converts a Java object to native CFML structure
113+ *
114+ * @param Object Map The Java map object or array to be converted
115+ */
116+ function toCF ( map ){
97117
98- if (isNull ( Map ) ) return ;
118+ if ( isNull ( arguments . map ) ) return ;
99119
100120 // if we're in a loop iteration and the array item is simple, return it
101- if (isSimpleValue ( Map ) ) return Map ;
121+ if ( isSimpleValue ( arguments . map ) ) return arguments . map ;
102122
103- if (isArray ( Map ) ){
123+ if ( isArray ( map ) ){
104124 var cfObj = [];
105125
106- for (var obj in Map ){
107- arrayAppend (cfObj ,toCF (obj ) );
126+ for ( var obj in arguments . map ){
127+ arrayAppend ( cfObj , toCF ( obj ) );
108128 }
109129
110130 } else {
111131
112132 var cfObj = {};
113133
114134 try {
115- cfObj .putAll ( Map );
135+ cfObj .putAll ( arguments . map );
116136
117- } catch (any e ){
137+ } catch ( any e ){
118138
119- return Map ;
139+ return arguments . map ;
120140 }
121141
122- // loop our keys to ensure first-level items with sub-documents objects are converted
123- for (var key in cfObj ){
124-
125- if (! isNull (cfObj [key ]) && ( isArray (cfObj [key ]) || isStruct (cfObj [key ]) ) ) cfObj [key ] = toCF (cfObj [key ]);
142+ // loop our keys to ensure first-level items with sub-documents objects are converted
143+ for ( var key in cfObj ){
126144
145+ if (
146+ ! isNull ( cfObj [ key ] ) &&
147+ ( isArray ( cfObj [ key ] ) || isStruct ( cfObj [ key ] ) )
148+ ){
149+ cfObj [ key ] = toCF ( cfObj [ key ] );
150+ }
127151 }
128152 }
129153
0 commit comments