Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit d886bbb

Browse files
committed
ApiTool.modify() does not agree with documentation fix jooby-project#989
1 parent ae68b5c commit d886bbb

File tree

4 files changed

+49
-42
lines changed

4 files changed

+49
-42
lines changed

modules/jooby-apitool/pom.xml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -64,37 +64,6 @@
6464
</executions>
6565
</plugin>
6666

67-
<plugin>
68-
<groupId>org.apache.maven.plugins</groupId>
69-
<artifactId>maven-compiler-plugin</artifactId>
70-
<executions>
71-
<!-- Replacing default-compile as it is treated specially by maven -->
72-
<execution>
73-
<id>default-compile</id>
74-
<phase>none</phase>
75-
</execution>
76-
<!-- Replacing default-testCompile as it is treated specially by maven -->
77-
<execution>
78-
<id>default-testCompile</id>
79-
<phase>none</phase>
80-
</execution>
81-
<execution>
82-
<id>java-compile</id>
83-
<phase>compile</phase>
84-
<goals>
85-
<goal>compile</goal>
86-
</goals>
87-
</execution>
88-
<execution>
89-
<id>java-test-compile</id>
90-
<phase>test-compile</phase>
91-
<goals>
92-
<goal>testCompile</goal>
93-
</goals>
94-
</execution>
95-
</executions>
96-
</plugin>
97-
9867
<plugin>
9968
<artifactId>kotlin-maven-plugin</artifactId>
10069
<groupId>org.jetbrains.kotlin</groupId>
@@ -132,6 +101,37 @@
132101
</executions>
133102
</plugin>
134103

104+
<plugin>
105+
<groupId>org.apache.maven.plugins</groupId>
106+
<artifactId>maven-compiler-plugin</artifactId>
107+
<executions>
108+
<!-- Replacing default-compile as it is treated specially by maven -->
109+
<execution>
110+
<id>default-compile</id>
111+
<phase>none</phase>
112+
</execution>
113+
<!-- Replacing default-testCompile as it is treated specially by maven -->
114+
<execution>
115+
<id>default-testCompile</id>
116+
<phase>none</phase>
117+
</execution>
118+
<execution>
119+
<id>java-compile</id>
120+
<phase>compile</phase>
121+
<goals>
122+
<goal>compile</goal>
123+
</goals>
124+
</execution>
125+
<execution>
126+
<id>java-test-compile</id>
127+
<phase>test-compile</phase>
128+
<goals>
129+
<goal>testCompile</goal>
130+
</goals>
131+
</execution>
132+
</executions>
133+
</plugin>
134+
135135
<!-- sure-fire -->
136136
<plugin>
137137
<groupId>org.apache.maven.plugins</groupId>

modules/jooby-apitool/src/main/java/org/jooby/apitool/ApiParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ public List<RouteMethod> parseFully(String application, List<Route.Definition> r
325325
customizer.entrySet().forEach(it ->
326326
result.stream()
327327
.filter(it.getKey())
328-
.findFirst()
329-
.ifPresent(it.getValue())
328+
.forEach(it.getValue())
330329
);
331330

332331
return result;

modules/jooby-apitool/src/main/java/org/jooby/internal/apitool/SwaggerBuilder.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,21 @@ public class SwaggerBuilder {
268268
ModelConverters.getInstance().addConverter(new AbstractModelConverter(Json.mapper()) {
269269
@Override public Property resolveProperty(Type type, ModelConverterContext context,
270270
Annotation[] annotations, Iterator<ModelConverter> chain) {
271-
TypeLiteral<?> typeLiteral = TypeLiteral.get(type);
272-
String typeName = typeLiteral.getType().getTypeName();
273-
if (typeName.equals("java.util.List<org.jooby.Upload>") ||
274-
typeName.equals("java.util.Set<org.jooby.Upload>")) {
275-
return new ArrayProperty(new FileProperty());
276-
}
277-
if (typeName.equals(Upload.class.getName())) {
278-
return new FileProperty();
271+
try {
272+
TypeLiteral<?> typeLiteral = TypeLiteral.get(type);
273+
String typeName = typeLiteral.getType().getTypeName();
274+
if (typeName.equals("java.util.List<org.jooby.Upload>") ||
275+
typeName.equals("java.util.Set<org.jooby.Upload>")) {
276+
return new ArrayProperty(new FileProperty());
277+
}
278+
if (typeName.equals(Upload.class.getName())) {
279+
return new FileProperty();
280+
}
281+
return super.resolveProperty(type, context, annotations, chain);
282+
} catch (IllegalArgumentException x) {
283+
// shhh
284+
return super.resolveProperty(type, context, annotations, chain);
279285
}
280-
return super.resolveProperty(type, context, annotations, chain);
281286
}
282287
});
283288
}

modules/jooby-apitool/src/test/java/apps/ApiDemo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ public class ApiDemo extends Jooby {
123123
});
124124

125125
use(new ApiTool()
126+
.modify(r -> r.pattern().startsWith("/api"), it-> {
127+
System.out.println(it);
128+
})
126129
.raml("/raml")
127130
.swagger("/swagger"));
128131
}

0 commit comments

Comments
 (0)