{"id":18373653,"url":"https://github.com/unionj-cloud/unionj-generator","last_synced_at":"2026-01-04T21:08:11.164Z","repository":{"id":45792126,"uuid":"316134895","full_name":"unionj-cloud/unionj-generator","owner":"unionj-cloud","description":"OpenAPI 3.0 specification Dsl and a collection of code generators","archived":false,"fork":false,"pushed_at":"2023-11-16T08:09:00.000Z","size":9867,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-04T14:54:53.422Z","etag":null,"topics":["dsl","openapi-codegen","openapi-generator","openapi3","spring-boot","typescript","vue"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unionj-cloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-11-26T05:47:34.000Z","updated_at":"2023-05-08T08:29:23.000Z","dependencies_parsed_at":"2023-11-16T09:27:18.105Z","dependency_job_id":null,"html_url":"https://github.com/unionj-cloud/unionj-generator","commit_stats":null,"previous_names":["tsingxiao/unionj-generator"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/unionj-cloud/unionj-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unionj-cloud%2Funionj-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unionj-cloud%2Funionj-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unionj-cloud%2Funionj-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unionj-cloud%2Funionj-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unionj-cloud","download_url":"https://codeload.github.com/unionj-cloud/unionj-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unionj-cloud%2Funionj-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264904288,"owners_count":23681170,"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":["dsl","openapi-codegen","openapi-generator","openapi3","spring-boot","typescript","vue"],"created_at":"2024-11-06T00:11:14.676Z","updated_at":"2026-01-04T21:08:11.071Z","avatar_url":"https://github.com/unionj-cloud.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# unionj-generator\nUnionj-generator is a collection of code generators for spring boot applications with a built-in RESTful api design tool(DSL) compatible with\n[OpenAPI 3.0.0 specification](http://spec.openapis.org/oas/v3.0.3).\n\nIncluding：\n- backend: Using dsl or OpenAPI 3.0 json doc to generate vo, proto, controller, service and feign modules for spring boot backend\n- openapi: dsl implementing [OpenAPI 3.0.0 specification](http://spec.openapis.org/oas/v3.0.3)\n- ui: OpenAPI3 documentation web UI\n- maven plugin: maven command line command to generate backend code\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n### TOC\n\n- [Installation](#installation)\n- [OpenAPI3 Web UI Screenshot](#openapi3-web-ui-screenshot)\n- [Usage](#usage)\n  - [Demo project](#demo-project)\n  - [Recommend project structure](#recommend-project-structure)\n  - [DSL](#dsl)\n    - [Schema](#schema)\n      - [Example](#example)\n      - [SchemaHelper](#schemahelper)\n      - [Generic](#generic)\n        - [Syntax](#syntax)\n    - [Path](#path)\n      - [Example](#example-1)\n  - [Backend](#backend)\n    - [Example](#example-2)\n- [Must Know](#must-know)\n- [Tutorials](#tutorials)\n- [TODO](#todo)\n- [Sister Project](#sister-project)\n- [Community](#community)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n# Installation\n\n```xml\n\u003cdependencies\u003e\n  \u003cdependency\u003e\n     \u003cgroupId\u003eio.github.unionj-cloud\u003c/groupId\u003e\n     \u003cartifactId\u003eunionj-generator-backend\u003c/artifactId\u003e\n     \u003cversion\u003e1.6.7\u003c/version\u003e\n  \u003c/dependency\u003e\n  \u003cdependency\u003e\n     \u003cgroupId\u003eio.github.unionj-cloud\u003c/groupId\u003e\n     \u003cartifactId\u003eunionj-generator-openapi\u003c/artifactId\u003e\n     \u003cversion\u003e1.6.7\u003c/version\u003e\n  \u003c/dependency\u003e\n  \u003cdependency\u003e\n     \u003cgroupId\u003eio.github.unionj-cloud\u003c/groupId\u003e\n     \u003cartifactId\u003eunionj-generator-ui\u003c/artifactId\u003e\n     \u003cversion\u003e1.6.7\u003c/version\u003e\n  \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n```xml\n\u003cbuild\u003e\n  \u003cplugins\u003e\n    \u003cplugin\u003e\n      \u003cgroupId\u003eio.github.unionj-cloud\u003c/groupId\u003e\n      \u003cartifactId\u003eunionj-generator-maven-plugin\u003c/artifactId\u003e\n      \u003cversion\u003e1.6.7\u003c/version\u003e\n      \u003cinherited\u003efalse\u003c/inherited\u003e\n      \u003cexecutions\u003e\n        \u003cexecution\u003e\n          \u003cid\u003epetStore\u003c/id\u003e\n          \u003cgoals\u003e\n            \u003cgoal\u003ecodegen\u003c/goal\u003e\n          \u003c/goals\u003e\n          \u003cinherited\u003efalse\u003c/inherited\u003e\n          \u003cconfiguration\u003e\n            \u003cdocUrl\u003ehttps://petstore3.swagger.io/api/v3/openapi.json\u003c/docUrl\u003e\n            \u003cfeignPkg\u003eio.github.unionj-cloud.feign\u003c/feignPkg\u003e\n            \u003cfeignDir\u003e${project.basedir}/cloud-petStore-feign\u003c/feignDir\u003e\n            \u003cvoPkg\u003eio.github.unionj-cloud.vo\u003c/voPkg\u003e\n            \u003cvoDir\u003e${project.basedir}/cloud-petStore-vo\u003c/voDir\u003e\n            \u003cpackages\u003e\n              \u003cpackage\u003eFEIGN\u003c/package\u003e\n              \u003cpackage\u003eVO\u003c/package\u003e\n            \u003c/packages\u003e\n            \u003cserviceId\u003ecloud-petStore\u003c/serviceId\u003e\n            \u003cserviceBaseUrlKey\u003epetStore.baseUrl\u003c/serviceBaseUrlKey\u003e\n          \u003c/configuration\u003e\n        \u003c/execution\u003e\n      \u003c/executions\u003e\n      \u003cconfiguration\u003e\n        \u003cparentGroupId\u003eio.github.unionj-cloud\u003c/parentGroupId\u003e\n        \u003cparentArtifactId\u003ecloud-unionj\u003c/parentArtifactId\u003e\n        \u003cparentVersion\u003e1.0.0-SNAPSHOT\u003c/parentVersion\u003e\n      \u003c/configuration\u003e\n    \u003c/plugin\u003e\n  \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\n# OpenAPI3 Web UI Screenshot\n![web-ui.png](web-ui.png)\n\n# Usage\n\n## Demo project\n\nIt's a simple typescript http client code download restful service project. Upload OpenAPI3 spec json file, download ts code.\nIt's used in our company project.\n\nRepo: https://github.com/unionj-cloud/openapi-svc\n\nScreenshot:\n![screenshot.png](screenshot.png)\n\n## Recommend project structure\n\nRepo: https://github.com/unionj-cloud/unionj-generator-guide\n\n![demo](./demo.png)\n\n## DSL\n\n### Schema\n\n#### Example\n\n```java\nimport static cloud.unionj.generator.OpenAPI3.dsl.Schema.schema;\nimport static cloud.unionj.generator.OpenAPI3.dsl.SchemaHelper.*;\n\npublic class Components {\n\n  private static Schema sizeProperty = int32(\"每页条数，默认10，传-1查出全部数据\");\n\n  private static Schema currentProperty = int32(\"当前页，从1开始\");\n\n  private static Schema offsetProperty = int32(\"偏移量\");\n\n  private static Schema sortProperty = string(\"排序条件字符串：排序字段前使用'-'(降序)和'+'(升序)号表示排序规则，多个排序字段用','隔开\",\n      \"+id,-create_at\");\n\n  private static Schema pageProperty = int32(\"当前页，从1开始\");\n\n  private static Schema limitProperty = int32(\"每页条数，默认10, 传-1查出全部数据\", 10);\n\n  private static Schema maxPageProperty = int32(\"导出结束页\");\n\n  private static Schema totalProperty = int64(\"总数，入参传入此参数则不再查询count，以此total为准\");\n\n  private static Schema topStatusProperty = int32(\"需要排在前的状态\");\n  \n  public static Schema PageResultVO = schema(sb -\u003e {\n    // Schema type. Required.\n    sb.type(\"object\");\n    // Schema title. Required. Otherwise the generator tool won't know it.\n    sb.title(\"PageResultVO\");\n    // Generic as List\u003cT\u003e\n    sb.properties(\"items\", ListT);\n    sb.properties(\"total\", totalProperty);\n    sb.properties(\"size\", sizeProperty);\n    sb.properties(\"current\", currentProperty);\n    sb.properties(\"searchCount\", bool);\n    sb.properties(\"pages\", int32(\"当前分页总页数\"));\n    sb.properties(\"offset\", offsetProperty);\n  });\n  \n  public static Schema RankVO = schema(sb -\u003e {\n    sb.type(\"object\");\n    sb.title(\"RankVO\");\n    sb.description(\"排行榜\");\n    sb.properties(\"serialNo\", int32);\n    sb.properties(\"name\", string);\n    sb.properties(\"income\", doubleNumer(\"累计收入\"));\n    sb.properties(\"quantity\", int32(\"完成任务数量\"));\n  });\n  \n  public static Schema PageResultVOJobVO = generic(gb -\u003e {\n    gb.generic(PageResultVO, ref(RankVO.getTitle()));\n  });\n}\n\n```\n\n\n\n#### SchemaHelper\n\nThere are some built-in schemas in cloud.unionj.generator.OpenAPI3.dsl.SchemaHelper.\n\n| Type          | Java                 |\n| ------------- | -------------------- |\n| int32         | Integer              |\n| int64         | Long                 |\n| string        | String               |\n| bool          | Boolean              |\n| floatNumber   | Float                |\n| doubleNumer   | Double               |\n| dateTime      | java.util.Date       |\n| T             | \u003cT\u003e                  |\n| ListT         | List\u003cT\u003e              |\n| SetT          | Set\u003cT\u003e               |\n| stringArray   | List\u003cString\u003e         |\n| int32Array    | List\u003cInteger\u003e        |\n| int64Array    | List\u003cLong\u003e           |\n| floatArray    | List\u003cFloat\u003e          |\n| doubleArray   | List\u003cDouble\u003e         |\n| boolArray     | List\u003cBoolean\u003e        |\n| dateTimeArray | List\u003cjava.util.Date\u003e |\n| enums         | enum                 |\n| ref           | Object               |\n| refArray      | List\u003cObject\u003e         |\n\n\n\n#### Generic\n\n##### Syntax\n\n```java\n// PageResultVO must has and only has one T like field, e.g. T, List\u003cT\u003e, Set\u003cT\u003e\n// It will be represented as PageResultVO\u003cRankVO\u003e\npublic static Schema PageResultVOJobVO = generic(gb -\u003e {\n  gb.generic(PageResultVO, ref(RankVO.getTitle()));\n});\n```\n\n\n\n### Path\n\n#### Example\n\n```java\nimport static cloud.unionj.generator.OpenAPI3.PathHelper.*;\n\n@Test\npublic void TestPath() throws IOException {\n  OpenAPI3 OpenAPI3 = OpenAPI3(ob -\u003e {\n    info(ib -\u003e {\n      ib.title(\"title\");\n      ib.version(\"v1.0.0\");\n    });\n\n    server(sb -\u003e {\n      sb.url(\"http://unionj.cloud\");\n    });\n\n    // Support GET, POST, PUT, DELETE only.\n    post(\"/hall/onlineSurvey/list\", PathConfig.builder()\n         .summary(\"summary\")\n         .tags(new String[]{\"tag1\", \"tag2\"})\n         .reqSchema(SearchJobPageResult)\n         .respSchema(SearchJobPageResult)\n         .build());\n\n    post(\"/hall/offlineSurvey/update\", PathConfig.builder()\n         .summary(\"summary\")\n         // Second tag will be used as Proto or typescript Service name\n         // If there was only one tag, the Proto or typescript Service name will be first part of endpoint\n         // e.g. HallProto, HallService\n         .tags(new String[]{\"tag1\", \"HallOfflinesurvey\"})\n         .reqSchema(SearchJobPageResult)\n         .respSchema(SearchJobPageResult)\n         .build());\n\n    post(\"/admin/onlineSurvey/top/update\", PathConfig.builder()\n         .summary(\"summary\")\n         .tags(new String[]{\"tag1\"})\n         .parameters(new Parameter[]{\n           ParameterBuilder.builder().name(\"id\").in(Parameter.InEnum.QUERY).required(true).schema(string).build(),\n           ParameterBuilder.builder().name(\"top\").in(Parameter.InEnum.QUERY).required(true).schema(int32).build(),\n         })\n         .respSchema(SearchJobPageResult)\n         .build());\n  });\n  Backend backend = BackendDocParser.parse(OpenAPI3);\n  SpringbootFolderGenerator springbootFolderGenerator = new SpringbootFolderGenerator.Builder(backend).build();\n  springbootFolderGenerator.generate();\n}\n```\n\n\n\n## Backend\n\n### Example\n\n```java\npackage cloud.unionj.example.proto;\n\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.web.bind.annotation.*;\nimport org.springframework.web.multipart.MultipartFile;\nimport java.util.*;\nimport cloud.unionj.example.vo.*;\nimport cloud.unionj.example.es.page.PageResult;\n\npublic interface AdminProto {\n\n    @PostMapping(\"/admin/news/list\")\n    ResultDTO\u003cPageResultVO\u003cNewsVO\u003e\u003e postAdminNewsList(\n        @RequestBody BaseSearchCondition body\n    );\n\n}\n```\n\n\n# Must Know\n- Source code in proto package, vo package and controller package will be replaced with new code completely, \nso don't edit any source code in these packages.\n- Existing source code in service package will be skipped and not be changed, so you can edit or add your custom code.\n\n# Tutorials\n- [unionj-generator快速上手-后端篇](https://www.jianshu.com/p/21c670ba90f1)\n\n# TODO\nPlease reference [unionj-generator kanban](https://github.com/unionj-cloud/unionj-generator/projects/1)\n\n# Sister Project\n\n- [go-doudou](https://github.com/unionj-cloud/go-doudou): OpenAPI 3.0 spec based lightweight microservice framework for Go\n- [pullcode](https://github.com/wubin1989/pullcode): a typescript http client code generation cli compatible with Swagger 2 and OpenAPI 3\n\n# Community\n\nWelcome to contribute to unionj-generator by forking it and submitting pr or issues. If you like unionj-generator, please give it a star!\n\nWelcome to contact me from \n- facebook: [https://www.facebook.com/bin.wu.94617999/](https://www.facebook.com/bin.wu.94617999/) \n- twitter: [https://twitter.com/BINWU49205513](https://twitter.com/BINWU49205513) \n- email: 328454505@qq.com\n- wechat:  \n![qrcode.png](qrcode.png) \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funionj-cloud%2Funionj-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funionj-cloud%2Funionj-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funionj-cloud%2Funionj-generator/lists"}