Skip to content

Commit de1dbe2

Browse files
Merge pull request ballerina-platform#1835 from SachinAkash01/align-improv
Fix the OpenAPI Tool Test Failures
1 parent 860a89a commit de1dbe2

132 files changed

Lines changed: 6366 additions & 7559 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

module-ballerina-openapi/CompilerPlugin.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id = "openapi-tools"
33
class = "io.ballerina.openapi.validator.OpenAPIValidatorPlugin"
44

55
[[dependency]]
6-
path = "../openapi-validator/build/libs/openapi-validator-2.3.1.jar"
6+
path = "../openapi-validator/build/libs/openapi-validator-2.3.1-SNAPSHOT.jar"
77
groupId = "ballerina"
88
artifactId = "openapi"
9-
version = "2.3.1"
9+
version = "2.3.1-SNAPSHOT"

openapi-cli/src/test/java/io/ballerina/openapi/cmd/BallerinaCodeGeneratorLicenseTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ public void testServiceGeneration() throws IOException {
118118
Assert.fail("Code generation failed. : " + readOutput(true));
119119
}
120120
}
121-
122121
@Test(description = "Test openapi to ballerina code generation with default file headers")
123122
public void testBothClientServiceGeneration() throws IOException {
124123
Path petstoreYaml = resourceDir.resolve(Paths.get("petstore.yaml"));
@@ -145,6 +144,7 @@ public void testBothClientServiceGeneration() throws IOException {
145144
}
146145
}
147146

147+
148148
@Test(description = "Test openapi to ballerina code generation with user provided license headers")
149149
public void testUserGivenLicenseHeader() throws IOException {
150150
Path petstoreYaml = resourceDir.resolve(Paths.get("petstore.yaml"));

openapi-cli/src/test/java/io/ballerina/openapi/generators/client/AllOfResponsesTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void getReturnTypeForAllOf() throws IOException, BallerinaOpenApiExceptio
5555
TypeHandler.createInstance(response, false);
5656
Operation post = response.getPaths().get("/users/{userId}/meetings").getPost();
5757
FunctionReturnTypeGeneratorImp functionReturnType = new FunctionReturnTypeGeneratorImp(post, response, "post");
58-
assertEquals(functionReturnType.getReturnType().get().type().toString(), "inline_response_201|error");
58+
assertEquals(functionReturnType.getReturnType().get().type().toString(), "inline_response_201|error?");
5959
}
6060

6161
@Test(description = "Tests for the object response without property")

