File tree Expand file tree Collapse file tree 5 files changed +25
-3
lines changed
http-generator-core/src/main/java/io/avaje/http/generator/core
tests/test-javalin/src/main
java/org/example/myapp/web Expand file tree Collapse file tree 5 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 22
22
23
23
import io .avaje .http .generator .core .javadoc .Javadoc ;
24
24
import io .avaje .http .generator .core .openapi .MethodDocBuilder ;
25
+ import io .swagger .v3 .oas .models .Operation ;
25
26
26
27
public class MethodReader {
27
28
@@ -269,6 +270,25 @@ private List<OpenAPIResponsePrism> buildApiResponses() {
269
270
return responses ;
270
271
}
271
272
273
+ public void readOperation (Operation operation , Javadoc javadoc ) {
274
+ OperationPrism .getOptionalOn (element ).ifPresent (an -> {
275
+ operation .setOperationId (emptyToNull (an .operationId ()));
276
+ operation .setDeprecated (an .deprecated ());
277
+ operation .setSummary (emptyToNull (an .summary ()));
278
+ operation .setDescription (emptyToNull (an .description ()));
279
+ });
280
+ if (operation .getDescription () == null ) {
281
+ operation .setDescription (javadoc .getDescription ());
282
+ }
283
+ if (operation .getSummary () == null ) {
284
+ operation .setSummary (javadoc .getSummary ());
285
+ }
286
+ }
287
+
288
+ private static String emptyToNull (String val ) {
289
+ return val .isEmpty () ? null : val ;
290
+ }
291
+
272
292
public <A > Optional <A > findAnnotation (Function <Element , Optional <A >> prismFunc ) {
273
293
return findAnnotation (prismFunc , element );
274
294
}
Original file line number Diff line number Diff line change @@ -39,9 +39,7 @@ public void build() {
39
39
return ;
40
40
}
41
41
42
- //operation.setOperationId();
43
- operation .setSummary (javadoc .getSummary ());
44
- operation .setDescription (javadoc .getDescription ());
42
+ methodReader .readOperation (operation , javadoc );
45
43
operation .setTags (methodReader .tags ());
46
44
47
45
if (javadoc .isDeprecated ()
Original file line number Diff line number Diff line change 23
23
@ GeneratePrism (value = io .avaje .http .api .InstrumentServerContext .class )
24
24
@ GeneratePrism (value = io .avaje .http .api .ExceptionHandler .class )
25
25
@ GeneratePrism (value = io .swagger .v3 .oas .annotations .OpenAPIDefinition .class , publicAccess = true )
26
+ @ GeneratePrism (value = io .swagger .v3 .oas .annotations .Operation .class , publicAccess = true )
26
27
@ GeneratePrism (value = io .swagger .v3 .oas .annotations .tags .Tag .class , publicAccess = true )
27
28
@ GeneratePrism (value = io .swagger .v3 .oas .annotations .tags .Tags .class , publicAccess = true )
28
29
@ GeneratePrism (value = io .swagger .v3 .oas .annotations .security .SecurityScheme .class , publicAccess = true )
Original file line number Diff line number Diff line change 8
8
import java .util .concurrent .CompletableFuture ;
9
9
import java .util .concurrent .Executors ;
10
10
11
+ import io .swagger .v3 .oas .annotations .Operation ;
11
12
import org .example .myapp .service .MyService ;
12
13
13
14
import io .avaje .http .api .BeanParam ;
@@ -61,6 +62,7 @@ String getPlainMessage() {
61
62
*/
62
63
@ Deprecated
63
64
@ Roles ({AppRoles .ADMIN , AppRoles .BASIC_USER })
65
+ @ Operation (operationId = "helloByDate" )
64
66
@ Get ("/{id}/{date}" )
65
67
HelloDto hello (int id , LocalDate date , String otherParam ) {
66
68
return new HelloDto (id , date .toString (), otherParam );
Original file line number Diff line number Diff line change 750
750
],
751
751
"summary" : " Return the Hello DTO" ,
752
752
"description" : " " ,
753
+ "operationId" : " helloByDate" ,
753
754
"parameters" : [
754
755
{
755
756
"name" : " id" ,
You can’t perform that action at this time.
0 commit comments