Skip to content

Commit 66b1e59

Browse files
author
Joern Wellniak
committed
ADR
1 parent 4505190 commit 66b1e59

2 files changed

Lines changed: 127 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# ADR-009: Use Google Coding Rules with Exception for Indentation
2+
3+
Date: 2025-10-23
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
The project aims to maintain a consistent and widely recognized coding style to improve code
12+
readability and collaboration. Google Coding Rules provide a comprehensive and well-documented
13+
standard for Java development. However, the team prefers using tabs instead of spaces for
14+
indentation to allow developers to customize their viewing preferences in their IDEs.
15+
16+
## Decision
17+
18+
The project will adopt Google Coding Rules as the standard coding style, with the exception of using
19+
tabs (`\t`) instead of spaces for indentation.
20+
21+
## Consequences
22+
23+
- **Positive**:
24+
- Ensures a consistent and widely recognized coding style.
25+
- Allows developers to adjust tab width in their IDEs for personal preference.
26+
- Simplifies onboarding for developers familiar with Google Coding Rules.
27+
28+
- **Negative**:
29+
- Requires configuring tools and IDEs to enforce the use of tabs.
30+
- May require additional effort to ensure compliance with the exception.
31+
32+
## Implementation
33+
34+
1. Configure the project to use Google Coding Rules:
35+
- Add the `google-java-format` plugin to the build system (e.g., Maven):
36+
```xml
37+
<plugin>
38+
<groupId>com.github.sherter.google-java-format</groupId>
39+
<artifactId>google-java-format-maven-plugin</artifactId>
40+
<version>1.15.0</version>
41+
</plugin>
42+
```
43+
44+
2. Modify the formatter configuration to use tabs for indentation:
45+
- Use the `--aosp` flag or customize the formatter to replace spaces with tabs.
46+
47+
3. Update IDE settings to enforce tabs for indentation:
48+
- For IntelliJ IDEA:
49+
- Go to `Preferences > Code Style > Java`.
50+
- Set "Use tab character" for indentation.
51+
52+
4. Document this decision in the project's coding standards to ensure team-wide adherence.
53+
54+
5. Add a pre-commit hook or CI check to validate compliance with the coding rules.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# ADR-010: Use OpenAPI Swagger Annotations for All REST API Endpoints
2+
3+
Date: 2025-10-24
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
To ensure that the REST API is well-documented and easily understandable for developers and external
12+
consumers, it is essential to provide clear and standardized documentation. OpenAPI (Swagger)
13+
annotations allow for the automatic generation of API documentation, which can be visualized using
14+
tools like Swagger UI. Currently, not all endpoints are annotated, and OpenAPI is not fully enabled
15+
in the Spring Boot application.
16+
17+
## Decision
18+
19+
All REST API endpoints in the project will be annotated with OpenAPI Swagger annotations.
20+
Additionally, OpenAPI will be enabled in the Spring Boot application to generate and serve the API
21+
documentation.
22+
23+
## Consequences
24+
25+
- **Positive**:
26+
- Provides a standardized and comprehensive API documentation.
27+
- Simplifies integration for external consumers by offering a clear contract.
28+
- Reduces manual effort in maintaining API documentation.
29+
30+
- **Negative**:
31+
- Requires additional effort to annotate all existing endpoints.
32+
- Developers need to be familiar with OpenAPI annotations.
33+
34+
## Implementation
35+
36+
1. Add the `springdoc-openapi` dependency to the `pom.xml`:
37+
```xml
38+
<dependency>
39+
<groupId>org.springdoc</groupId>
40+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
41+
<version>2.1.0</version>
42+
</dependency>
43+
```
44+
45+
2. Annotate all REST API endpoints with OpenAPI annotations:
46+
```java
47+
@RestController
48+
@RequestMapping("/example")
49+
@Tag(name = "Example", description = "Example API")
50+
public class ExampleController {
51+
52+
@Operation(summary = "Get example data", description = "Fetches example data by ID")
53+
@ApiResponses(value = {
54+
@ApiResponse(responseCode = "200", description = "Successful operation"),
55+
@ApiResponse(responseCode = "404", description = "Example not found")
56+
})
57+
@GetMapping("/{id}")
58+
public ResponseEntity<ExampleDto> getExample(@PathVariable Long id) {
59+
// Implementation here
60+
return ResponseEntity.ok(new ExampleDto());
61+
}
62+
}
63+
```
64+
65+
3. Enable OpenAPI in the Spring Boot application:
66+
- No additional configuration is required as `springdoc-openapi` automatically enables Swagger
67+
UI at `/swagger-ui.html`.
68+
69+
4. Document this decision in the project's development guidelines to ensure all new endpoints are
70+
annotated.
71+
72+
5. Verify the generated documentation by accessing the Swagger UI at
73+
`http://localhost:8080/swagger-ui.html`.

0 commit comments

Comments
 (0)