-
-
Notifications
You must be signed in to change notification settings - Fork 11
support a per-function @noCbSwagger
attribute
#43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
support a per-function @noCbSwagger
attribute
#43
Conversation
the presence of this attribute prevents the inclusion of the function's associated documentation from ending up in swagger docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @davidAtInleague ! A couple of cleanup items and then I will merge this a bump a patch.
models/RoutesParser.cfc
Outdated
@@ -324,6 +339,11 @@ component accessors="true" threadsafe singleton { | |||
} | |||
} | |||
|
|||
if ( path.count() == 0 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use boolean evaluation here, per Ortus Coding Standards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
models/RoutesParser.cfc
Outdated
// then do not expose this function to swagger docs. | ||
// | ||
if ( !isNull( arguments.handlerMetadata ) ) { | ||
var maybeNull_metaData = getFunctionMetadata( handlerMetadata = arguments.handlerMetadata, functionName = lCase( actions[ methodName ] ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just call this var functionMetadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
models/RoutesParser.cfc
Outdated
* return true if the metadata represents a function marked "noCbSwagger" | ||
*/ | ||
private boolean function isAnnotatedWithTruthyNoCbSwaggerAttribute( required struct functionMetadata ) { | ||
if ( !structKeyExists( functionMetadata, "noCbSwagger" ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call this function metadata cbSwagger
, check for its existence, and then look for a boolean
false
. This can open up additional inclusions in the future by using cbSwagger
or cbSwagger=true
on a function or component. When we implement this, we could then do discovery of an entire site without includes/excludes by simply using the component/function MD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So your function annotation would become:
function myFunction() cbSwagger=false{...}
or
/**
* @cbswagger false
**/
function myFunction(){...}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
models/RoutesParser.cfc
Outdated
return false; | ||
} | ||
|
||
if ( trim( functionMetadata.noCbSwagger ) == "" ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify the conditionals here with a ternary here:
return !structKeyExists( functionMetadata, "cbSwagger" )
? false
: !functionMetadata.cbswagger.len()
|| (
isValid( "boolean", functionMetadata.noCbSwagger ) && functionMetadata.noCbSwagger
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
models/RoutesParser.cfc
Outdated
/** | ||
* return true if the metadata represents a function marked "noCbSwagger" | ||
*/ | ||
private boolean function isAnnotatedWithTruthyNoCbSwaggerAttribute( required struct functionMetadata ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename this method to isCbSwaggerEnabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually since this is within the scope of the parser, let's just call this isDocumentationEnabled
. Then we could hook in to other exclusions, as necessary, down the road.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
I tried to run cfformat but get the following, I'm not sure what the issue is here:
|
the presence of this attribute prevents the inclusion of the function's associated documentation from ending up in swagger docs
Description
completes #42
Type of change
Checklist