diff options
author | zaaarf <me@zaaarf.foo> | 2024-01-23 10:57:46 +0100 |
---|---|---|
committer | zaaarf <me@zaaarf.foo> | 2024-01-23 10:57:46 +0100 |
commit | 47b45e2e42241c59011276572181c6efd016a378 (patch) | |
tree | d0c7336eed3918d0ab3f97687f87ba8b3fe1226e /src/main/java/foo/zaaarf/routecompass/Route.java | |
parent | 729bf6f2a752bf16724401eed5f470276fd38a39 (diff) |
feat: request/response dto support0.1.1
Diffstat (limited to 'src/main/java/foo/zaaarf/routecompass/Route.java')
-rw-r--r-- | src/main/java/foo/zaaarf/routecompass/Route.java | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/main/java/foo/zaaarf/routecompass/Route.java b/src/main/java/foo/zaaarf/routecompass/Route.java index db1492a..7c7c091 100644 --- a/src/main/java/foo/zaaarf/routecompass/Route.java +++ b/src/main/java/foo/zaaarf/routecompass/Route.java @@ -35,6 +35,16 @@ public class Route { public final boolean deprecated; /** + * A {@link DTO} representing the response body. + */ + public final DTO returnType; + + /** + * A {@link DTO} representing the request body. + */ + public final DTO inputType; + + /** * An array of {@link Param}s, representing parameters accepted by the endpoint. */ public final Param[] params; @@ -48,8 +58,8 @@ public class Route { * @param deprecated whether the endpoint is deprecated * @param params {@link Param}s of the endpoint, may be null */ - public Route(String path, RequestMethod[] methods, MediaType consumes, MediaType produces, boolean deprecated, - Param... params) { + public Route(String path, RequestMethod[] methods, MediaType consumes, MediaType produces, + boolean deprecated, DTO returnType, DTO inputType, Param... params) { this.path = path; StringBuilder methodStringBuilder = new StringBuilder("["); @@ -70,6 +80,9 @@ public class Route { this.deprecated = deprecated; + this.returnType = returnType; + this.inputType = inputType; + if(params != null) this.params = params; else this.params = new Param[0]; //just in case } @@ -106,4 +119,31 @@ public class Route { this.defaultValue = defaultValue; } } + + /** + * Representation of a DTO type. + */ + public static class DTO { + + /** + * Fully-qualified name of the type. + */ + public final String FQN; + + /** + * An array of {@link Param} representing the type's fields. + */ + public final Route.Param[] fields; + + /** + * The one and only constructor. + * @param FQN the fully-qualified name + * @param fields the {@link Param}s representing the fields + */ + public DTO(String FQN, Route.Param ... fields) { + this.FQN = FQN; + if(fields == null) this.fields = new Route.Param[0]; + else this.fields = fields; + } + } } |