CAMEL-11006 Auto generate REST DSL for Camel fr......om Swagger2.0/OAI specificationRefactored `directRouteGenerator` to `destinationGenerator` in remainingplaces. Refactored `Function<Operation, String>` to`DestinationGenerator` makes for nicer interface.
CAMEL-11006 Auto generate REST DSL for Camel fr......om Swagger2.0/OAI specificationRefactored `directRouteGenerator` to `destinationGenerator` and made`RestDslDefinitionGenerator` public -- otherwise it could not be used.
CAMEL-11006 Auto generate REST DSL for Camel fr......om Swagger2.0/OAI specificationThis is initial work on REST DSL code|object generation from Swaggerspecification.Entry point to the implementation is RestDslGenerator::to...(...)methods. Several options are provided for generating source files: - for code generation in Maven plugin ones accepting Path or Appendable should be suitable - for generation in Annotation Processing ones accepting Filer are more appropriate - and for generation of the object graph in runtime the one accepting CamelContext is providedBoth the source code and object graph implementation depend on aCodeEmitter implementation: one relying on reflection(RestDefinitionEmitter) is used to generate the object graph, and theone generating the source code for the RouteBuilder::configure methodbody using the javapoet library (MethodBodySourceCodeEmitter).CodeEmitter is driven by two visitor pattern implementations onefor processing path elements of the specification (RestDslPathGenerator)and one for processing operation elements of he specification(RestDslOperationGenerator). Both can be further adapted to support moreof the Swagger specification. I believe they map the currently used /relevant parts of the Swagger specification covered by REST DSL.Example of usage: RestDslGenerator.toPath(swagger) .withClassName("MyRestRoute") .withPackageName("com.example") .withIndent("\t") .generate(Paths.get("src", "generated"));