CamelContextConfiguration onBeforeStart()

in components-starter/camel-openapi-java-starter/src/main/java/org/apache/camel/springboot/openapi/OpenApiAutoConfiguration.java [64:108]


    CamelContextConfiguration onBeforeStart(GenericApplicationContext ac, CamelContext camelContext, OpenApiConfiguration config) {
        return new CamelContextConfiguration() {
            @Override
            public void beforeApplicationStart(CamelContext camelContext) {
                // routes have now been loaded, so we need to detect rest-dsl APIs in Camel
                // this will trigger spring boot to create the bean which springdoc can detect
                try {
                    OpenAPI created = createOpenAPI(camelContext);
                    if (created != null) {
                        LOG.info("OpenAPI ({}) created from Camel Rest-DSL v{} - {}", created.getOpenapi(), created.getInfo().getVersion(), created.getInfo().getTitle());
                        // transfer data to the existing
                        openAPI.setInfo(created.getInfo());
                        openAPI.setOpenapi(created.getOpenapi());
                        if (created.getComponents() != null) {
                            openAPI.setComponents(created.getComponents());
                        }
                        if (created.getExtensions() != null) {
                            openAPI.setExtensions(created.getExtensions());
                        }
                        if (created.getSecurity() != null) {
                            openAPI.setSecurity(created.getSecurity());
                        }
                        if (created.getExternalDocs() != null) {
                            openAPI.setExternalDocs(created.getExternalDocs());
                        }
                        if (created.getPaths() != null) {
                            openAPI.setPaths(created.getPaths());
                        }
                        if (created.getTags() != null) {
                            openAPI.setTags(created.getTags());
                        }
                        // do not copy servers as we use the spring-boot configured setting
                    }
                } catch (Exception e) {
                    LOG.warn("Error generating OpenAPI from Camel Rest DSL due to: {}. This exception is ignored.",
                            e.getMessage(), e);
                }
            }

            @Override
            public void afterApplicationStart(CamelContext camelContext) {
                // noop
            }
        };
    }