{"id":20471527,"url":"https://github.com/backbase/boat-examples","last_synced_at":"2025-09-08T11:04:37.209Z","repository":{"id":235149749,"uuid":"787835111","full_name":"Backbase/boat-examples","owner":"Backbase","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-24T12:26:37.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-06-14T06:03:49.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Backbase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-17T09:17:27.000Z","updated_at":"2024-04-24T12:26:40.000Z","dependencies_parsed_at":"2024-04-24T13:53:32.541Z","dependency_job_id":null,"html_url":"https://github.com/Backbase/boat-examples","commit_stats":null,"previous_names":["backbase/boat-examples"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Backbase/boat-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Backbase%2Fboat-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Backbase%2Fboat-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Backbase%2Fboat-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Backbase%2Fboat-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Backbase","download_url":"https://codeload.github.com/Backbase/boat-examples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Backbase%2Fboat-examples/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260427404,"owners_count":23007502,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T14:16:25.556Z","updated_at":"2025-06-17T19:35:32.735Z","avatar_url":"https://github.com/Backbase.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"`# BOAT Golden Example\n\nThis example consists of three modules:\n\n- [Server](server): This service provides a greeting message based on the received name\n- [Client](client): This service registers a user and calls the [Server](server) service to get a greeting message\n- [Api](api): The OpenAPI specification for the greeting services are stored in this module.\n\n**Note**: It's important to keep your specifications in a separate module to prevent duplicating it in the server and\nclient.\n\n## API\n\nThis module will package the OpenAPI specs using `maven-assembly-plugin`. Take a look at\nthe [api.xml](api/assembly/api.xml) file to see how it's configured.\u003cbr/\u003e\nFor validating and bundling the spec file we can use `boat-maven-plugin`. Take a look at the executions of the plugin.\n\n## Server\n\nThe server uses the api dependency to generate the rest controller interfaces.\u003c/br\u003e\nFirst we need to unpack the API dependency using the `maven-dependency-plugin` in the [POM file](server/pom.xml):\n\n```xml\n\n\u003cplugin\u003e\n    \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n    \u003cartifactId\u003emaven-dependency-plugin\u003c/artifactId\u003e\n    \u003cexecutions\u003e\n        \u003cexecution\u003e\n            \u003cid\u003eunpack\u003c/id\u003e\n            \u003cphase\u003egenerate-sources\u003c/phase\u003e\n            \u003cgoals\u003e\n                \u003cgoal\u003eunpack\u003c/goal\u003e\n            \u003c/goals\u003e\n            \u003cconfiguration\u003e\n                \u003cartifactItems\u003e\n                    \u003cartifactItem\u003e\n                        \u003cgroupId\u003ecom.backbase\u003c/groupId\u003e\n                        \u003cartifactId\u003eboat-example-api\u003c/artifactId\u003e\n                        \u003cversion\u003e1.0.0\u003c/version\u003e\n                        \u003cclassifier\u003eapi\u003c/classifier\u003e\n                        \u003coutputDirectory\u003e${project.build.directory}/yaml\u003c/outputDirectory\u003e\n                        \u003ctype\u003ezip\u003c/type\u003e\n                        \u003coverWrite\u003etrue\u003c/overWrite\u003e\n                    \u003c/artifactItem\u003e\n                \u003c/artifactItems\u003e\n                \u003cincludes\u003e**/*.yaml, **/*.json\u003c/includes\u003e\n            \u003c/configuration\u003e\n        \u003c/execution\u003e\n    \u003c/executions\u003e\n\u003c/plugin\u003e\n```\n\nThen we can generate required DTOs and interfaces using `boat-maven-plugin`:\n\n```xml\n\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.backbase.oss\u003c/groupId\u003e\n    \u003cartifactId\u003eboat-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e${boat-maven-plugin.version}\u003c/version\u003e\n    \u003cexecutions\u003e\n        \u003cexecution\u003e\n            \u003cid\u003egenerate-client-api-code\u003c/id\u003e\n            \u003cgoals\u003e\n                \u003cgoal\u003egenerate-spring-boot-embedded\u003c/goal\u003e\n            \u003c/goals\u003e\n            \u003cphase\u003egenerate-sources\u003c/phase\u003e\n            \u003cconfiguration\u003e\n                \u003cinputSpec\u003e${project.build.directory}/yaml/boat-example-api/greeting-api-v1.0.0.yaml\n                \u003c/inputSpec\u003e\n                \u003capiPackage\u003ecom.backbase.greeting.api.service.v1\u003c/apiPackage\u003e\n                \u003cmodelPackage\u003ecom.backbase.greeting.api.service.v1.model\u003c/modelPackage\u003e\n                \u003ctypeMappings\u003e\n                    \u003ctypeMapping\u003eOffsetDateTime=java.time.ZonedDateTime\u003c/typeMapping\u003e\n                \u003c/typeMappings\u003e\n            \u003c/configuration\u003e\n        \u003c/execution\u003e\n    \u003c/executions\u003e\n\u003c/plugin\u003e\n```\n\nNotice the `\u003cgoal\u003egenerate-spring-boot-embedded\u003c/goal\u003e` which generates required files for server implementation.\n\n## Client\n\nThe client also uses the API dependency to generate required DTOs and client files.\u003cbr/\u003e\nFirst we need to unpack the API dependency using the `maven-dependency-plugin` like the server config.\u003cbr/\u003e\nThen we can generate required DTOs and client using `boat-maven-plugin`:\n\n```xml\n\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.backbase.oss\u003c/groupId\u003e\n    \u003cartifactId\u003eboat-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e${boat-maven-plugin.version}\u003c/version\u003e\n    \u003cexecutions\u003e\n        \u003cexecution\u003e\n            \u003cid\u003eboat-example-api\u003c/id\u003e\n            \u003cphase\u003egenerate-sources\u003c/phase\u003e\n            \u003cgoals\u003e\n                \u003cgoal\u003egenerate-rest-template-embedded\u003c/goal\u003e\n            \u003c/goals\u003e\n            \u003cconfiguration\u003e\n                \u003cinputSpec\u003e${project.build.directory}/yaml/boat-example-api/greeting-api-v1.0.0.yaml\n                \u003c/inputSpec\u003e\n                \u003capiPackage\u003ecom.backbase.greeting.api.service.v1\u003c/apiPackage\u003e\n                \u003cmodelPackage\u003ecom.backbase.greeting.api.service.v1.model\u003c/modelPackage\u003e\n                \u003ctypeMappings\u003e\n                    \u003ctypeMapping\u003eOffsetDateTime=java.time.ZonedDateTime\u003c/typeMapping\u003e\n                \u003c/typeMappings\u003e\n            \u003c/configuration\u003e\n        \u003c/execution\u003e\n    \u003c/executions\u003e\n\u003c/plugin\u003e\n```\n\nNotice the `\u003cgoal\u003egenerate-rest-template-embedded\u003c/goal\u003e` which generates required files for client implementation.\n\n### Client config\n\nWe need to create and configure api beans:\n\n```java\n\n@Configuration\npublic class GreetingClientConfiguration {\n    @Value(\"${backbase.example.greeting-base-url}\")\n    private String greetingBasePath;\n\n    @Bean\n    public ApiClient greetingApiClient(@Qualifier(INTER_SERVICE_REST_TEMPLATE_BEAN_NAME) RestTemplate restTemplate) {\n        ApiClient apiClient = new ApiClient(restTemplate);\n        apiClient.setBasePath(this.greetingBasePath);\n        apiClient.addDefaultHeader(HttpCommunicationConfiguration.INTERCEPTORS_ENABLED_HEADER, Boolean.TRUE.toString());\n        return apiClient;\n    }\n\n    @Bean\n    public GreetingApi createConfirmationApi(@Qualifier(\"greetingApiClient\") ApiClient greetingApiClient) {\n        return new GreetingApi(greetingApiClient);\n    }\n}\n```\n\nIf we want to call a service-api, we need to provide a client-credential token which is created by the Token Converter\nservice. We can use the rest template that is provided by the SSDK communication library which will automatically inject\nthe\nclient credential token in the request using `@Qualifier(INTER_SERVICE_REST_TEMPLATE_BEAN_NAME)`.\u003c/br\u003e\nFor more information you can read the HTTP\ncommunication [here](https://community.backbase.com/documentation/ServiceSDK/latest/http_service_to_service_communication)\n.\u003cbr/\u003e\n\nThe `INTERCEPTORS_ENABLED_HEADER` header enables the `ApiErrorExceptionInterceptor` class of the SSDK communication\nlibrary to intercept errors.\nFor more info about client configuration you can read\nthe [community doc](https://community.backbase.com/documentation/ServiceSDK/latest/generate_clients_from_openapi).\n\n### Enabling logging\n\nWe can enable request and response logging in api client using debug option:\n\n```java\n    @Bean\npublic ApiClient greetingApiClient(){\n        ApiClient apiClient=new ApiClient(new RestTemplate());\n        apiClient.setBasePath(this.greetingBasePath);\n        apiClient.addDefaultHeader(HttpCommunicationConfiguration.INTERCEPTORS_ENABLED_HEADER,Boolean.TRUE.toString());\n        apiClient.setDebugging(true);\n        return apiClient;\n        }\n```\n\n## Writing tests\n\nIn the client for writing tests, we can mock the server's API like this:\n\n```java\n  //mock server's response\n  GreetingPostResponse greetingPostResponse=new GreetingPostResponse();\n          greetingPostResponse.setMessage(HELLO_USERNAME);\n          when(greetingApi.postGreeting(any())).thenReturn(greetingPostResponse);\n```\n\nYou can check the whole test class [here](client/src/test/java/com/example/RegisterControllerIT.java)\n\nFor more info you can read\nthe [boat documentation](https://github.com/Backbase/backbase-openapi-tools/blob/main/boat-maven-plugin/README.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackbase%2Fboat-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbackbase%2Fboat-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackbase%2Fboat-examples/lists"}