1
1
# 03-api
2
2
Use this to add Company specific API stuff like the configuration of the projects within the Company.
3
3
4
- The following structure is generated by ` .. /helperCompany.scala init ` :
4
+ The following structure is generated by ` ./helperCompany.scala init ` :
5
5
6
6
``` bash
7
7
03-api/src
@@ -15,38 +15,193 @@ The following structure is generated by `../helperCompany.scala init`:
15
15
16
16
The Company's base class to generate the API documentation and API Clients for Postman.
17
17
18
- Example:
18
+ Example (generated by ` ./helperCompany.scala init ` ) :
19
19
20
- ``` scala mdoc
20
+ ``` scala
21
21
import camundala .api .*
22
22
23
23
trait CompanyApiCreator extends ApiCreator , ApiDsl , CamundaPostmanApiCreator :
24
24
25
25
// override the config if needed
26
26
protected def apiConfig : ApiConfig = CompanyApiCreator .apiConfig
27
-
28
- lazy val companyDescr = ??? // TODO Add your Company Description!
27
+
28
+ lazy val companyProjectVersion = BuildInfo .version
29
29
30
30
object CompanyApiCreator :
31
- lazy val apiConfig = ApiConfig (companyId = " mycompany" )
31
+ lazy val apiConfig = ApiConfig (companyName = " mycompany" )
32
32
end CompanyApiCreator
33
33
```
34
34
35
35
## ApiConfig
36
- You can define the project structure.
36
+ You can customize the API Configuration.
37
+
38
+ Here an example:
39
+
40
+ ``` scala mdoc
41
+ import camundala .api .ApiConfig
42
+
43
+ lazy val apiConfig : ApiConfig =
44
+ ApiConfig (" mycompany" )
45
+ .withTenantId(" mycompany" )
46
+ .withDocBaseUrl(s " http://mycompany.ch/bpmnDocs " )
47
+ .withJiraUrls(" COM" -> " https://issue.mycompany.ch/browse" )
48
+ ```
49
+
50
+ ## Default ApiConfig
51
+ This is the default Configuration:
52
+ ``` scala
53
+ // your company name like 'mycompany'
54
+ companyName: String ,
55
+ // define tenant if you have one - used for the Postman OpenApi
56
+ tenantId: Option [String ] = None ,
57
+ // contact email / phone, if there are questions
58
+ contact: Option [Contact ] = None ,
59
+ // REST endpoint (for testing API)
60
+ endpoint: String = " http://localhost:8080/engine-rest" ,
61
+ // Base Path of your project (if changed - all doc paths will be adjusted)
62
+ basePath: os.Path = os.pwd,
63
+ // If you work with JIRA, you can add matchers that will create automatically URLs to JIRA Tasks
64
+ jiraUrls: Map [String , String ] = Map .empty,
65
+ // Configure your project setup
66
+ projectsConfig: ProjectsConfig = ProjectsConfig (),
67
+ // Configure your template generation
68
+ modelerTemplateConfig: ModelerTemplateConfig = ModelerTemplateConfig (),
69
+ // The URL of your published documentations
70
+ // s"http://myCompany/bpmnDocs"
71
+ docBaseUrl: Option [String ] = None ,
72
+ // Path, where the Git Projects are cloned - for dependency check.
73
+ // the default is for the structure: dev-myCompany/projects/myProject
74
+ tempGitDir: os.Path = os.pwd / os.up / os.up / " git-temp"
75
+ ```
76
+
77
+ ## ProjectsConfig
78
+ You can configure your projects.
37
79
38
80
Here an example:
39
81
40
82
``` scala mdoc
41
83
import camundala .api .*
42
84
43
- lazy val apiConfig =
44
- ApiConfig (companyId = " mycompany" )
45
-
85
+ lazy val projectsConfig = ProjectsConfig (
86
+ // Path to your ApiProjectConf - default is os.pwd / PROJECT.conf
87
+ projectConfPath = os.rel / " src" / " main" / " resources" / " myproject.conf" ,
88
+ // grouped configs per GitRepos - so it is possible to use projects from different Repos
89
+ perGitRepoConfigs = Seq (myCompanyGitRepoConfig)
90
+ )
91
+
92
+ lazy val myCompanyGitRepoConfig = ProjectsPerGitRepoConfig (
93
+ // Base URL for the Git Repos
94
+ // The pattern must be $cloneBaseUrl/$projectName.git
95
+ cloneBaseUrl = " ssh://git@mycompany.com:2222/myrepo" ,
96
+ // Definition of the projects
97
+ projects = myProjects
98
+ )
99
+
100
+ lazy val myProjects = Seq (`mycompany-services`, `mycompany-finances`, `mycompany-employees`)
101
+
102
+ lazy val `mycompany-services` = ProjectConfig (
103
+ // Name of the project
104
+ name = " mycompany-services" ,
105
+ // you can group your projects - for better overview
106
+ group = services,
107
+ // the color of your project - for better overview and visualization in the BPMN diagrams
108
+ color = " blue"
109
+ )
110
+
111
+ lazy val `mycompany-finances` = ???
112
+ lazy val `mycompany-employees` = ???
113
+ lazy val services = ProjectGroup (
114
+ name = " services" ,
115
+ // line color
116
+ color = " purple" ,
117
+ fill = " #ddd"
118
+ )
119
+
120
+ ```
121
+
122
+ @: callout (info)
123
+ All other information is taken automatically from the _ ApiProjectConf_ .
124
+ @:@
125
+
126
+ ## Standard Features:
127
+
128
+ With the API Creator you get a lot of features out of the box.
129
+
130
+ #### README
131
+ If you have a read me in your base path (` config.basePath / "README.md ` ),
132
+ we integrate it automatically in the documentation - as a visible part.
133
+
134
+ #### CHANGELOG
135
+ If you have a change log in your base path (` config.basePath / "CHANGELOG.md ` ),
136
+ we integrate it automatically in the documentation - as a collapsed part.
137
+
138
+ #### General Variables
139
+ General variables that are supported in any Process- and/or ExternalTask-Worker are documented - in a collapsed part.
140
+ By default, the following Variables are supported:
141
+
142
+ ``` scala mdoc
143
+ enum InputParams :
144
+ // mocking
145
+ case servicesMocked
146
+ case mockedWorkers
147
+ case outputMock
148
+ case outputServiceMock
149
+ // mapping
150
+ case manualOutMapping
151
+ case outputVariables
152
+ case handledErrors
153
+ case regexHandledErrors
154
+ // authorization
155
+ case impersonateUserId
156
+ // ..
157
+ end InputParams
158
+ ```
159
+ That expects that your implementation can handle these variables.
160
+
161
+ @: callout (info)
162
+ If you are using our Workers they are supported out of the box!
163
+ @:@
164
+
165
+ If you only want to support some of them, you can override them:
166
+
167
+ ``` scala
168
+ override def supportedVariables : Seq [InputParams ] = Seq (
169
+ servicesMocked,
170
+ outputMock,
171
+ outputServiceMock,
172
+ handledErrors,
173
+ regexHandledErrors,
174
+ impersonateUserId
175
+ )
176
+ ```
46
177
178
+ #### Jira Tickets
179
+ We replace configured JIRA Ticket pattern with its URL.
180
+
181
+ Configuration:
182
+ ``` scala
183
+ override protected def apiConfig : ApiConfig =
184
+ super .apiConfig
185
+ .withJiraUrls(JIRA_PROJECT -> JIRA_URL )
47
186
```
48
187
188
+ - JIRA_PROJECT: The shortcut for the JIRA Project (prefix of jira ticket number).
189
+ - JIRA_URL: The base URL to browse JIRA tickets, e.g. ` https://issue.mycompany.ch/browse ` .
190
+
191
+ Now in the Change Log all occurrences of the regex ` JIRA_PROJECT-(\\d+) ` (-> ` JIRA_TICKET ` )
192
+ will be replaced with ` [JIRA_TICKET]($url/JIRA_TICKET) ` .
193
+ In the generated documentation this is a link to the according Jira ticket.
194
+
195
+ #### BPMN diagrams
196
+ BPMN- and DMN diagrams are integrated in the documentation.
197
+
198
+ They are referenced in the OpenApi.html and can be opened directly from there.
199
+ There are 3 ways:
200
+
201
+ 1 . As an image in the documentation
202
+ 2 . As a link to download the BPMN-/ DMN-diagram
203
+ 3 . As SVG image to show the diagram in the browser (you can zoom in and out)
49
204
50
205
@: callout (info)
51
- Documentation of ` companyDescr ` will be in every API documentation. So ones per project .
206
+ This is only working if you upload your BPMN- and DMN-diagrams to a Web server (via WebDAV) .
52
207
@:@
0 commit comments