Skip to content

Commit

Permalink
Spring integration lib (#116)
Browse files Browse the repository at this point in the history
Co-authored-by: nsimonides <[email protected]>
Co-authored-by: Jerre van Veluw <[email protected]>
  • Loading branch information
3 people authored Oct 30, 2024
1 parent 50f8b9a commit 6c01687
Show file tree
Hide file tree
Showing 126 changed files with 4,320 additions and 327 deletions.
4 changes: 2 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: *

build:
./mvnw clean verify && \
(cd gradle-ktor && ./gradlew clean build) && \
./mvnw clean test && \
(cd gradle-ktor && ./gradlew clean test) && \
(cd npm-typescript && npm run build)

clean:
Expand Down
3 changes: 2 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

Here you can find examples of how to use:

* [A custom Emitter](maven-spring-custom/README.md)
* [The Gradle Plugin](gradle-ktor/README.md)
* [The Maven Plugin](maven-spring-compile/README.md)
* [And convert an OpenAPI Specification](maven-spring-convert/README.md)
* [A custom Emitter](maven-spring-custom/README.md)
* [The Spring integration](maven-spring-integration/README.md)

## Integration

Expand Down
2 changes: 1 addition & 1 deletion examples/gradle-ktor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
implementation(libs.bundles.ktor)
implementation(libs.jackson)
implementation(libs.logback)
testImplementation(kotlin("test"))
testImplementation(libs.kotlin.test)
testImplementation(libs.bundles.ktor.test)
}

Expand Down
1 change: 1 addition & 0 deletions examples/gradle-ktor/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ logback = "1.4.14"
kotlinx_serialization = "1.7.0"

[libraries]
kotlin_test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
ktor_server_core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" }
ktor_server_netty = { module = "io.ktor:ktor-server-netty-jvm", version.ref = "ktor" }
ktor_server_content_negotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor" }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package community.flock.wirespec.example.gradle.app
package community.flock.wirespec.example.maven.custom.app

import community.flock.wirespec.example.gradle.app.todo.LiveTodoRepository
import community.flock.wirespec.example.gradle.app.todo.todoModule
import community.flock.wirespec.example.maven.custom.app.todo.LiveTodoRepository
import community.flock.wirespec.example.maven.custom.app.todo.todoModule
import io.ktor.serialization.kotlinx.json.json
import io.ktor.server.application.Application
import io.ktor.server.application.install
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.common
package community.flock.wirespec.example.maven.custom.app.common

interface Converter<DOMAIN : Any, DTO : Any> :
Internalizer<DTO, DOMAIN>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.common
package community.flock.wirespec.example.maven.custom.app.common

