diff --git a/asyncapi-template/filters/PropertyFilter.js b/asyncapi-template/filters/PropertyFilter.js index 4313c5d..5d3fac1 100644 --- a/asyncapi-template/filters/PropertyFilter.js +++ b/asyncapi-template/filters/PropertyFilter.js @@ -112,4 +112,22 @@ function isRobotOutput(prop) { return prop.startsWith("<"); } -module.exports = { formatPropName, cap1, formatPropType, formatPropObjType, formatPropCallbackType, formatPropParser, formatPropInitialValue, isRobotInput, isRobotOutput } +function usesCustomTypes(props, schemaName) { + for (const [propName, prop] of Object.entries(props)) { + if (formatPropParser(prop, schemaName, propName) !== "null") return true; + } + return false; +} + +module.exports = { + formatPropName, + cap1, + formatPropType, + formatPropObjType, + formatPropCallbackType, + formatPropParser, + formatPropInitialValue, + isRobotInput, + isRobotOutput, + usesCustomTypes +} diff --git a/asyncapi-template/template/$$schema$$.java b/asyncapi-template/template/$$schema$$.java index 855ed0f..1b94456 100644 --- a/asyncapi-template/template/$$schema$$.java +++ b/asyncapi-template/template/$$schema$$.java @@ -35,7 +35,9 @@ import org.team199.wpiws.connection.ConnectionProcessor; import org.team199.wpiws.connection.WSValue; import org.team199.wpiws.interfaces.*; +{%- if (props | usesCustomTypes(name)) %} import org.team199.wpiws.types.*; +{%- endif %} /** * Represents a simulated {{ name | lower }}