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 2222
2323import io .avaje .http .generator .core .javadoc .Javadoc ;
2424import io .avaje .http .generator .core .openapi .MethodDocBuilder ;
25+ import io .swagger .v3 .oas .models .Operation ;
2526
2627public class MethodReader {
2728
@@ -269,6 +270,25 @@ private List<OpenAPIResponsePrism> buildApiResponses() {
269270 return responses ;
270271 }
271272
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+
272292 public <A > Optional <A > findAnnotation (Function <Element , Optional <A >> prismFunc ) {
273293 return findAnnotation (prismFunc , element );
274294 }
Original file line number Diff line number Diff line change @@ -39,9 +39,7 @@ public void build() {
3939 return ;
4040 }
4141
42- //operation.setOperationId();
43- operation .setSummary (javadoc .getSummary ());
44- operation .setDescription (javadoc .getDescription ());
42+ methodReader .readOperation (operation , javadoc );
4543 operation .setTags (methodReader .tags ());
4644
4745 if (javadoc .isDeprecated ()
Original file line number Diff line number Diff line change 2323@ GeneratePrism (value = io .avaje .http .api .InstrumentServerContext .class )
2424@ GeneratePrism (value = io .avaje .http .api .ExceptionHandler .class )
2525@ GeneratePrism (value = io .swagger .v3 .oas .annotations .OpenAPIDefinition .class , publicAccess = true )
26+ @ GeneratePrism (value = io .swagger .v3 .oas .annotations .Operation .class , publicAccess = true )
2627@ GeneratePrism (value = io .swagger .v3 .oas .annotations .tags .Tag .class , publicAccess = true )
2728@ GeneratePrism (value = io .swagger .v3 .oas .annotations .tags .Tags .class , publicAccess = true )
2829@ GeneratePrism (value = io .swagger .v3 .oas .annotations .security .SecurityScheme .class , publicAccess = true )
Original file line number Diff line number Diff line change 88import java .util .concurrent .CompletableFuture ;
99import java .util .concurrent .Executors ;
1010
11+ import io .swagger .v3 .oas .annotations .Operation ;
1112import org .example .myapp .service .MyService ;
1213
1314import io .avaje .http .api .BeanParam ;
@@ -61,6 +62,7 @@ String getPlainMessage() {
6162 */
6263 @ Deprecated
6364@ Roles ({AppRoles .ADMIN , AppRoles .BASIC_USER })
65+ @ Operation (operationId = "helloByDate" )
6466 @ Get ("/{id}/{date}" )
6567 HelloDto hello (int id , LocalDate date , String otherParam ) {
6668 return new HelloDto (id , date .toString (), otherParam );
Original file line number Diff line number Diff line change 750750 ],
751751 "summary" : " Return the Hello DTO" ,
752752 "description" : " " ,
753+ "operationId" : " helloByDate" ,
753754 "parameters" : [
754755 {
755756 "name" : " id" ,
You can’t perform that action at this time.
0 commit comments