fun interface Consumer<DTO : Any, DOMAIN : Any> {
fun DTO.consume(): DOMAIN
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.common
package community.flock.wirespec.example.maven.custom.app.common

interface Value<T : Any> {
val value: T
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.common
package community.flock.wirespec.example.maven.custom.app.common

import community.flock.wirespec.kotlin.Wirespec
import io.ktor.client.HttpClient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package community.flock.wirespec.example.gradle.app.exception
package community.flock.wirespec.example.maven.custom.app.exception

import community.flock.wirespec.example.gradle.app.todo.Todo
import community.flock.wirespec.example.maven.custom.app.todo.Todo

sealed class AppException(override val message: String) : RuntimeException(message)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.exception
package community.flock.wirespec.example.maven.custom.app.exception

import community.flock.wirespec.generated.kotlin.Error

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package community.flock.wirespec.example.gradle.app.todo
package community.flock.wirespec.example.maven.custom.app.todo

import community.flock.wirespec.example.gradle.app.exception.TodoNotFoundException
import community.flock.wirespec.example.maven.custom.app.exception.TodoNotFoundException

class LiveTodoRepository : TodoRepository {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package community.flock.wirespec.example.gradle.app.todo
package community.flock.wirespec.example.maven.custom.app.todo

import community.flock.wirespec.example.gradle.app.common.Value
import community.flock.wirespec.example.maven.custom.app.common.Value

data class Todo(
val id: Id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package community.flock.wirespec.example.gradle.app.todo
package community.flock.wirespec.example.maven.custom.app.todo

import community.flock.wirespec.example.gradle.app.todo.TodoConsumer.consume
import community.flock.wirespec.example.gradle.app.todo.TodoProducer.produce
import community.flock.wirespec.example.maven.custom.app.exception.TodoIdNotValidException
import community.flock.wirespec.example.maven.custom.app.todo.TodoConsumer.consume
import community.flock.wirespec.example.maven.custom.app.todo.TodoProducer.produce
import community.flock.wirespec.generated.kotlin.DeleteTodoByIdEndpoint
import community.flock.wirespec.generated.kotlin.GetTodoByIdEndpoint
import community.flock.wirespec.generated.kotlin.GetTodosEndpoint
Expand All @@ -27,7 +28,7 @@ class TodoHandler(liveTodoRepository: TodoRepository) : TodoApi {

override suspend fun getTodoById(request: GetTodoByIdEndpoint.Request): GetTodoByIdEndpoint.Response200 =
request.path.id
.also { if (!it.validate()) throw community.flock.wirespec.example.gradle.app.exception.TodoIdNotValidException(
.also { if (!it.validate()) throw TodoIdNotValidException(
it.value
)
}
Expand All @@ -46,7 +47,7 @@ class TodoHandler(liveTodoRepository: TodoRepository) : TodoApi {

override suspend fun deleteTodoById(request: DeleteTodoByIdEndpoint.Request): DeleteTodoByIdEndpoint.Response200 =
request.path.id
.also { if (!it.validate()) throw community.flock.wirespec.example.gradle.app.exception.TodoIdNotValidException(
.also { if (!it.validate()) throw TodoIdNotValidException(
it.value
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.todo
package community.flock.wirespec.example.maven.custom.app.todo

interface HasTodoRepository {
val todoRepository: TodoRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package community.flock.wirespec.example.gradle.app.todo
package community.flock.wirespec.example.maven.custom.app.todo

import community.flock.wirespec.example.gradle.app.common.Serialization
import community.flock.wirespec.example.maven.custom.app.common.Serialization
import community.flock.wirespec.generated.kotlin.DeleteTodoByIdEndpoint
import community.flock.wirespec.generated.kotlin.GetTodoByIdEndpoint
import community.flock.wirespec.generated.kotlin.GetTodosEndpoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.todo
package community.flock.wirespec.example.maven.custom.app.todo

interface TodoService : HasTodoRepository

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package community.flock.wirespec.example.gradle.app.todo
package community.flock.wirespec.example.maven.custom.app.todo

import community.flock.wirespec.example.gradle.app.common.Consumer
import community.flock.wirespec.example.gradle.app.common.Producer
import community.flock.wirespec.example.maven.custom.app.common.Consumer
import community.flock.wirespec.example.maven.custom.app.common.Producer
import community.flock.wirespec.generated.kotlin.PotentialTodoDto
import community.flock.wirespec.generated.kotlin.TodoDto
import community.flock.wirespec.generated.kotlin.TodoId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package community.flock.wirespec.example.gradle.app.user
package community.flock.wirespec.example.maven.custom.app.user

import community.flock.wirespec.example.gradle.app.user.UserConverter.internalize
import community.flock.wirespec.example.maven.custom.app.user.UserConverter.internalize
import community.flock.wirespec.generated.kotlin.DeleteUserByNameEndpoint
import community.flock.wirespec.generated.kotlin.GetUserByNameEndpoint
import community.flock.wirespec.generated.kotlin.GetUsersEndpoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package community.flock.wirespec.example.gradle.app.user
package community.flock.wirespec.example.maven.custom.app.user

import community.flock.wirespec.example.gradle.app.common.Serialization
import community.flock.wirespec.example.gradle.app.common.WirespecClient
import community.flock.wirespec.example.maven.custom.app.common.Serialization
import community.flock.wirespec.example.maven.custom.app.common.WirespecClient
import community.flock.wirespec.generated.kotlin.DeleteUserByNameEndpoint
import community.flock.wirespec.generated.kotlin.GetUserByNameEndpoint
import community.flock.wirespec.generated.kotlin.GetUsersEndpoint
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package community.flock.wirespec.example.maven.custom.app.user

data class User(val name: String)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.user
package community.flock.wirespec.example.maven.custom.app.user

interface HasUserAdapter {
val userAdapter: UserAdapter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package community.flock.wirespec.example.gradle.app.user
package community.flock.wirespec.example.maven.custom.app.user

import community.flock.wirespec.example.gradle.app.common.Converter
import community.flock.wirespec.example.maven.custom.app.common.Converter
import community.flock.wirespec.generated.kotlin.UserDto

object UserConverter : Converter<User, UserDto> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.user
package community.flock.wirespec.example.maven.custom.app.user

interface UserService : HasUserAdapter

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package community.flock.wirespec.example.gradle.app
package community.flock.wirespec.example.maven.custom.app

import community.flock.wirespec.example.gradle.app.todo.LiveTodoRepository
import community.flock.wirespec.example.gradle.app.todo.todoModule
import community.flock.wirespec.example.maven.custom.app.todo.LiveTodoRepository
import community.flock.wirespec.example.maven.custom.app.todo.todoModule
import io.ktor.client.request.get
import io.ktor.client.statement.bodyAsText
import io.ktor.http.HttpStatusCode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.todo
package community.flock.wirespec.example.maven.custom.app.todo

import org.junit.Test
import kotlin.test.assertTrue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.user
package community.flock.wirespec.example.maven.custom.app.user

import community.flock.wirespec.generated.kotlin.DeleteUserByNameEndpoint
import community.flock.wirespec.generated.kotlin.GetUserByNameEndpoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.user
package community.flock.wirespec.example.maven.custom.app.user

import org.junit.Test
import kotlin.test.assertEquals
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app;
package community.flock.wirespec.example.maven.custom.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.common;
package community.flock.wirespec.example.maven.custom.app.common;

public interface Converter<I, E> extends Internalizer<E, I>, Externalizer<I, E> {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.common;
package community.flock.wirespec.example.maven.custom.app.common;

public interface Externalizer<I, E> {
E externalize(I domain);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.common;
package community.flock.wirespec.example.maven.custom.app.common;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package community.flock.wirespec.example.gradle.app.common;
package community.flock.wirespec.example.maven.custom.app.common;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import community.flock.wirespec.example.gradle.app.exception.SerializationException;
import community.flock.wirespec.example.maven.custom.app.exception.SerializationException;
import community.flock.wirespec.java.Wirespec;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.common;
package community.flock.wirespec.example.maven.custom.app.common;

import community.flock.wirespec.java.Wirespec.RawRequest;
import community.flock.wirespec.java.Wirespec.RawResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.config;
package community.flock.wirespec.example.maven.custom.app.config;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.exception;
package community.flock.wirespec.example.maven.custom.app.exception;

public sealed class AppException extends RuntimeException permits Conflict, NotFound, CallInterrupted, SerializationException {
public AppException(String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.exception;
package community.flock.wirespec.example.maven.custom.app.exception;

public final class CallInterrupted extends AppException {
public CallInterrupted(Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.exception;
package community.flock.wirespec.example.maven.custom.app.exception;

public sealed class Conflict extends AppException {
public Conflict(String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.exception;
package community.flock.wirespec.example.maven.custom.app.exception;

public sealed class NotFound extends AppException {
public NotFound(String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.exception;
package community.flock.wirespec.example.maven.custom.app.exception;

public final class SerializationException extends AppException {
public SerializationException(Exception cause) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.todo;
package community.flock.wirespec.example.maven.custom.app.todo;

import community.flock.wirespec.generated.java.Todo;
import community.flock.wirespec.generated.java.TodoId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package community.flock.wirespec.example.gradle.app.todo;
package community.flock.wirespec.example.maven.custom.app.todo;

import community.flock.wirespec.example.gradle.app.exception.NotFound;
import community.flock.wirespec.example.maven.custom.app.exception.NotFound;
import community.flock.wirespec.generated.java.Error;
import community.flock.wirespec.generated.java.Todo;
import community.flock.wirespec.generated.java.TodoId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.todo;
package community.flock.wirespec.example.maven.custom.app.todo;

import community.flock.wirespec.generated.java.Todo;
import community.flock.wirespec.generated.java.TodoId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.todo;
package community.flock.wirespec.example.maven.custom.app.todo;

import community.flock.wirespec.generated.java.Todo;
import community.flock.wirespec.generated.java.TodoId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package community.flock.wirespec.example.gradle.app.user;
package community.flock.wirespec.example.maven.custom.app.user;

import community.flock.wirespec.example.gradle.app.exception.CallInterrupted;
import community.flock.wirespec.example.gradle.app.exception.Conflict;
import community.flock.wirespec.example.gradle.app.exception.NotFound;
import community.flock.wirespec.example.maven.custom.app.exception.CallInterrupted;
import community.flock.wirespec.example.maven.custom.app.exception.Conflict;
import community.flock.wirespec.example.maven.custom.app.exception.NotFound;
import community.flock.wirespec.generated.java.DeleteUserByNameEndpoint;
import community.flock.wirespec.generated.java.GetUserByNameEndpoint;
import community.flock.wirespec.generated.java.GetUsersEndpoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package community.flock.wirespec.example.gradle.app.user;
package community.flock.wirespec.example.maven.custom.app.user;

import community.flock.wirespec.example.gradle.app.common.WirespecSerializer;
import community.flock.wirespec.example.gradle.app.common.WirespecTransporter;
import community.flock.wirespec.example.maven.custom.app.common.WirespecSerializer;
import community.flock.wirespec.example.maven.custom.app.common.WirespecTransporter;
import community.flock.wirespec.generated.java.DeleteUserByNameEndpoint;
import community.flock.wirespec.generated.java.GetUserByNameEndpoint;
import community.flock.wirespec.generated.java.GetUsersEndpoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package community.flock.wirespec.example.maven.custom.app.user;

public record User(String name) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.user;
package community.flock.wirespec.example.maven.custom.app.user;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package community.flock.wirespec.example.gradle.app.user;
package community.flock.wirespec.example.maven.custom.app.user;

import community.flock.wirespec.generated.java.DeleteUserByNameEndpoint;
import community.flock.wirespec.generated.java.GetUserByNameEndpoint;
Expand Down
Loading

0 comments on commit 6c01687

Please sign in to comment.