Skip to content

Commit f2531db

Browse files
committed
BoxLang compatibility
1 parent 9f480af commit f2531db

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

models/OpenAPIConstraintsGenerator.cfc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ component name="OpenAPIConstraintsGenerator" {
1818
() => {
1919
return deserializeJSON( fileRead( expandPath( paths.parametersPath ) ) );
2020
},
21-
createTimespan( 1, 0, 0, 0 )
21+
1 // 1 day
2222
);
2323
structAppend( constraints, generateConstraintsFromParameters( parametersJSON[ paths.parametersKey ] ) )
2424
}
@@ -29,7 +29,7 @@ component name="OpenAPIConstraintsGenerator" {
2929
() => {
3030
return deserializeJSON( fileRead( expandPath( paths.requestBodyPath ) ) );
3131
},
32-
createTimespan( 1, 0, 0, 0 )
32+
1 // 1 day
3333
);
3434
var schema = requestBodyJSON[ "content" ][ "application/json" ][ "schema" ];
3535
structAppend(
@@ -67,13 +67,13 @@ component name="OpenAPIConstraintsGenerator" {
6767
var constraints = {};
6868
constraints[ "required" ] = arguments.isRequired;
6969
addValidationType( constraints, schema );
70-
if ( constraints[ "type" ] == "struct" ) {
70+
if ( constraints[ "type" ] == "struct" && schema.keyExists( "properties" ) ) {
7171
constraints[ "constraints" ] = generateConstraintsFromRequestBodyProperties(
7272
schema.properties,
7373
schema.required ?: []
7474
);
7575
}
76-
if ( constraints[ "type" ] == "array" ) {
76+
if ( constraints[ "type" ] == "array" && schema.keyExists( "items" ) ) {
7777
constraints[ "items" ] = generateConstraint( schema.items, arguments.isRequired );
7878
}
7979
if ( schema.keyExists( "enum" ) ) {

models/RoutesParser.cfc

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ component accessors="true" threadsafe singleton {
6464

6565
// Incorporate our API routes into the document
6666
filterDesignatedRoutes().each( function( key, value ){
67-
template[ "paths" ].putAll( createPathsFromRouteConfig( value ) );
67+
structAppend(
68+
template[ "paths" ],
69+
createPathsFromRouteConfig( value ),
70+
true
71+
);
6872
} );
6973

7074
// Build out the Open API Document object
@@ -192,7 +196,7 @@ component accessors="true" threadsafe singleton {
192196
for ( var pathEntry in entrySet ) {
193197
for ( var routeKey in designatedRoutes ) {
194198
if ( replaceNoCase( routeKey, "/", "", "ALL" ) == pathEntry ) {
195-
sortedRoutes.put( routeKey, designatedRoutes[ routeKey ] );
199+
sortedRoutes[ routeKey ] = designatedRoutes[ routeKey ];
196200
}
197201
}
198202
}
@@ -287,7 +291,7 @@ component accessors="true" threadsafe singleton {
287291
// method not in error methods
288292
if ( !arrayFindNoCase( errorMethods, actions[ methodList ] ) ) {
289293
// Create new path template
290-
path.put( lCase( methodName ), getOpenAPIUtil().newMethod() );
294+
path[ lCase( methodName ) ] = getOpenAPIUtil().newMethod();
291295
// Append Params
292296
appendPathParams( pathKey = arguments.pathKey, method = path[ lCase( methodName ) ] );
293297
// Append Function metadata
@@ -309,7 +313,7 @@ component accessors="true" threadsafe singleton {
309313
} else {
310314
for ( var methodName in getOpenAPIUtil().defaultMethods() ) {
311315
// Insert path template for default method
312-
path.put( lCase( methodName ), getOpenAPIUtil().newMethod() );
316+
path[ lCase( methodName ) ] = getOpenAPIUtil().newMethod();
313317
// Append Params
314318
appendPathParams( pathKey = arguments.pathKey, method = path[ lCase( methodName ) ] );
315319
// Append metadata
@@ -346,7 +350,7 @@ component accessors="true" threadsafe singleton {
346350
}
347351
}
348352

349-
arguments.existingPaths.put( "/" & arrayToList( pathSegments, "/" ), path );
353+
arguments.existingPaths[ "/" & arrayToList( pathSegments, "/" ) ] = path;
350354
}
351355

352356
/**
@@ -358,7 +362,7 @@ component accessors="true" threadsafe singleton {
358362
private void function appendPathParams( required string pathKey, required struct method ){
359363
// Verify parameters array in the method definition
360364
if ( !structKeyExists( arguments.method, "parameters" ) ) {
361-
arguments.method.put( "parameters", [] );
365+
arguments.method[ "parameters" ] = [];
362366
}
363367

364368
// handle any parameters in the url now
@@ -508,44 +512,41 @@ component accessors="true" threadsafe singleton {
508512

509513
// hint/description
510514
if ( infoKey == "hint" ) {
511-
if ( !method.containsKey( "description" ) || method[ "description" ] == "" ) {
512-
method.put( "description", infoMetadata );
515+
if ( !structKeyExists( method, "description" ) || method[ "description" ] == "" ) {
516+
method[ "description" ] = infoMetadata;
513517
}
514-
if ( !functionMetadata.containsKey( "summary" ) ) {
515-
method.put( "summary", infoMetadata );
518+
if ( !structKeyExists( functionMetadata, "summary" ) ) {
519+
method[ "summary" ] = infoMetadata;
516520
}
517521
continue;
518522
}
519523

520524
if ( infoKey == "description" && infoMetadata != "" ) {
521-
method.put( "description", infoMetadata );
525+
method[ "description" ] = infoMetadata;
522526
continue;
523527
}
524528

525529
if ( infoKey == "summary" ) {
526-
method.put( "summary", infoMetadata );
530+
method[ "summary" ] = infoMetadata;
527531
continue;
528532
}
529533

530534
// Operation Tags
531535
if ( infoKey == "tags" ) {
532-
method.put(
533-
"tags",
534-
( isSimpleValue( infoMetadata ) ? listToArray( infoMetadata ) : infoMetadata )
535-
);
536+
method[ "tags" ] = isSimpleValue( infoMetadata ) ? listToArray( infoMetadata ) : infoMetadata;
536537
continue;
537538
}
538539

539540
// Request body: { description, required, content : {} } if simple, we just add it as required, with listed as content
540541
if ( left( infoKey, 12 ) == "requestBody" ) {
541-
method.put( "requestBody", structNew( "ordered" ) );
542+
method[ "requestBody" ] = structNew( "ordered" );
542543

543544
if ( isSimpleValue( infoMetadata ) ) {
544545
method[ "requestBody" ][ "description" ] = infoMetadata;
545546
method[ "requestBody" ][ "required" ] = true;
546547
method[ "requestBody" ][ "content" ] = { "#infoMetadata#" : {} };
547548
} else {
548-
method[ "requestBody" ].putAll( infoMetadata );
549+
structAppend( method[ "requestBody" ], infoMetadata, true );
549550
}
550551
continue;
551552
}
@@ -635,13 +636,13 @@ component accessors="true" threadsafe singleton {
635636
var filterString = arrayToList(
636637
[
637638
moduleName,
638-
listLast( handlerMetadata.name, "." ),
639+
listLast( handlerMetadata.fullname, "." ),
639640
methodName
640641
],
641642
"."
642643
);
643644
} else {
644-
var filterString = arrayToList( [ handlerMetadata.name, methodName ], "." );
645+
var filterString = arrayToList( [ handlerMetadata.fullname, methodName ], "." );
645646
}
646647

647648
availableFiles
@@ -754,14 +755,18 @@ component accessors="true" threadsafe singleton {
754755
// get reponse name
755756
var responseName = right( infoKey, len( infoKey ) - 9 );
756757

757-
method[ "responses" ].put( responseName, structNew( "ordered" ) );
758+
method[ "responses" ][ responseName ] = structNew( "ordered" );
758759

759760
// Use simple value for description and content type
760761
if ( isSimpleValue( infoMetadata ) ) {
761762
method[ "responses" ][ responseName ][ "description" ] = infoMetadata;
762763
method[ "responses" ][ responseName ][ "content" ] = { "#infoMetadata#" : {} };
763764
} else {
764-
method[ "responses" ][ responseName ].putAll( infoMetadata );
765+
structAppend(
766+
method[ "responses" ][ responseName ],
767+
infoMetadata,
768+
true
769+
);
765770
}
766771
} );
767772

test-harness/box.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"coldbox":"be"
1111
},
1212
"devDependencies":{
13-
"testbox":"^4.0.0",
13+
"testbox":"be",
1414
"route-visualizer":"^2.0.0+6"
1515
},
1616
"installPaths":{

0 commit comments

Comments
 (0)