Skip to content

Commit 51e1b06

Browse files
committed
[REQ-22001][FIX] Add MCP server support to apiService.mustache
1 parent 1d07128 commit 51e1b06

File tree

10 files changed

+87
-9
lines changed

10 files changed

+87
-9
lines changed

modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/apiService.mustache

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ package {{package}};
22

33
import {{package}}.*;
44
import {{modelPackage}}.*;
5+
{{#vendorExtensions.x-enable-mcp-server}}
6+
import io.quarkiverse.mcp.server.Tool;
7+
import io.quarkiverse.mcp.server.ToolArg;
8+
import jakarta.enterprise.context.ApplicationScoped;
9+
import lombok.AllArgsConstructor;
10+
{{/vendorExtensions.x-enable-mcp-server}}
11+
512
{{#operations}}{{#operation}}{{#isMultipart}}import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
613
{{/isMultipart}}{{/operation}}{{/operations}}
714

@@ -28,5 +35,49 @@ public interface {{classname}}Service {
2835
Response {{nickname}}({{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}{{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{^isMultipart}}{{>serviceFormParams}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}SecurityContext securityContext)
2936
throws NotFoundException;
3037
{{/operation}}
38+
39+
{{#vendorExtensions.x-enable-mcp-server}}
40+
default Response {{nickname}}(
41+
{{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}
42+
{{#allParams}}
43+
{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{^isMultipart}}{{>serviceFormParams}}{{^last}}, {{/last}}{{/isMultipart}}{{#isMultipart}}{{^isFormParam}}{{^last}}, {{/last}}{{/isFormParam}}{{/isMultipart}}
44+
{{/allParams}}
45+
String context
46+
) throws NotFoundException {
47+
return {{nickname}}(
48+
{{#isMultipart}}input,{{/isMultipart}}
49+
{{#allParams}}{{paramName}},{{/allParams}}
50+
(SecurityContext)null
51+
);
52+
}
53+
{{/vendorExtensions.x-enable-mcp-server}}
54+
55+
}
56+
{{#vendorExtensions.x-enable-mcp-server}}
57+
@ApplicationScoped
58+
@AllArgsConstructor
59+
class Mcp{{classname}}Service {
60+
{{classname}}Service service;
61+
62+
{{#operation}}
63+
{{#vendorExtensions.x-enable-mcp-operation}}
64+
@Tool(description = "{{summary}}")
65+
public Response {{nickname}}(
66+
{{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}
67+
{{#allParams}}
68+
@ToolArg(description = "{{description}}", required = false)
69+
{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{^isMultipart}}{{>serviceFormParams}}{{^last}}, {{/last}}{{/isMultipart}}{{#isMultipart}}{{^isFormParam}}{{^last}}, {{/last}}{{/isFormParam}}{{/isMultipart}}
70+
{{/allParams}}
71+
String context
72+
) throws NotFoundException {
73+
return service.{{nickname}}(
74+
{{#isMultipart}}input,{{/isMultipart}}
75+
{{#allParams}}{{paramName}},{{/allParams}}
76+
(SecurityContext)null
77+
);
78+
}
79+
{{/vendorExtensions.x-enable-mcp-operation}}
80+
{{/operation}}
3181
}
82+
{{/vendorExtensions.x-enable-mcp-server}}
3283
{{/operations}}

samples/server/petstore/jaxrs-resteasy/default/src/gen/java/org/openapitools/api/PetApiService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.openapitools.api.*;
44
import org.openapitools.model.*;
5+
56
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
67

78

@@ -19,7 +20,7 @@
1920
import javax.ws.rs.core.Response;
2021
import javax.ws.rs.core.SecurityContext;
2122

22-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
23+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2324
public interface PetApiService {
2425
Response addPet(Pet body,SecurityContext securityContext)
2526
throws NotFoundException;
@@ -37,4 +38,6 @@ Response updatePetWithForm(Long petId,String name,String status,SecurityContext
3738
throws NotFoundException;
3839
Response uploadFile(MultipartFormDataInput input,Long petId,SecurityContext securityContext)
3940
throws NotFoundException;
41+
42+
4043
}

samples/server/petstore/jaxrs-resteasy/default/src/gen/java/org/openapitools/api/StoreApiService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.openapitools.model.*;
55

66

7+
78
import java.util.Map;
89
import org.openapitools.model.Order;
910

@@ -17,7 +18,7 @@
1718
import javax.ws.rs.core.Response;
1819
import javax.ws.rs.core.SecurityContext;
1920

20-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
21+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2122
public interface StoreApiService {
2223
Response deleteOrder(String orderId,SecurityContext securityContext)
2324
throws NotFoundException;
@@ -27,4 +28,6 @@ Response getOrderById(Long orderId,SecurityContext securityContext)
2728
throws NotFoundException;
2829
Response placeOrder(Order body,SecurityContext securityContext)
2930
throws NotFoundException;
31+
32+
3033
}

samples/server/petstore/jaxrs-resteasy/default/src/gen/java/org/openapitools/api/UserApiService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.openapitools.model.*;
55

66

7+
78
import java.util.Date;
89
import org.openapitools.model.User;
910

@@ -17,7 +18,7 @@
1718
import javax.ws.rs.core.Response;
1819
import javax.ws.rs.core.SecurityContext;
1920

20-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
21+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2122
public interface UserApiService {
2223
Response createUser(User body,SecurityContext securityContext)
2324
throws NotFoundException;
@@ -35,4 +36,6 @@ Response logoutUser(SecurityContext securityContext)
3536
throws NotFoundException;
3637
Response updateUser(String username,User body,SecurityContext securityContext)
3738
throws NotFoundException;
39+
40+
3841
}

samples/server/petstore/jaxrs-resteasy/java8/src/gen/java/org/openapitools/api/PetApiService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.openapitools.api.*;
44
import org.openapitools.model.*;
5+
56
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
67

78

@@ -19,7 +20,7 @@
1920
import javax.ws.rs.core.Response;
2021
import javax.ws.rs.core.SecurityContext;
2122

22-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
23+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2324
public interface PetApiService {
2425
Response addPet(Pet body,SecurityContext securityContext)
2526
throws NotFoundException;
@@ -37,4 +38,6 @@ Response updatePetWithForm(Long petId,String name,String status,SecurityContext
3738
throws NotFoundException;
3839
Response uploadFile(MultipartFormDataInput input,Long petId,SecurityContext securityContext)
3940
throws NotFoundException;
41+
42+
4043
}

samples/server/petstore/jaxrs-resteasy/java8/src/gen/java/org/openapitools/api/StoreApiService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.openapitools.model.*;
55

66

7+
78
import java.util.Map;
89
import org.openapitools.model.Order;
910

@@ -17,7 +18,7 @@
1718
import javax.ws.rs.core.Response;
1819
import javax.ws.rs.core.SecurityContext;
1920

20-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
21+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2122
public interface StoreApiService {
2223
Response deleteOrder(String orderId,SecurityContext securityContext)
2324
throws NotFoundException;
@@ -27,4 +28,6 @@ Response getOrderById(Long orderId,SecurityContext securityContext)
2728
throws NotFoundException;
2829
Response placeOrder(Order body,SecurityContext securityContext)
2930
throws NotFoundException;
31+
32+
3033
}

samples/server/petstore/jaxrs-resteasy/java8/src/gen/java/org/openapitools/api/UserApiService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.openapitools.model.*;
55

66

7+
78
import java.time.OffsetDateTime;
89
import org.openapitools.model.User;
910

@@ -17,7 +18,7 @@
1718
import javax.ws.rs.core.Response;
1819
import javax.ws.rs.core.SecurityContext;
1920

20-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
21+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2122
public interface UserApiService {
2223
Response createUser(User body,SecurityContext securityContext)
2324
throws NotFoundException;
@@ -35,4 +36,6 @@ Response logoutUser(SecurityContext securityContext)
3536
throws NotFoundException;
3637
Response updateUser(String username,User body,SecurityContext securityContext)
3738
throws NotFoundException;
39+
40+
3841
}

samples/server/petstore/jaxrs-resteasy/joda/src/gen/java/org/openapitools/api/PetApiService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.openapitools.api.*;
44
import org.openapitools.model.*;
5+
56
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
67

78

@@ -19,7 +20,7 @@
1920
import javax.ws.rs.core.Response;
2021
import javax.ws.rs.core.SecurityContext;
2122

22-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
23+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2324
public interface PetApiService {
2425
Response addPet(Pet body,SecurityContext securityContext)
2526
throws NotFoundException;
@@ -37,4 +38,6 @@ Response updatePetWithForm(Long petId,String name,String status,SecurityContext
3738
throws NotFoundException;
3839
Response uploadFile(MultipartFormDataInput input,Long petId,SecurityContext securityContext)
3940
throws NotFoundException;
41+
42+
4043
}

samples/server/petstore/jaxrs-resteasy/joda/src/gen/java/org/openapitools/api/StoreApiService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.openapitools.model.*;
55

66

7+
78
import java.util.Map;
89
import org.openapitools.model.Order;
910

@@ -17,7 +18,7 @@
1718
import javax.ws.rs.core.Response;
1819
import javax.ws.rs.core.SecurityContext;
1920

20-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
21+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2122
public interface StoreApiService {
2223
Response deleteOrder(String orderId,SecurityContext securityContext)
2324
throws NotFoundException;
@@ -27,4 +28,6 @@ Response getOrderById(Long orderId,SecurityContext securityContext)
2728
throws NotFoundException;
2829
Response placeOrder(Order body,SecurityContext securityContext)
2930
throws NotFoundException;
31+
32+
3033
}

samples/server/petstore/jaxrs-resteasy/joda/src/gen/java/org/openapitools/api/UserApiService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.openapitools.model.*;
55

66

7+
78
import org.joda.time.DateTime;
89
import org.openapitools.model.User;
910

@@ -17,7 +18,7 @@
1718
import javax.ws.rs.core.Response;
1819
import javax.ws.rs.core.SecurityContext;
1920

20-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
21+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2122
public interface UserApiService {
2223
Response createUser(User body,SecurityContext securityContext)
2324
throws NotFoundException;
@@ -35,4 +36,6 @@ Response logoutUser(SecurityContext securityContext)
3536
throws NotFoundException;
3637
Response updateUser(String username,User body,SecurityContext securityContext)
3738
throws NotFoundException;
39+
40+
3841
}

0 commit comments

Comments
 (0)