openapi-cli/src/test/java/io/ballerina/openapi/generators/client/FunctionBodyNodeTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public Object[][] dataProviderForFunctionBody() {
104104
{"diagnostic_files/xml_payload_with_ref.yaml", "/pets", false, false, false,
105105
"{string resourcePath = string `/pets`;" +
106106
"http:Request request = new;" +
107-
"json jsonBody = payload.toJson();" +
107+
"json jsonBody = jsondata:toJson(payload);" +
108108
"xml? xmlBody = check xmldata:fromJson(jsonBody);" +
109109
"request.setPayload(xmlBody, \"application/xml\");" +
110110
"return self.clientEp->post(resourcePath, request);}"},
@@ -114,7 +114,7 @@ public Object[][] dataProviderForFunctionBody() {
114114
{"client/swagger/text_request_payload.yaml", "/pets", false, false, false,
115115
"{string resourcePath = string `/pets`;" +
116116
"http:Request request = new;" +
117-
"json jsonBody = payload.toJson();" +
117+
"json jsonBody = jsondata:toJson(payload);" +
118118
"request.setPayload(jsonBody, \"text/json\");" +
119119
"return self.clientEp->post(resourcePath, request);}"},
120120
{"client/swagger/pdf_payload.yaml", "/pets", false, false, false,
@@ -134,7 +134,8 @@ public Object[][] dataProviderForFunctionBody() {
134134
"X\\-Custom\\-Header}}, \"address\": {headers:{\"X-Address-Header\":X\\-Address\\-Header}}, " +
135135
"\"name\":" +
136136
"{contentType:\"text/plain\"}};\n" +
137-
"mime:Entity[] bodyParts = check createBodyParts(payload, encodingMap);\n" +
137+
"mime:Entity[] bodyParts = check createBodyParts(checkjsondata:toJson(payload).ensureType(), " +
138+
"encodingMap);\n" +
138139
"request.setBodyParts(bodyParts);\n" +
139140
" return self.clientEp->post(resourcePath, request);\n}"},
140141
{"client/swagger/empty_object_responnse.yaml", "/pets", false, false, false,

openapi-cli/src/test/java/io/ballerina/openapi/generators/common/TestConstants.java

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,35 @@ public class TestConstants {
1313
private static String commonClientConfigurationFields = "# The HTTP version understood by the client\n" +
1414
" http:HttpVersion httpVersion = http:HTTP_2_0;\n" +
1515
" # Configurations related to HTTP/1.x protocol\n" +
16-
" ClientHttp1Settings http1Settings?;\n" +
16+
" http:ClientHttp1Settings http1Settings = {};\n" +
1717
" # Configurations related to HTTP/2 protocol\n" +
18-
" http:ClientHttp2Settings http2Settings?;\n" +
18+
" http:ClientHttp2Settings http2Settings = {};\n" +
1919
" # The maximum time to wait (in seconds) for a response before closing the connection\n" +
20-
" decimal timeout = 60;\n" +
20+
" decimal timeout = 30;\n" +
2121
" # The choice of setting `forwarded`/`x-forwarded` header\n" +
2222
" string forwarded = \"disable\";\n" +
23+
" # Configurations associated with Redirection" +
24+
" http:FollowRedirects followRedirects?;" +
2325
" # Configurations associated with request pooling\n" +
2426
" http:PoolConfiguration poolConfig?;\n" +
2527
" # HTTP caching related configurations\n" +
26-
" http:CacheConfig cache?;\n" +
28+
" http:CacheConfig cache = {};\n" +
2729
" # Specifies the way of handling compression (`accept-encoding`) header\n" +
2830
" http:Compression compression = http:COMPRESSION_AUTO;\n" +
2931
" # Configurations associated with the behaviour of the Circuit Breaker\n" +
3032
" http:CircuitBreakerConfig circuitBreaker?;\n" +
3133
" # Configurations associated with retrying\n" +
3234
" http:RetryConfig retryConfig?;\n" +
35+
" # Configurations associated with cookies" +
36+
" http:CookieConfig cookieConfig?;" +
3337
" # Configurations associated with inbound response size limits\n" +
34-
" http:ResponseLimitConfigs responseLimits?;\n" +
38+
" http:ResponseLimitConfigs responseLimits = {};\n" +
3539
" # SSL/TLS-related options\n" +
3640
" http:ClientSecureSocket secureSocket?;\n" +
3741
" # Proxy server related options\n" +
3842
" http:ProxyConfig proxy?;\n" +
43+
" # Provides settings related to client socket configuration" +
44+
" http:ClientSocketConfig socketConfig = {};" +
3945
" # Enables the inbound payload validation functionality which provided by the constraint package. " +
4046
"Enabled by default\n" +
4147
" boolean validation = true;\n" +
@@ -188,29 +194,35 @@ public class TestConstants {
188194
" # The HTTP version understood by the client\n" +
189195
" http:HttpVersion httpVersion = http:HTTP_2_0;\n" +
190196
" # Configurations related to HTTP/1.x protocol\n" +
191-
" ClientHttp1Settings http1Settings?;\n" +
197+
" http:ClientHttp1Settings http1Settings = {};\n" +
192198
" # Configurations related to HTTP/2 protocol\n" +
193-
" http:ClientHttp2Settings http2Settings?;\n" +
199+
" http:ClientHttp2Settings http2Settings = {};\n" +
194200
" # The maximum time to wait (in seconds) for a response before closing the connection\n" +
195-
" decimal timeout = 60;\n" +
201+
" decimal timeout = 30;\n" +
196202
" # The choice of setting `forwarded`/`x-forwarded` header\n" +
197203
" string forwarded = \"disable\";\n" +
204+
" # Configurations associated with Redirection\n" +
205+
" http:FollowRedirects followRedirects?;\n" +
198206
" # Configurations associated with request pooling\n" +
199207
" http:PoolConfiguration poolConfig?;\n" +
200208
" # HTTP caching related configurations\n" +
201-
" http:CacheConfig cache?;\n" +
209+
" http:CacheConfig cache = {};\n" +
202210
" # Specifies the way of handling compression (`accept-encoding`) header\n" +
203211
" http:Compression compression = http:COMPRESSION_AUTO;\n" +
204212
" # Configurations associated with the behaviour of the Circuit Breaker\n" +
205213
" http:CircuitBreakerConfig circuitBreaker?;\n" +
206214
" # Configurations associated with retrying\n" +
207215
" http:RetryConfig retryConfig?;\n" +
216+
" # Configurations associated with cookies\n" +
217+
" http:CookieConfig cookieConfig?;\n" +
208218
" # Configurations associated with inbound response size limits\n" +
209-
" http:ResponseLimitConfigs responseLimits?;\n" +
219+
" http:ResponseLimitConfigs responseLimits = {};\n" +
210220
" # SSL/TLS-related options\n" +
211221
" http:ClientSecureSocket secureSocket?;\n" +
212222
" # Proxy server related options\n" +
213223
" http:ProxyConfig proxy?;\n" +
224+
" # Provides settings related to client socket configuration\n" +
225+
" http:ClientSocketConfig socketConfig = {};\n" +
214226
" # Enables the inbound payload validation functionality which provided by the constraint package. " +
215227
"Enabled by default\n" +
216228
" boolean validation = true;\n" +
@@ -230,29 +242,35 @@ public class TestConstants {
230242
" # The HTTP version understood by the client\n" +
231243
" http:HttpVersion httpVersion = http:HTTP_2_0;\n" +
232244
" # Configurations related to HTTP/1.x protocol\n" +
233-
" ClientHttp1Settings http1Settings?;\n" +
245+
" http:ClientHttp1Settings http1Settings = {};\n" +
234246
" # Configurations related to HTTP/2 protocol\n" +
235-
" http:ClientHttp2Settings http2Settings?;\n" +
247+
" http:ClientHttp2Settings http2Settings = {};\n" +
236248
" # The maximum time to wait (in seconds) for a response before closing the connection\n" +
237-
" decimal timeout = 60;\n" +
249+
" decimal timeout = 30;\n" +
238250
" # The choice of setting `forwarded`/`x-forwarded` header\n" +
239251
" string forwarded = \"disable\";\n" +
252+
" # Configurations associated with Redirection\n" +
253+
" http:FollowRedirects followRedirects?;\n" +
240254
" # Configurations associated with request pooling\n" +
241255
" http:PoolConfiguration poolConfig?;\n" +
242256
" # HTTP caching related configurations\n" +
243-
" http:CacheConfig cache?;\n" +
257+
" http:CacheConfig cache = {};\n" +
244258
" # Specifies the way of handling compression (`accept-encoding`) header\n" +
245259
" http:Compression compression = http:COMPRESSION_AUTO;\n" +
246260
" # Configurations associated with the behaviour of the Circuit Breaker\n" +
247261
" http:CircuitBreakerConfig circuitBreaker?;\n" +
248262
" # Configurations associated with retrying\n" +
249263
" http:RetryConfig retryConfig?;\n" +
264+
" # Configurations associated with cookies\n" +
265+
" http:CookieConfig cookieConfig?;\n" +
250266
" # Configurations associated with inbound response size limits\n" +
251-
" http:ResponseLimitConfigs responseLimits?;\n" +
267+
" http:ResponseLimitConfigs responseLimits = {};\n" +
252268
" # SSL/TLS-related options\n" +
253269
" http:ClientSecureSocket secureSocket?;\n" +
254270
" # Proxy server related options\n" +
255271
" http:ProxyConfig proxy?;\n" +
272+
" # Provides settings related to client socket configuration\n" +
273+
" http:ClientSocketConfig socketConfig={};\n" +
256274
" # Enables the inbound payload validation functionality which provided by the constraint package. " +
257275
"Enabled by default\n" +
258276
" boolean validation = true;\n" +
@@ -270,29 +288,35 @@ public class TestConstants {
270288
" # The HTTP version understood by the client\n" +
271289
" http:HttpVersion httpVersion = http:HTTP_1_1;\n" +
272290
" # Configurations related to HTTP/1.x protocol\n" +
273-
" ClientHttp1Settings http1Settings?;\n" +
291+
" http:ClientHttp1Settings http1Settings = {};\n" +
274292
" # Configurations related to HTTP/2 protocol\n" +
275-
" http:ClientHttp2Settings http2Settings?;\n" +
293+
" http:ClientHttp2Settings http2Settings = {};\n" +
276294
" # The maximum time to wait (in seconds) for a response before closing the connection\n" +
277-
" decimal timeout = 60;\n" +
295+
" decimal timeout = 30;\n" +
278296
" # The choice of setting `forwarded`/`x-forwarded` header\n" +
279297
" string forwarded = \"disable\";\n" +
298+
" # Configurations associated with Redirection" +
299+
" http:FollowRedirects followRedirects?;" +
280300
" # Configurations associated with request pooling\n" +
281301
" http:PoolConfiguration poolConfig?;\n" +
282302
" # HTTP caching related configurations\n" +
283-
" http:CacheConfig cache?;\n" +
303+
" http:CacheConfig cache = {};\n" +
284304
" # Specifies the way of handling compression (`accept-encoding`) header\n" +
285305
" http:Compression compression = http:COMPRESSION_AUTO;\n" +
286306
" # Configurations associated with the behaviour of the Circuit Breaker\n" +
287307
" http:CircuitBreakerConfig circuitBreaker?;\n" +
288308
" # Configurations associated with retrying\n" +
289309
" http:RetryConfig retryConfig?;\n" +
310+
" # Configurations associated with cookies" +
311+
" http:CookieConfig cookieConfig?;" +
290312
" # Configurations associated with inbound response size limits\n" +
291-
" http:ResponseLimitConfigs responseLimits?;\n" +
313+
" http:ResponseLimitConfigs responseLimits = {};\n" +
292314
" # SSL/TLS-related options\n" +
293315
" http:ClientSecureSocket secureSocket?;\n" +
294316
" # Proxy server related options\n" +
295317
" http:ProxyConfig proxy?;\n" +
318+
" # Provides settings related to client socket configuration" +
319+
" http:ClientSocketConfig socketConfig = {};" +
296320
" # Enables the inbound payload validation functionality which provided by the constraint package. " +
297321
" Enabled by default\n" +
298322
" boolean validation = true;\n" +

0 commit comments

Comments
 (0)