Skip to content

Commit f7909d9

Browse files
committed
No effective change, format only
1 parent 83c579f commit f7909d9

File tree

9 files changed

+158
-27
lines changed

9 files changed

+158
-27
lines changed

http-generator-client/src/main/java/io/avaje/http/generator/client/ClientMethodWriter.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,11 @@ void writeGeneric(UType type) {
152152
.map(Util::shortName)
153153
.collect(Collectors.joining(".class, "));
154154

155-
writer.append(
156-
"Types.newParameterizedType(%s.class, %s.class)", Util.shortName(type.mainType()), params);
155+
writer.append("Types.newParameterizedType(%s.class, %s.class)", Util.shortName(type.mainType()), params);
157156
} else {
158157
writer.append("%s.class", Util.shortName(type.mainType()));
159158
}
160-
writer.append(");");
161-
162-
writer.eol();
159+
writer.append(");").eol();
163160
}
164161

165162
private void writeWithHandler() {
@@ -283,4 +280,4 @@ private boolean isHttpResponse(String type0) {
283280
return type0.equals("java.net.http.HttpResponse");
284281
}
285282

286-
}
283+
}

http-generator-client/src/main/java/io/avaje/http/generator/client/ClientProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public ClientProcessor() {
3535
Class.forName("io.avaje.jsonb.Jsonb");
3636
jsonBOnClassPath = true;
3737
} catch (final ClassNotFoundException e) {
38+
// intentionally ignored
3839
}
3940
useJsonB = jsonBOnClassPath;
4041
}

http-generator-core/src/main/java/io/avaje/http/generator/core/JsonBUtil.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ private static void addJsonBodyType(MethodReader methodReader, Consumer<UType> a
3838
}
3939

