Skip to content

Commit 20136f4

Browse files
wing328RL6172
andauthored
[REQ-22001][FIX] Add MCP server support to apiService.mustache (#22558)
Co-authored-by: RL6172 <[email protected]>
1 parent f484aea commit 20136f4

File tree

10 files changed

+162
-1071
lines changed

10 files changed

+162
-1071
lines changed

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

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,49 @@ import jakarta.enterprise.context.ApplicationScoped;
99
import lombok.AllArgsConstructor;
1010
{{/vendorExtensions.x-enable-mcp-server}}
1111

12-
{{#operations}}
13-
{{#operation}}
14-
{{#isMultipart}}
15-
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
16-
{{/isMultipart}}
17-
{{/operation}}
18-
{{/operations}}
12+
{{#operations}}{{#operation}}{{#isMultipart}}import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
13+
{{/isMultipart}}{{/operation}}{{/operations}}
1914

20-
{{#imports}}
21-
import {{import}};
15+
{{#imports}}import {{import}};
2216
{{/imports}}
2317

2418
import java.util.List;
2519
import {{package}}.NotFoundException;
20+
2621
import java.io.InputStream;
2722

2823
{{#useBeanValidation}}
2924
import {{javaxPackage}}.validation.constraints.*;
3025
import {{javaxPackage}}.validation.Valid;
3126
{{/useBeanValidation}}
32-
3327
import {{javaxPackage}}.ws.rs.core.Response;
3428
import {{javaxPackage}}.ws.rs.core.SecurityContext;
3529

3630
{{>generatedAnnotation}}
3731

3832
{{#operations}}
3933
public interface {{classname}}Service {
40-
{{#operation}}
41-
Response {{nickname}}(
42-
{{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}
43-
{{#allParams}}
44-
{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{^isMultipart}}{{>serviceFormParams}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}},{{/isFormParam}}{{/isMultipart}}
45-
{{/allParams}}
46-
SecurityContext securityContext
47-
) throws NotFoundException;
34+
{{#operation}}
35+
Response {{nickname}}({{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}{{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{^isMultipart}}{{>serviceFormParams}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}SecurityContext securityContext)
36+
throws NotFoundException;
37+
{{/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}}
4854

49-
default Response {{nickname}}(
50-
{{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}
51-
{{#allParams}}
52-
{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{^isMultipart}}{{>serviceFormParams}}{{^last}}, {{/last}}{{/isMultipart}}{{#isMultipart}}{{^isFormParam}}{{^last}}, {{/last}}{{/isFormParam}}{{/isMultipart}}
53-
{{/allParams}}
54-
String context
55-
) throws NotFoundException {
56-
return {{nickname}}(
57-
{{#isMultipart}}input,{{/isMultipart}}
58-
{{#allParams}}{{paramName}},{{/allParams}}
59-
(SecurityContext)null
60-
);
61-
}
62-
{{/operation}}
6355
}
6456
{{#vendorExtensions.x-enable-mcp-server}}
6557
@ApplicationScoped

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

Lines changed: 18 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -5,164 +5,39 @@
55

66
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
77

8+
89
import java.io.File;
910
import org.openapitools.model.ModelApiResponse;
1011
import org.openapitools.model.Pet;
1112

1213
import java.util.List;
1314
import org.openapitools.api.NotFoundException;
15+
1416
import java.io.InputStream;
1517

1618
import javax.validation.constraints.*;
1719
import javax.validation.Valid;
18-
1920
import javax.ws.rs.core.Response;
2021
import javax.ws.rs.core.SecurityContext;
2122

2223
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2324
public interface PetApiService {
24-
Response addPet(
25-
26-
Pet body,
27-
SecurityContext securityContext
28-
) throws NotFoundException;
29-
30-
default Response addPet(
31-
32-
Pet body,
33-
String context
34-
) throws NotFoundException {
35-
return addPet(
36-
37-
body,
38-
(SecurityContext)null
39-
);
40-
}
41-
Response deletePet(
42-
43-
Long petId,
44-
SecurityContext securityContext
45-
) throws NotFoundException;
46-
47-
default Response deletePet(
48-
49-
Long petId,
50-
String context
51-
) throws NotFoundException {
52-
return deletePet(
53-
54-
petId,
55-
(SecurityContext)null
56-
);
57-
}
58-
Response findPetsByStatus(
59-
60-
List<String> status,
61-
SecurityContext securityContext
62-
) throws NotFoundException;
63-
64-
default Response findPetsByStatus(
65-
66-
List<String> status,
67-
String context
68-
) throws NotFoundException {
69-
return findPetsByStatus(
70-
71-
status,
72-
(SecurityContext)null
73-
);
74-
}
75-
Response findPetsByTags(
76-
77-
List<String> tags,
78-
SecurityContext securityContext
79-
) throws NotFoundException;
80-
81-
default Response findPetsByTags(
82-
83-
List<String> tags,
84-
String context
85-
) throws NotFoundException {
86-
return findPetsByTags(
87-
88-
tags,
89-
(SecurityContext)null
90-
);
91-
}
92-
Response getPetById(
93-
94-
Long petId,
95-
SecurityContext securityContext
96-
) throws NotFoundException;
97-
98-
default Response getPetById(
99-
100-
Long petId,
101-
String context
102-
) throws NotFoundException {
103-
return getPetById(
104-
105-
petId,
106-
(SecurityContext)null
107-
);
108-
}
109-
Response updatePet(
110-
111-
Pet body,
112-
SecurityContext securityContext
113-
) throws NotFoundException;
114-
115-
default Response updatePet(
116-
117-
Pet body,
118-
String context
119-
) throws NotFoundException {
120-
return updatePet(
121-
122-
body,
123-
(SecurityContext)null
124-
);
125-
}
126-
Response updatePetWithForm(
127-
128-
Long petId,
129-
String name,
130-
String status,
131-
SecurityContext securityContext
132-
) throws NotFoundException;
25+
Response addPet(Pet body,SecurityContext securityContext)
26+
throws NotFoundException;
27+
Response deletePet(Long petId,SecurityContext securityContext)
28+
throws NotFoundException;
29+
Response findPetsByStatus(List<String> status,SecurityContext securityContext)
30+
throws NotFoundException;
31+
Response findPetsByTags(List<String> tags,SecurityContext securityContext)
32+
throws NotFoundException;
33+
Response getPetById(Long petId,SecurityContext securityContext)
34+
throws NotFoundException;
35+
Response updatePet(Pet body,SecurityContext securityContext)
36+
throws NotFoundException;
37+
Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext)
38+
throws NotFoundException;
39+
Response uploadFile(MultipartFormDataInput input,Long petId,SecurityContext securityContext)
40+
throws NotFoundException;
13341

134-
default Response updatePetWithForm(
135-
136-
Long petId,
137-
String name,
138-
String status,
139-
String context
140-
) throws NotFoundException {
141-
return updatePetWithForm(
142-
143-
petId,name,status,
144-
(SecurityContext)null
145-
);
146-
}
147-
Response uploadFile(
148-
MultipartFormDataInput input,
149-
Long petId,
150-
151-
152-
SecurityContext securityContext
153-
) throws NotFoundException;
15442

155-
default Response uploadFile(
156-
MultipartFormDataInput input,
157-
Long petId,
158-
159-
160-
String context
161-
) throws NotFoundException {
162-
return uploadFile(
163-
input,
164-
petId,additionalMetadata,_file,
165-
(SecurityContext)null
166-
);
167-
}
16843
}

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

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,85 +4,30 @@
44
import org.openapitools.model.*;
55

66

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

1011
import java.util.List;
1112
import org.openapitools.api.NotFoundException;
13+
1214
import java.io.InputStream;
1315

1416
import javax.validation.constraints.*;
1517
import javax.validation.Valid;
16-
1718
import javax.ws.rs.core.Response;
1819
import javax.ws.rs.core.SecurityContext;
1920

2021
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2122
public interface StoreApiService {
22-
Response deleteOrder(
23-
24-
String orderId,
25-
SecurityContext securityContext
26-
) throws NotFoundException;
27-
28-
default Response deleteOrder(
29-
30-
String orderId,
31-
String context
32-
) throws NotFoundException {
33-
return deleteOrder(
34-
35-
orderId,
36-
(SecurityContext)null
37-
);
38-
}
39-
Response getInventory(
40-
41-
SecurityContext securityContext
42-
) throws NotFoundException;
43-
44-
default Response getInventory(
45-
46-
String context
47-
) throws NotFoundException {
48-
return getInventory(
49-
50-
51-
(SecurityContext)null
52-
);
53-
}
54-
Response getOrderById(
55-
56-
Long orderId,
57-
SecurityContext securityContext
58-
) throws NotFoundException;
23+
Response deleteOrder(String orderId,SecurityContext securityContext)
24+
throws NotFoundException;
25+
Response getInventory(SecurityContext securityContext)
26+
throws NotFoundException;
27+
Response getOrderById(Long orderId,SecurityContext securityContext)
28+
throws NotFoundException;
29+
Response placeOrder(Order body,SecurityContext securityContext)
30+
throws NotFoundException;
5931

60-
default Response getOrderById(
61-
62-
Long orderId,
63-
String context
64-
) throws NotFoundException {
65-
return getOrderById(
66-
67-
orderId,
68-
(SecurityContext)null
69-
);
70-
}
71-
Response placeOrder(
72-
73-
Order body,
74-
SecurityContext securityContext
75-
) throws NotFoundException;
7632

77-
default Response placeOrder(
78-
79-
Order body,
80-
String context
81-
) throws NotFoundException {
82-
return placeOrder(
83-
84-
body,
85-
(SecurityContext)null
86-
);
87-
}
8833
}

0 commit comments

Comments
 (0)