{"id":14986599,"url":"https://github.com/hardiksinghbehl/multiple-open-api-group-spring-boot","last_synced_at":"2025-04-11T23:01:41.613Z","repository":{"id":118947403,"uuid":"400705395","full_name":"hardikSinghBehl/multiple-open-api-group-spring-boot","owner":"hardikSinghBehl","description":"POC showing how to divide endpoint(s) among different Open-API screens","archived":false,"fork":false,"pushed_at":"2021-08-28T06:14:09.000Z","size":62,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T18:54:02.834Z","etag":null,"topics":["java","open-api","open-api-v3","spring-boot"],"latest_commit_sha":null,"homepage":"https://x2-open-api-groups-spring-boot.herokuapp.com/swagger-ui.html","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hardikSinghBehl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-08-28T04:58:01.000Z","updated_at":"2023-07-28T10:11:36.000Z","dependencies_parsed_at":"2023-03-17T06:45:47.315Z","dependency_job_id":null,"html_url":"https://github.com/hardikSinghBehl/multiple-open-api-group-spring-boot","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.375,"last_synced_commit":"1b5b3a8103c2a7cd3c8a21f4d6e211091ef31925"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikSinghBehl%2Fmultiple-open-api-group-spring-boot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikSinghBehl%2Fmultiple-open-api-group-spring-boot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikSinghBehl%2Fmultiple-open-api-group-spring-boot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikSinghBehl%2Fmultiple-open-api-group-spring-boot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hardikSinghBehl","download_url":"https://codeload.github.com/hardikSinghBehl/multiple-open-api-group-spring-boot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492876,"owners_count":21113163,"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":["java","open-api","open-api-v3","spring-boot"],"created_at":"2024-09-24T14:13:12.417Z","updated_at":"2025-04-11T23:01:41.568Z","avatar_url":"https://github.com/hardikSinghBehl.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Multiple Open-API groups: Spring boot\n#### POC showing how to divide endpoint(s) among different Open-API screens\n#### [Demo Link (Select definition from top right corner)](https://x2-open-api-groups-spring-boot.herokuapp.com/swagger-ui.html)\n---\n\nhttps://user-images.githubusercontent.com/69693621/131207157-e017fc2d-631a-4df5-9063-21d3520df48a.mov\n\n---\n## Steps \n1. Put the below dependency in pom.xml\n```\n\u003cdependency\u003e\n\t\u003cgroupId\u003eorg.springdoc\u003c/groupId\u003e\n\t\u003cartifactId\u003espringdoc-openapi-ui\u003c/artifactId\u003e\n\t\u003cversion\u003e1.5.10\u003c/version\u003e\n\u003c/dependency\u003e\n```\n2. Put the below mentioned property in the application.properties file\n```\nspringdoc.api-docs.groups.enabled=true\n```\n3. Divide the controller endpoint(s) of each group in a distinct base package\n```\n- com.behl.controller.nsfw\n  - put endpoint(s) that belong in 'nsfw' group here\n- com.behl.controller.sfw\n  - put endpoint(s) that belong in 'sfw' group here\n```\n4. Define Bean of type GroupedOpenApi for each group and specify the package to scan \n```\n@Bean\npublic GroupedOpenApi nsfwOpenApi() {\n\tString packagesToscan[] = { \"com.behl.agares.controller.nsfw\" };\n\treturn GroupedOpenApi.builder().group(\"nsfw\")\n\t\t\t.packagesToScan(packagesToscan).build();\n}\n```\n5. (Optional) To customize the Open-API defintion including info, contact, security etc implement OpenApiCustomiser interface and override customize() containing your custom configurations\n```\n@Configuration\npublic class NsfwOpenApiCustomizer implements OpenApiCustomiser {\n\n\t@Override\n\tpublic void customise(final OpenAPI openApi) {\n\t\tfinal var info = new Info().title(\"Not Safe For Work Joke API\").version(\"1.0\")\n\t\t\t\t.description(\"Endpoint(s) to expose to mature audience\")\n\t\t\t\t.contact(new Contact().email(\"hardik.behl7444@gmail.com\").name(\"Hardik Singh Behl\")\n\t\t\t\t\t\t.url(\"https://www.linkedin.com/in/hardiksinghbehl/\"));\n\t\topenApi.info(info);\n\t}\n\n}\n\n```\nPass the class implementing OpenApiCustomizer in the .addOpenApiCustomiser(OpenApiCustomizer) method in the earlier created GroupedOpenApi Bean\n```\n@Bean\npublic GroupedOpenApi sfwOpenApi() {\n\tString packagesToscan[] = { \"com.behl.agares.controller.sfw\" };\n\treturn GroupedOpenApi.builder().group(\"sfw\").addOpenApiCustomiser(nsfwOpenApiCustomizer)\n\t\t\t.packagesToScan(packagesToscan).build();\n}\n```\n6. Access the swagger-ui at the below URI containing multiple configured definition/groups\n```\nhttp://server:port/swagger-ui.html\n```\n```\nhttp://localhost:8080/swagger-ui.html\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardiksinghbehl%2Fmultiple-open-api-group-spring-boot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardiksinghbehl%2Fmultiple-open-api-group-spring-boot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardiksinghbehl%2Fmultiple-open-api-group-spring-boot/lists"}