Skip to content

Commit a5cb28a

Browse files
committed
Format
1 parent 9a2bb6f commit a5cb28a

File tree

9 files changed

+476
-475
lines changed

9 files changed

+476
-475
lines changed

ModuleConfig.cfc

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
component {
77

88
// Module Properties
9-
this.title = "ColdBox Swagger SDK";
10-
this.author = "Ortus Solutions";
11-
this.webURL = "https://www.ortussolutions.com";
12-
this.description = "Swagger SDK Module";
13-
this.version = "@build.version@[email protected]@";
14-
this.viewParentLookup = true;
9+
this.title = "ColdBox Swagger SDK";
10+
this.author = "Ortus Solutions";
11+
this.webURL = "https://www.ortussolutions.com";
12+
this.description = "Swagger SDK Module";
13+
this.version = "@build.version@[email protected]@";
14+
this.viewParentLookup = true;
1515
this.layoutParentLookup = true;
1616
// Model Namespace
17-
this.modelNamespace = "SwaggerSDK";
17+
this.modelNamespace = "SwaggerSDK";
1818
// CF Mapping
19-
this.cfmapping = "SwaggerSDK";
19+
this.cfmapping = "SwaggerSDK";
2020
// Auto-map models
21-
this.autoMapModels = false;
21+
this.autoMapModels = false;
2222
// Module Dependencies That Must Be Loaded First, use internal names or aliases
23-
this.dependencies = [ "cbjavaloader" ];
23+
this.dependencies = [ "cbjavaloader" ];
2424

2525
/**
2626
* Configure App
@@ -33,14 +33,13 @@ component {
3333
*/
3434
function onLoad(){
3535
// load jars
36-
wirebox.getInstance( "loader@cbjavaloader" )
37-
.appendPaths( variables.modulePath & "/lib" );
36+
wirebox.getInstance( "loader@cbjavaloader" ).appendPaths( variables.modulePath & "/lib" );
3837

3938

4039
/**
41-
* Utilities
42-
*
43-
*/
40+
* Utilities
41+
*
42+
*/
4443

4544
// Open API Util
4645
binder
@@ -51,9 +50,9 @@ component {
5150

5251

5352
/**
54-
* Manual Instantiation Instances
55-
*
56-
*/
53+
* Manual Instantiation Instances
54+
*
55+
*/
5756

5857
// models.OpenAPI.Document
5958
binder

box.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
"*/.md"
3333
],
3434
"scripts":{
35-
"toMaster":"recipe build/toMaster.boxr"
35+
"toMaster":"recipe build/toMaster.boxr",
36+
"format":"cfformat run models,test-harness/tests/resources/BaseOpenAPISpec.cfc,test-harness/tests/specs,ModuleConfig.cfc --overwrite",
37+
"format:watch":"cfformat watch models,test-harness/tests/resources/BaseOpenAPISpec.cfc,test-harness/tests/specs,ModuleConfig.cfc ./.cfformat.json",
38+
"format:check":"cfformat check models,test-harness/tests/resources/BaseOpenAPISpec.cfc,test-harness/tests/specs,ModuleConfig.cfc ./.cfformat.json",
3639
},
3740
"installPaths":{
3841
"cbjavaloader":"modules/cbjavaloader/"

models/OpenAPI/Document.cfc

Lines changed: 65 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,43 @@ component name="OpenAPIDocument" accessors="true" {
2020
* @param Doc The document representation
2121
* @param XPath The XPath of the document to zoom this Document object to
2222
**/
23-
Document function init( required struct Doc, required string XPath="" ){
24-
23+
Document function init(
24+
required struct Doc,
25+
required string XPath = ""
26+
){
2527
// Scope the root Document to handle internal inheritance $refs
2628
setRootDocument( arguments.Doc );
2729

2830
// Set the working document which will be returned when normalized
2931
setDocument( arguments.Doc );
3032

3133
// Zoom if requested
32-
if( len( arguments.XPath ) ){
33-
arguments.XPath = arrayToList( listToArray( arguments.XPath, "/" ), "." );
34-
this
35-
.setXPath( arguments.XPath )
36-
.zoomToXPath();
34+
if ( len( arguments.XPath ) ) {
35+
arguments.XPath = arrayToList(
36+
listToArray( arguments.XPath, "/" ),
37+
"."
38+
);
39+
this.setXPath( arguments.XPath ).zoomToXPath();
3740
}
3841

3942
return this;
4043
}
4144

4245
/**
43-
* Convenience methot for setting the XPath of the Document
44-
*
45-
* @param XPath The XPath to zoom the parsed document to during recursion
46-
**/
46+
* Convenience methot for setting the XPath of the Document
47+
*
48+
* @param XPath The XPath to zoom the parsed document to during recursion
49+
**/
4750
Document function xPath( required string XPath ){
4851
this.setXPath( arguments.XPath );
4952
return this;
5053
}
5154

5255
/**
53-
* Zooms this Document instance to the XPath
54-
**/
56+
* Zooms this Document instance to the XPath
57+
**/
5558
Document function zoomToXPath(){
56-
if( isNull( getXPath() ) ) return;
59+
if ( isNull( getXPath() ) ) return;
5760

5861
setDocument( locate( getXPath() ) );
5962

@@ -71,9 +74,9 @@ component name="OpenAPIDocument" accessors="true" {
7174
* Convenience method to return a YAML string of the normalized document
7275
**/
7376
function asYAML(){
74-
return server.keyExists( "boxlang" ) ?
75-
yamlSerialize( getNormalizedDocument() ) :
76-
variables.jLoader.create( "org.yaml.snakeyaml.Yaml" ).dump( getNormalizedDocument() );
77+
return server.keyExists( "boxlang" ) ? yamlSerialize( getNormalizedDocument() ) : variables.jLoader
78+
.create( "org.yaml.snakeyaml.Yaml" )
79+
.dump( getNormalizedDocument() );
7780
}
7881

7982
/**
@@ -88,29 +91,39 @@ component name="OpenAPIDocument" accessors="true" {
8891
*
8992
* @param APIDoc The document to normalized. Defaults to the entity document
9093
**/
91-
function getNormalizedDocument( any APIDoc=this.getDocument() ){
92-
if( isArray( arguments.APIDoc ) ){
93-
return arrayMap( arguments.APIDoc, function( item ) {
94-
return getNormalizedDocument( item );
95-
} );
96-
} else if ( isObject( arguments.APIDoc ) && findNoCase( "Parser", getMetaData( arguments.APIDoc ).name ) ) {
97-
if ( !structKeyExists( arguments.APIDoc, "getDocumentObject" ) ) {
98-
throwForeignObjectTypeException( arguments.APIDoc );
99-
throw(
100-
type = "SwaggerSDK.NormalizationException",
101-
message = "SwaggerSDK doesn't know what do with an object of type #getMetaData( arguments.APIDoc ).name#."
102-
);
103-
}
104-
105-
return arguments.APIDoc.getDocumentObject().getNormalizedDocument();
106-
} else if ( isStruct( arguments.APIDoc ) ) {
107-
return structMap( arguments.APIDoc, function( key, value ) {
94+
function getNormalizedDocument( any APIDoc = this.getDocument() ){
95+
if ( isArray( arguments.APIDoc ) ) {
96+
return arrayMap( arguments.APIDoc, function( item ){
97+
return getNormalizedDocument( item );
98+
} );
99+
} else if (
100+
isObject( arguments.APIDoc ) && findNoCase(
101+
"Parser",
102+
getMetadata( arguments.APIDoc ).name
103+
)
104+
) {
105+
if (
106+
!structKeyExists(
107+
arguments.APIDoc,
108+
"getDocumentObject"
109+
)
110+
) {
111+
throwForeignObjectTypeException( arguments.APIDoc );
112+
throw(
113+
type = "SwaggerSDK.NormalizationException",
114+
message = "SwaggerSDK doesn't know what do with an object of type #getMetadata( arguments.APIDoc ).name#."
115+
);
116+
}
117+
118+
return arguments.APIDoc.getDocumentObject().getNormalizedDocument();
119+
} else if ( isStruct( arguments.APIDoc ) ) {
120+
return structMap( arguments.APIDoc, function( key, value ){
108121
// allow explicit nulls in sample docs to pass through
109-
return !isNull( value ) ? getNormalizedDocument( value ) : javacast( "null", 0 );
110-
} );
111-
}
122+
return !isNull( value ) ? getNormalizedDocument( value ) : javacast( "null", 0 );
123+
} );
124+
}
112125

113-
return arguments.APIDoc;
126+
return arguments.APIDoc;
114127
}
115128

116129
/**
@@ -123,12 +136,17 @@ component name="OpenAPIDocument" accessors="true" {
123136
any function locate( string key ){
124137
var rootDocument = this.getRootDocument();
125138

126-
if( structKeyExists( rootDocument, arguments.key ) ){
139+
if ( structKeyExists( rootDocument, arguments.key ) ) {
127140
return rootDocument[ arguments.key ];
128-
} else if( isDefined( 'rootDocument.#arguments.key#' ) ){
129-
return evaluate( 'rootDocument.#arguments.key#' );
141+
} else if ( isDefined( "rootDocument.#arguments.key#" ) ) {
142+
return evaluate( "rootDocument.#arguments.key#" );
130143
} else {
131-
return { "$ref" : "##/#arrayToList( listToArray( arguments.key, "." ), "/" )#"};
144+
return {
145+
"$ref" : "##/#arrayToList(
146+
listToArray( arguments.key, "." ),
147+
"/"
148+
)#"
149+
};
132150
}
133151
}
134152

@@ -137,13 +155,13 @@ component name="OpenAPIDocument" accessors="true" {
137155
/********************************************************************************/
138156

139157
/**
140-
* Throws a foreign object type exception if detected when normalizing a document
141-
* @param UnKnownObject The foreign object detected
142-
**/
158+
* Throws a foreign object type exception if detected when normalizing a document
159+
* @param UnKnownObject The foreign object detected
160+
**/
143161
private function throwForeignObjectTypeException( required any UnKnownObject ){
144162
throw(
145-
type="SwaggerSDK.ForeignObjectException",
146-
message="SwaggerSDK doesn't know what do with an object of type #getMetaData( UnKnownObject ).name#."
163+
type = "SwaggerSDK.ForeignObjectException",
164+
message = "SwaggerSDK doesn't know what do with an object of type #getMetadata( UnKnownObject ).name#."
147165
);
148166
}
149167

0 commit comments

Comments
 (0)