-
Couldn't load subscription status.
- Fork 250
Class Names Glob Patterns
Typescript-generator input classes can be specified using classPatterns parameter which is a list of glob patterns.
Any class whose name matches any of the specified patterns will be included unless it is explicitly excluded.
This parameter can be combined with other input parameters (classes and classesFromJaxrsApplication).
Note: class dependencies will be also included even if they do not match any pattern (for example if class
Ahas a propery of typeBthenBwill be also included regardless of its name). This transitive mechanism applies to all input parameters.
Classes can be excluded one by one by using excludeClasses parameter. It is also possible to exclude multiple classes at once by using excludeClassPatterns parameter.
Class name glob patterns support two wildcards.
- Single
*wildcard matches any character except for.and$. - Double
**wildcard matches any character.
-
cz.habarta.example.*- pattern for classes incz.habarta.examplepackage -
cz.habarta.example.**- pattern for classes incz.habarta.examplepackage and all sub-packages -
cz.habarta.**Json- pattern for classes ending withJsonsuffix -
**.dto.*- pattern for classes in anydtopackage -
**$Companion- pattern useful for excluding Kotlin companion objects
<plugin>
<groupId>cz.habarta.typescript-generator</groupId>
<artifactId>typescript-generator-maven-plugin</artifactId>
<version>1.7.x</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<jsonLibrary>jackson2</jsonLibrary>
<classPatterns>
<pattern>cz.habarta.example.*</pattern>
<pattern>cz.habarta.example.data.**</pattern>
<pattern>cz.habarta.example.rest.*</pattern>
</classPatterns>
<excludeClasses>
<class>cz.habarta.example.Application</class>
</excludeClasses>
<outputFile>target/rest.d.ts</outputFile>
<outputKind>global</outputKind>
</configuration>
</execution>
</executions>
</plugin>If you have JAX-RS Application it is recommended to specify input classes using classesFromJaxrsApplication parameter instead of using globbing.
For more information see JAX RS Application.
Tip: as mentioned before classes are included transitively. But sometimes whole chain of classes is discovered unintentionally so it is practical to use
excludeClassesparameter to exclude root of this chain or tree. For example if classAwhich is explicitly included has a property of typeB, classBhasCand classChasDit is sufficient to exclude classBto excludeB,CandDand process classAonly.