This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static com.tngtech.archunit.library.GeneralCodingRules.NO_CLASSES_SHOULD_THROW_GENERIC_EXCEPTIONS; | |
import static com.tngtech.archunit.library.GeneralCodingRules.NO_CLASSES_SHOULD_USE_JODATIME; | |
... | |
@ArchTest | |
static ArchRule no_generic_exceptions = NO_CLASSES_SHOULD_THROW_GENERIC_EXCEPTIONS; | |
@ArchTest | |
static ArchRule do_not_use_jodatime = NO_CLASSES_SHOULD_USE_JODATIME; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.viadee.architecture.archunit.rules; | |
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; | |
import org.springframework.web.bind.annotation.RestController; | |
import com.tngtech.archunit.lang.ArchRule; | |
public class TeamArchRules { | |
/** Architecture Rule for REST controller conventions */ | |
public static ArchRule CONTROLLERS_SHOULD_BE_SUFFIXED_AND_LOCATED = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<!-- Note: deactivate debug logs for ArchUnit to prevent OutOfMemory errors on windows terminals. --> | |
<include resource="org/springframework/boot/logging/logback/defaults.xml"/> | |
<include resource="org/springframework/boot/logging/logback/console-appender.xml" /> | |
<root level="INFO"> | |
<appender-ref ref="CONSOLE" /> | |
</root> | |
<logger name="com.tngtech.archunit" level="WARN"/> | |
</configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@AnalyzeClasses( | |
packages = " de.viadee.architecture.archunit", | |
importOptions = { | |
ImportOption.DoNotIncludeTests.class, | |
ImportOption.DoNotIncludeJars.class, | |
ImportOption.DoNotIncludeArchives.class }) | |
public class MyTest { | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ArchTest | |
private static ArchRule controllers_should_be_suffixed = | |
freeze( | |
classes() | |
.that().areAnnotatedWith(RestController.class) | |
.should().haveSimpleNameEndingWith("Controller") | |
.andShould().resideInAPackage("..controller..") | |
.because("controllers must use business services instead of the persistence layer") | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping("/api/users") | |
@Tag(name = "User API", description = "User Management API") | |
interface UserApi { | |
@GetMapping | |
@ResponseStatus(code = HttpStatus.OK) | |
List<User> findAll(); | |
@GetMapping("/{id}") | |
@ResponseStatus(code = HttpStatus.OK) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
public class UserApiController implements UserApi { | |
private Map<String, User> users = new HashMap<>(); | |
@Override | |
public List<User> findAll() { | |
return new ArrayList<>(users.values()); | |
} | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springdoc</groupId> | |
<artifactId>springdoc-openapi-ui</artifactId> | |
<version>1.5.4</version> | |
</dependency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OpenAPIDefinition( | |
info = @Info( | |
title = "API Roundtrip Demo (viadee.de)", | |
description = "An API showcase demonstrating how to automatically generate an openapi spec and client based on this.", | |
version = "0.1.0", | |
contact = @Contact( | |
name = "Cloud @viadee", | |
url = "https://www.viadee.de", | |
email = "[email protected]"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
springdoc.writer-with-default-pretty-printer=true |