4040
public static void writeJsonbType(UType type, Append writer) {
41-
4241
writer.append(" this.%sJsonType = jsonB.type(", type.shortName());
4342
if (!type.isGeneric()) {
4443
writer.append("%s.class)", Util.shortName(PrimitiveUtil.wrap(type.full())));
@@ -56,13 +55,12 @@ public static void writeJsonbType(UType type, Append writer) {
5655
writeType(type.paramRaw(), writer);
5756
writer.append(".map()");
5857
break;
59-
default:
60-
{
61-
if (type.mainType().contains("java.util"))
62-
throw new UnsupportedOperationException(
63-
"Only java.util Map, Set and List are supported JsonB Controller Collection Types");
64-
writeType(type, writer);
58+
default: {
59+
if (type.mainType().contains("java.util")) {
60+
throw new UnsupportedOperationException("Only java.util Map, Set and List are supported JsonB Controller Collection Types");
6561
}
62+
writeType(type, writer);
63+
}
6664
}
6765
}
6866
writer.append(";").eol();
@@ -76,9 +74,7 @@ static void writeType(UType type, Append writer) {
7674
.map(Util::shortName)
7775
.collect(Collectors.joining(".class, "));
7876

79-
writer.append(
80-
"Types.newParameterizedType(%s.class, %s.class))",
81-
Util.shortName(type.mainType()), params);
77+
writer.append("Types.newParameterizedType(%s.class, %s.class))", Util.shortName(type.mainType()), params);
8278
} else {
8379
writer.append("%s.class)", Util.shortName(type.mainType()));
8480
}

http-generator-core/src/main/java/io/avaje/http/generator/core/UType.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ public interface UType {
1111
static UType parse(TypeMirror type) {
1212
return Util.parseType(type);
1313
}
14-
/** Create the UType from the given String. */
14+
15+
/**
16+
* Create the UType from the given String.
17+
*/
1518
static UType parse(String type) {
1619
return Util.parse(type);
1720
}
@@ -52,12 +55,16 @@ default String param1() {
5255
return null;
5356
}
5457

55-
/** Return the raw generic parameter if this UType is a Collection. */
58+
/**
59+
* Return the raw generic parameter if this UType is a Collection.
60+
*/
5661
default UType paramRaw() {
5762
return null;
5863
}
5964

60-
/** Return the raw type. */
65+
/**
66+
* Return the raw type.
67+
*/
6168
String full();
6269

6370
default boolean isGeneric() {
@@ -114,8 +121,8 @@ public String full() {
114121
@Override
115122
public Set<String> importTypes() {
116123
return rawType.startsWith("java.lang.") && rawType.indexOf('.') > -1
117-
? Set.of()
118-
: Collections.singleton(rawType.replace("[]", ""));
124+
? Set.of()
125+
: Collections.singleton(rawType.replace("[]", ""));
119126
}
120127

121128
@Override
@@ -154,7 +161,6 @@ class Generic implements UType {
154161
}
155162

156163
private String extractRawParam() {
157-
158164
switch (mainType()) {
159165
case "java.util.Set":
160166
case "java.util.List":

http-generator-javalin/src/main/java/io/avaje/http/generator/javalin/ControllerWriter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ private void writeClassStart() {
8989

9090
for (final UType type : jsonTypes.values()) {
9191
final var typeString = PrimitiveUtil.wrap(type.shortType()).replace(",", ", ");
92-
9392
writer.append(" private final JsonType<%s> %sJsonType;", typeString, type.shortName()).eol();
9493
}
9594
writer.eol();

http-generator-javalin/src/main/java/io/avaje/http/generator/javalin/JavalinProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public JavalinProcessor() {
1717
Class.forName("io.avaje.jsonb.Jsonb");
1818
jsonBOnClassPath = true;
1919
} catch (final ClassNotFoundException e) {
20+
// intentionally ignored
2021
}
2122
useJsonB = jsonBOnClassPath;
2223
}

http-generator-nima/src/main/java/io/avaje/http/generator/helidon/nima/ControllerWriter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ private void writeClassStart() {
9393
}
9494
for (final UType type : jsonTypes.values()) {
9595
final var typeString = PrimitiveUtil.wrap(type.shortType()).replace(",", ", ");
96-
9796
writer.append(" private final JsonType<%s> %sJsonType;", typeString, type.shortName()).eol();
9897
}
9998
writer.eol();

http-generator-nima/src/main/java/io/avaje/http/generator/helidon/nima/NimaProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public NimaProcessor() {
1717
Class.forName("io.avaje.jsonb.Jsonb");
1818
jsonBOnClassPath = true;
1919
} catch (final ClassNotFoundException e) {
20+
// intentionally ignored
2021
}
2122
jsonB = jsonBOnClassPath;
2223
}

tests/test-javalin-jsonb/src/main/resources/public/openapi.json

Lines changed: 134 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"description" : "Example Javalin controllers with Java and Maven",
66
"version" : ""
77
},
8+
"tags" : [ {
9+
"name" : "tag1",
10+
"description" : "this is added to openapi tags"
11+
} ],
812
"paths" : {
913
"/bars" : {
1014
"get" : {
@@ -678,6 +682,125 @@
678682
"deprecated" : true
679683
}
680684
},
685+
"/openapi/get" : {
686+
"get" : {
687+
"tags" : [ ],
688+
"summary" : "Example of Open API Get (up to the first period is the summary)",
689+
"description" : "When using Javalin Context only This Javadoc description is added to the generated openapi.json",
690+
"responses" : {
691+
"200" : {
692+
"description" : "funny phrase (this part of the javadoc is added to the response desc)",
693+
"content" : {
694+
"text/plain" : {
695+
"schema" : {
696+
"type" : "string"
697+
}
698+
}
699+
}
700+
}
701+
}
702+
}
703+
},
704+
"/openapi/post" : {
705+
"post" : {
706+
"tags" : [ "tag1" ],
707+
"summary" : "Standard Post",
708+
"description" : "uses tag annotation to add tags to openapi json",
709+
"requestBody" : {
710+
"description" : "the body (this is used for generated request body desc)",
711+
"content" : {
712+
"application/json" : {
713+
"schema" : {
714+
"$ref" : "#/components/schemas/Person"
715+
}
716+
}
717+
},
718+
"required" : true
719+
},
720+
"responses" : {
721+
"200" : {
722+
"description" : "overrides @return javadoc description",
723+
"content" : {
724+
"application/json" : {
725+
"schema" : {
726+
"$ref" : "#/components/schemas/Person"
727+
}
728+
}
729+
}
730+
},
731+
"201" : {
732+
"description" : "the response body (from javadoc)",
733+
"content" : {
734+
"application/json" : {
735+
"schema" : {
736+
"$ref" : "#/components/schemas/Person"
737+
}
738+
}
739+
}
740+
},
741+
"400" : {
742+
"description" : "User not found (Will not have an associated response schema)"
743+
},
744+
"500" : {
745+
"description" : "Some other Error (Will have this error class as the response class)",
746+
"content" : {
747+
"application/json" : {
748+
"schema" : {
749+
"$ref" : "#/components/schemas/ErrorResponse"
750+
}
751+
}
752+
}
753+
}
754+
}
755+
}
756+
},
757+
"/openapi/post1" : {
758+
"post" : {
759+
"tags" : [ ],
760+
"summary" : "Standard Post",
761+
"description" : "The Deprecated annotation adds \"deprecacted:true\" to the generated json",
762+
"requestBody" : {
763+
"description" : "the body",
764+
"content" : {
765+
"application/json" : {
766+
"schema" : {
767+
"type" : "array",
768+
"items" : {
769+
"$ref" : "#/components/schemas/Person"
770+
}
771+
}
772+
}
773+
},
774+
"required" : true
775+
},
776+
"responses" : {
777+
"400" : {
778+
"description" : "User not found"
779+
},
780+
"500" : {
781+
"description" : "Some other Error",
782+
"content" : {
783+
"application/json" : {
784+
"schema" : {
785+
"$ref" : "#/components/schemas/ErrorResponse"
786+
}
787+
}
788+
}
789+
},
790+
"201" : {
791+
"description" : "the response body (from javadoc)",
792+
"content" : {
793+
"application/json" : {
794+
"schema" : {
795+
"$ref" : "#/components/schemas/Person"
796+
}
797+
}
798+
}
799+
}
800+
},
801+
"deprecated" : true
802+
}
803+
},
681804
"/req-scoped" : {
682805
"get" : {
683806
"tags" : [ ],
@@ -946,7 +1069,7 @@
9461069
"schema" : {
9471070
"type" : "array",
9481071
"items" : {
949-
"$ref" : "#/components/schemas/E"
1072+
"$ref" : "#/components/schemas/Person"
9501073
}
9511074
}
9521075
}
@@ -1116,8 +1239,16 @@
11161239
}
11171240
}
11181241
},
1119-
"E" : {
1120-
"type" : "object"
1242+
"ErrorResponse" : {
1243+
"type" : "object",
1244+
"properties" : {
1245+
"id" : {
1246+
"type" : "string"
1247+
},
1248+
"text" : {
1249+
"type" : "string"
1250+
}
1251+
}
11211252
},
11221253
"GetBeanForm" : {
11231254
"type" : "object",

0 commit comments

Comments
 (0)