Skip to content

Commit 64e4c5a

Browse files
committed
route spec: support extends route jooby-project#365
1 parent 0ce1ce8 commit 64e4c5a

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

coverage-report/src/test/java/org/jooby/swagger/SwaggerFeature.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void json() throws Exception {
5151
" \"/api/pets\" : {\n" +
5252
" \"get\" : {\n" +
5353
" \"tags\" : [ \"pets\" ],\n" +
54+
" \"summary\" : \"Pets.list\",\n" +
5455
" \"consumes\" : [ \"*/*\" ],\n" +
5556
" \"produces\" : [ \"*/*\" ],\n" +
5657
" \"parameters\" : [ {\n" +
@@ -71,6 +72,7 @@ public void json() throws Exception {
7172
" },\n" +
7273
" \"post\" : {\n" +
7374
" \"tags\" : [ \"pets\" ],\n" +
75+
" \"summary\" : \"Pets.create\",\n" +
7476
" \"consumes\" : [ \"*/*\" ],\n" +
7577
" \"produces\" : [ \"*/*\" ],\n" +
7678
" \"parameters\" : [ {\n" +
@@ -94,6 +96,7 @@ public void json() throws Exception {
9496
" \"/api/pets/{id}\" : {\n" +
9597
" \"get\" : {\n" +
9698
" \"tags\" : [ \"pets\" ],\n" +
99+
" \"summary\" : \"Pets.get\",\n" +
97100
" \"consumes\" : [ \"*/*\" ],\n" +
98101
" \"produces\" : [ \"*/*\" ],\n" +
99102
" \"parameters\" : [ {\n" +
@@ -149,6 +152,7 @@ public void json() throws Exception {
149152
" \"/api/pets\" : {\n" +
150153
" \"get\" : {\n" +
151154
" \"tags\" : [ \"pets\" ],\n" +
155+
" \"summary\" : \"Pets.list\",\n" +
152156
" \"consumes\" : [ \"*/*\" ],\n" +
153157
" \"produces\" : [ \"*/*\" ],\n" +
154158
" \"parameters\" : [ {\n" +
@@ -169,6 +173,7 @@ public void json() throws Exception {
169173
" },\n" +
170174
" \"post\" : {\n" +
171175
" \"tags\" : [ \"pets\" ],\n" +
176+
" \"summary\" : \"Pets.create\",\n" +
172177
" \"consumes\" : [ \"*/*\" ],\n" +
173178
" \"produces\" : [ \"*/*\" ],\n" +
174179
" \"parameters\" : [ {\n" +
@@ -192,6 +197,7 @@ public void json() throws Exception {
192197
" \"/api/pets/{id}\" : {\n" +
193198
" \"get\" : {\n" +
194199
" \"tags\" : [ \"pets\" ],\n" +
200+
" \"summary\" : \"Pets.get\",\n" +
195201
" \"consumes\" : [ \"*/*\" ],\n" +
196202
" \"produces\" : [ \"*/*\" ],\n" +
197203
" \"parameters\" : [ {\n" +
@@ -252,6 +258,7 @@ public void yml() throws Exception {
252258
" get:\n" +
253259
" tags:\n" +
254260
" - \"pets\"\n" +
261+
" summary: \"Pets.list\"\n" +
255262
" consumes:\n" +
256263
" - \"*/*\"\n" +
257264
" produces:\n" +
@@ -270,6 +277,7 @@ public void yml() throws Exception {
270277
" post:\n" +
271278
" tags:\n" +
272279
" - \"pets\"\n" +
280+
" summary: \"Pets.create\"\n" +
273281
" consumes:\n" +
274282
" - \"*/*\"\n" +
275283
" produces:\n" +
@@ -289,6 +297,7 @@ public void yml() throws Exception {
289297
" get:\n" +
290298
" tags:\n" +
291299
" - \"pets\"\n" +
300+
" summary: \"Pets.get\"\n" +
292301
" consumes:\n" +
293302
" - \"*/*\"\n" +
294303
" produces:\n" +
@@ -336,6 +345,7 @@ public void yml() throws Exception {
336345
" get:\n" +
337346
" tags:\n" +
338347
" - \"pets\"\n" +
348+
" summary: \"Pets.list\"\n" +
339349
" consumes:\n" +
340350
" - \"*/*\"\n" +
341351
" produces:\n" +
@@ -354,6 +364,7 @@ public void yml() throws Exception {
354364
" post:\n" +
355365
" tags:\n" +
356366
" - \"pets\"\n" +
367+
" summary: \"Pets.create\"\n" +
357368
" consumes:\n" +
358369
" - \"*/*\"\n" +
359370
" produces:\n" +
@@ -373,6 +384,7 @@ public void yml() throws Exception {
373384
" get:\n" +
374385
" tags:\n" +
375386
" - \"pets\"\n" +
387+
" summary: \"Pets.get\"\n" +
376388
" consumes:\n" +
377389
" - \"*/*\"\n" +
378390
" produces:\n" +

jooby-spec/src/main/java/org/jooby/internal/spec/RouteCollector.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,14 @@ private void importRoutes(final Type type, final Context ctx) {
146146
this.nodes.addAll(result);
147147
}
148148

149+
@SuppressWarnings("rawtypes")
149150
private void mvcRoutes(final Node n, final Type type, final Context ctx) {
151+
if (type instanceof Class) {
152+
Class sclass = ((Class) type).getSuperclass();
153+
if (sclass != Object.class) {
154+
mvcRoutes(n, sclass, ctx);
155+
}
156+
}
150157
List<Map.Entry<Object, Node>> result = ctx.parse(type)
151158
.map(unit -> new RouteCollector(false, owners).accept(unit, ctx))
152159
.orElse(Collections.emptyList());

jooby-swagger/src/main/java/org/jooby/internal/swagger/SwaggerBuilder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ public <S extends Swagger> S build(final Optional<String> tagFilter,
124124
if (tag == null) {
125125
tag = new Tag();
126126
tag.name(tagname);
127-
route.summary().ifPresent(tag::description);
128127
tags.put(tagname, tag);
129128
swagger.addTag(tag);
130129
}
130+
// tag summary
131+
route.summary().ifPresent(tag::description);
131132

132133
/**
133134
* Path
@@ -145,8 +146,9 @@ public <S extends Swagger> S build(final Optional<String> tagFilter,
145146
op.addTag(tag.getName());
146147

147148
/**
148-
* Doc and summary
149+
* Doc and summary: default or full
149150
*/
151+
route.name().ifPresent(n -> op.summary(n.substring(1)));
150152
route.doc().ifPresent(doc -> {
151153
String summary = Splitter.on(SENTENCE)
152154
.trimResults()

0 commit comments

Comments
 (0)