REST API - OpenAPI documentation generation
========
This project generates a single openapi.json containing the OpeanAPI documentation of the Engine Rest API.
Aligned with OpeanAPI specification version [3.0.2](https://github.com/OAI/OpenAPI-Specification/blob/3.0.2/versions/3.0.2.md).
# Table of Contents
1. [Build and phases](#build-and-phases)
2. [Contribution](#contribution)
+ [main.ftl](#mainftl)
+ [utils](#utils)
+ [models](#models)
+ [paths](#paths)
+ [commons](#commons)
+ [sorting](#sorting)
+ [pagination](#pagination)
+ [reuse](#reuse)
+ [descriptions](#descriptions)
+ [formats](#formats)
+ [nullable](#nullable)
+ [examples](#examples)
3. [Reviews](#reviews)
## Build and phases
To build the artifact run: `mvn clean install`
The build contains:
* Generation of a formatted openapi.json file by parsing the [templates](./src/main/templates)
* Validation of the generated file against [schema.json](./src/main/openapi/schema.json)
* Generation of a java client from the openapi.json file
* Run of smoke tests against that client (the tests use [WireMock](http://wiremock.org/docs/))
## Contribution
NOTE: Please follow the next step to get familiar with the structure and the instructions that follow.
For the generation of the documentation, we use the [Freemarker](https://freemarker.apache.org/docs/index.html) templating language.
The structure of the template is:
```
+--main.ftl
+--lib
| +--utils.ftl
| +--commons
| | +--pagination-params.ftl
| | +--process-instance-query-params.ftl
| | +--sort-params.ftl
| | +--sort-props.ftl
+--models
| +--org/camunda/bpm/engine/rest/dto
| | +--ExceptionDto.ftl
| | +--history
| | | +--HistoricProcessInstanceQueryDto.ftl
| | +--repository
| | | +--DeploymentDto.ftl
| | | +--ProcessDefinitionDto.ftl
| | +--runtime
| | | +--ActivityInstanceDto.ftl
+--paths
| +--deployment
| | +--create
| | | +--post.ftl
| +--process-instance
| | +--get.ftl
| | +--suspended
| | | +--put.ftl
| | +--{id}
| | | +--delete.ftl
| | | +--variables
| | | | +--{varName}
| | | | | +--data
| | | | | | +--get.ftl
| | | | | | +--post.ftl
| | | | | +--delete.ftl
```
### main.ftl
The `main.ftl` contains the general information of the OpenAPI doc:
* OpenAPI spec version
* info
* externalDocs
* servers (default and named)
* tags (each resource has a tag)
* Sub-resources should have the parent tag as prefix (e.g. `Task` and `Task Attachment`)
* wrap up of paths and components
By parsing this file end .json file is generated.
### utils
Contains all of the [macros](https://freemarker.apache.org/docs/ref_directive_macro.html) used in paths and models:
* `parameter` (used in paths)
* `property` (used in paths and models)
* `requestBody` (used in paths)
* `response` (used in paths)
Try to get familiar with them as they are heavily used in the templates.
Keep in mind that in some situations, it is fine not to use them, if the endpoint/dto is too complex, for example.
Feel free to add missing parameters to the macros, however, do not forget to reflect your changes to all usages of the macros.
Some parameters are required (`name` and `description` in most of the cases),
and some need to be provided if necessary (nice to have - `minimum`,`defaultValue`, `deprecated`).
### models
This folder contains all of the DTOs used in the request and response bodies. Instructions:
* use the name and package structure of the Rest DTOs when possible
([org.camunda.bpm.engine.rest.dto.ExceptionDto.java](https://github.com/camunda/camunda-bpm-platform/blob/master/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/ExceptionDto.java) -->
[org/camunda/bpm/engine/rest/dto/ExceptionDto.ftl](https://github.com/camunda/camunda-bpm-platform/blob/master/engine-rest/engine-rest-openapi/src/main/templates/models/org/camunda/bpm/engine/rest/dto/ExceptionDto.ftl))
Keep the properties of OpenAPI doc as close as possible to the Java DTOs and add explicit description whenever a property is not applicable to a certain endpoint (e.g. [PUT /process-instance/suspended](https://github.com/camunda/camunda-bpm-platform/blob/master/engine-rest/engine-rest-openapi/src/main/templates/paths/process-instance/suspended/put.ftl))
* the definitions of the models are resolved automatically via the folder structure. The `/models` directory should contain only the models that are used in the documentation, any additional files (macros and reusable files) should go to [commons](#commons), do not create empty folders. The models are ordered lexicographically.
* use the [utils](#utils) from the previous section when possible.
* use the `dto` macro to define a DTO
* in case of a DTO hierarchy (`TriggerVariableValueDto extends VariableValueDto`), the `dto` macro provides an `extends`
attribute that makes use of the `allOf` OpenAPI syntax - [example](https://github.com/camunda/camunda-bpm-platform/blob/392d98b61e5e0eff3e1dad0ee15a5ad986e0d93c/engine-rest/engine-rest-openapi/src/main/templates/models/org/camunda/bpm/engine/rest/dto/runtime/TriggerVariableValueDto.ftl#L2-L19).
* the `property` macros should be nested inside the `dto` macro
* in case the response can be two DTOs depending on request parameter (example - [message correlation](https://docs.camunda.org/manual/develop/reference/rest/message/post-message/#result) and responses `MessageCorrelationResultDto` or `MessageCorrelationResultWithVariableDto` (extending `MessageCorrelationResultDto`)), please use the DTO for the response that contains all of the properties (in the correlation case - `MessageCorrelationResultWithVariableDto`) even some are not applicable for all of the responses, and make sure to document which properties are not applicable in which use cases. (In some use cases `oneOf` approach might be applicable together with `discrimitator` ([spec](https://github.com/OAI/OpenAPI-Specification/blob/3.0.2/versions/3.0.2.md#discriminator-object)), please test this additionally as the clients might have problems to be generated in this approach.)
* for the `property` macros DO NOT forget to put `last = true` param for the last property, that will take care for the commas in the json file.
* the DTOs that have sorting or pagination properties should use the [common templates](#commons).
### paths
Contains the endpoints definitions of the Rest API. Instructions:
* each resource has its own folder under /paths (e.g. `/process-instance`, `/deployment`)
* the path of the endpoint is resolved to a folder structure (e.g. get process instance count `GET /process-instance/count` goes to `/paths/process-instance/count`).
NOTE: The endpoints' paths are automatically resolved from the folder structure, please keep the file structure of `/paths` clean, without any additional files, different than the endpoint definitions (for example the reusable templates should go in [commons](#commons), do not create empty folders and so on).
The endpoints' paths are ordered lexicographically.
* the dynamic endpoints should be structured with brakes like `process-instance/{id}/variables/{varName}/data`,
then the path parameters (`id` and `varName`) should always be included in the endpoint definition and marked as `required`.
* endpoints that are almost similar but have a different paths (e.g. [Get Activity Instance Statistics](https://docs.camunda.org/manual/7.12/reference/rest/process-definition/get-activity-statistics/)) needs to be separated in different files. A unique `operationId` should be assigned to each of them. You can consider adding the common parts of the endpoints in [lib/commons](#commons).
* the name of the method's request (GET, POST, PUT, DELETE, OPTIONS) is the name of the template file (get.ftl, post.frl, etc.).
* each endpoint definition has a unique `operationId` that will be used for the generation of clients.
* for `async` endpoints make sure to add `Operation` suffix to prevent collisions in generated C# clients, e.g. `setExternalTaskRetriesAsync` -> `setExt
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Camunda Platform 7 是一个灵活的工作流程和流程自动化框架。它的核心是在 Java 虚拟机中运行的原生 BPMN 2.0 流程引擎。它可以嵌入到任何 Java 应用程序和任何运行时容器中。它与 Java EE 6 集成,与 Spring 框架完美匹配。在流程引擎之上,您可以从一系列工具中进行选择,用于人工工作流程管理、操作和监控。
资源推荐
资源详情
资源评论
收起资源包目录
一个灵活的工作流程和流程自动化框架 它的核心是在 Java 虚拟机中运行的原生 BPMN 2.0 流程引擎 (2000个子文件)
index.html 38B
MockProvider.java 186KB
ProcessInstanceRestServiceInteractionTest.java 185KB
ProcessDefinitionRestServiceInteractionTest.java 174KB
TaskRestServiceInteractionTest.java 153KB
CaseExecutionRestServiceInteractionTest.java 146KB
CaseInstanceRestServiceInteractionTest.java 95KB
TaskRestServiceQueryTest.java 90KB
DeploymentRestServiceInteractionTest.java 89KB
HistoricTaskInstanceRestServiceQueryTest.java 85KB
HistoricProcessInstanceRestServiceQueryTest.java 80KB
FilterRestServiceInteractionTest.java 78KB
ExternalTaskRestServiceInteractionTest.java 77KB
MigrationRestServiceInteractionTest.java 74KB
ExecutionRestServiceInteractionTest.java 72KB
JobRestServiceInteractionTest.java 65KB
JobDefinitionRestServiceInteractionTest.java 64KB
MessageRestServiceTest.java 57KB
HistoricCaseInstanceRestServiceQueryTest.java 55KB
ProcessInstanceRestServiceQueryTest.java 55KB
AuthorizationRestServiceInteractionTest.java 54KB
CaseExecutionRestServiceQueryTest.java 54KB
TaskVariableRestResourceInteractionTest.java 50KB
TaskVariableLocalRestResourceInteractionTest.java 50KB
VariableInstanceRestServiceQueryTest.java 50KB
HistoricDetailRestServiceQueryTest.java 47KB
ExecutionRestServiceQueryTest.java 42KB
CaseInstanceRestServiceQueryTest.java 39KB
HistoricVariableInstanceRestServiceQueryTest.java 38KB
ProcessEngineRestServiceTest.java 37KB
TenantRestServiceInteractionTest.java 36KB
JobRestServiceQueryTest.java 35KB
HistoricActivityInstanceRestServiceQueryTest.java 35KB
DecisionDefinitionRestServiceInteractionTest.java 34KB
HistoricExternalTaskLogRestServiceQueryTest.java 34KB
UserRestServiceInteractionTest.java 32KB
HistoricDecisionInstanceRestServiceQueryTest.java 32KB
HistoricJobLogRestServiceQueryTest.java 32KB
ModificationRestServiceInteractionTest.java 32KB
GroupRestServiceInteractionTest.java 31KB
CaseDefinitionRestServiceInteractionTest.java 30KB
HistoricCaseActivityInstanceRestServiceQueryTest.java 29KB
ExternalTaskRestServiceQueryTest.java 28KB
ProcessDefinitionRestServiceQueryTest.java 27KB
HistoricIncidentRestServiceQueryTest.java 27KB
SequentialMultiInstanceCompensationScenarioTest.java 26KB
ParallelMultiInstanceCompensationScenarioTest.java 26KB
HistoricDecisionInstanceRestServiceInteractionTest.java 26KB
RestartProcessInstanceRestServiceTest.java 26KB
HistoricProcessInstanceRestServiceInteractionTest.java 26KB
LdapIdentityProviderSession.java 24KB
JsonSerializationTest.java 24KB
CatchErrorFromProcessApplicationTest.java 24KB
JobDefinitionRestServiceQueryTest.java 23KB
DecisionDefinitionRestServiceQueryTest.java 23KB
HistoricTaskReportRestServiceTest.java 22KB
CamundaEventingIT.java 22KB
HistoricProcessInstanceRestServiceReportTest.java 22KB
IncidentRestServiceQueryTest.java 21KB
XmlSerializationTest.java 21KB
HistoricIdentityLinkLogRestServiceQueryTest.java 20KB
DecisionRequirementsDefinitionRestServiceQueryTest.java 19KB
HistoricVariableInstanceRestServiceInteractionTest.java 19KB
LdapUserQueryTest.java 18KB
HistoricDetailRestServiceInteractionTest.java 18KB
HistoricActivityStatisticsRestServiceQueryTest.java 18KB
CaseDefinitionRestServiceQueryTest.java 18KB
SignalRestServiceTest.java 18KB
StatisticsRestTest.java 17KB
FetchAndLockRestServiceInteractionTest.java 17KB
VariableInstanceRestServiceInteractionTest.java 17KB
LdapTestEnvironment.java 16KB
FetchAndLockHandlerTest.java 16KB
CleanableHistoricProcessInstanceReportServiceTest.java 15KB
HistoricBatchRestServiceInteractionTest.java 15KB
CleanableHistoricDecisionInstanceReportServiceTest.java 15KB
DeploymentRestServiceQueryTest.java 15KB
CallActivityContextSwitchTest.java 15KB
CleanableHistoricCaseInstanceReportServiceTest.java 15KB
UserOperationLogRestServiceQueryTest.java 15KB
ConnectProcessEnginePluginTest.java 14KB
DecisionRequirementsDefinitionRestServiceInteractionTest.java 14KB
RestIT.java 14KB
FilterRestServiceQueryTest.java 13KB
MetricsRestServiceInteractionTest.java 13KB
BatchRestServiceInteractionTest.java 13KB
EventSubscriptionRestServiceQueryTest.java 12KB
BatchRestServiceStatisticsTest.java 12KB
HistoricBatchRestServiceQueryTest.java 11KB
TwoLevelNestedNonInterruptingEventSubprocessScenarioTest.java 11KB
PaDataFormatConfiguratorTest.java 11KB
EngineDataGenerator.java 11KB
LdapGroupQueryTest.java 11KB
ConditionRestServiceTest.java 11KB
JsonValueTest.java 11KB
TaskFilterTest.java 11KB
TelemetryRestServiceTest.java 11KB
HistoryCleanupRestServiceInteractionTest.java 11KB
CamundaBpmProperties.java 10KB
XmlValueTest.java 10KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6749
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功