From cf8530ba60057fbe4b52098856996cbfcad974db Mon Sep 17 00:00:00 2001 From: lnash94 Date: Wed, 10 Apr 2024 15:43:09 +0530 Subject: [PATCH] Update openapi tests --- .../OpenAPIDistributionArtifactCheck.java | 10 +- .../resources/openapi/expected/client.bal | 9 +- .../openapi/expected/filtered_tags.bal | 3 +- .../test/resources/openapi/expected/types.bal | 101 +++++++++--------- gradle.properties | 2 +- 5 files changed, 61 insertions(+), 64 deletions(-) diff --git a/ballerina-test/src/test/java/org/ballerinalang/distribution/test/OpenAPIDistributionArtifactCheck.java b/ballerina-test/src/test/java/org/ballerinalang/distribution/test/OpenAPIDistributionArtifactCheck.java index 85d696058d..5c1796899f 100644 --- a/ballerina-test/src/test/java/org/ballerinalang/distribution/test/OpenAPIDistributionArtifactCheck.java +++ b/ballerina-test/src/test/java/org/ballerinalang/distribution/test/OpenAPIDistributionArtifactCheck.java @@ -52,7 +52,7 @@ public void openapiAnnotationExistsTest() { .resolve("cache") .resolve("ballerina") .resolve("openapi") - .resolve("1.8.0") + .resolve("1.9.0") .resolve("bir"); Path jarPath = TEST_DISTRIBUTION_PATH @@ -61,7 +61,7 @@ public void openapiAnnotationExistsTest() { .resolve("cache") .resolve("ballerina") .resolve("openapi") - .resolve("1.8.0") + .resolve("1.9.0") .resolve("java17"); Path balaPath = TEST_DISTRIBUTION_PATH @@ -70,7 +70,7 @@ public void openapiAnnotationExistsTest() { .resolve("bala") .resolve("ballerina") .resolve("openapi") - .resolve("1.8.0") + .resolve("1.9.0") .resolve("java17") .resolve("platform") .resolve("java17"); @@ -95,10 +95,10 @@ public void openapiAnnotationExistsTest() { Assert.assertTrue(Files.exists(birPath)); Assert.assertTrue(Files.exists(balaPath)); - Assert.assertTrue(Files.exists(jarPath.resolve("ballerina-openapi-1.8.0.jar"))); + Assert.assertTrue(Files.exists(jarPath.resolve("ballerina-openapi-1.9.0.jar"))); Assert.assertNotNull(TestUtils.findFileOrDirectory(breLibPath, "openapi-cli-")); Assert.assertNotNull(TestUtils.findFileOrDirectory(breLibPath, "openapi-validator-")); - Assert.assertNotNull(TestUtils.findFileOrDirectory(breLibPath, "openapi-bal-service-")); + Assert.assertNotNull(TestUtils.findFileOrDirectory(breLibPath, "ballerina-to-openapi-")); Assert.assertNotNull(TestUtils.findFileOrDirectory(languageExtension, "openapi-ls-")); Assert.assertTrue(Files.exists(docsPath)); } diff --git a/ballerina-test/src/test/resources/openapi/expected/client.bal b/ballerina-test/src/test/resources/openapi/expected/client.bal index 51348a0dfd..ecd6433a87 100644 --- a/ballerina-test/src/test/resources/openapi/expected/client.bal +++ b/ballerina-test/src/test/resources/openapi/expected/client.bal @@ -1,6 +1,5 @@ // AUTO-GENERATED FILE. DO NOT MODIFY. // This file is auto-generated by the Ballerina OpenAPI tool. - import ballerina/http; # The Stripe REST API. Please see https://stripe.com/docs/api for more details. @@ -38,6 +37,7 @@ public isolated client class Client { self.clientEp = httpEp; return; } + # Retrieves a PaymentMethod object. # # + payment_method - Payment Method @@ -50,9 +50,9 @@ public isolated client class Client { resourcePath = resourcePath + check getPathForQueryParam(queryParam); map headerValues = {"X-LIMIT": xLimit}; map httpHeaders = getMapForHeaders(headerValues); - json response = check self.clientEp->get(resourcePath, httpHeaders); - return response; + return self.clientEp->get(resourcePath, httpHeaders); } + # Creates a new customer object. # # + customer - Customer ID @@ -64,7 +64,6 @@ public isolated client class Client { map requestBodyEncoding = {"address": {style: DEEPOBJECT, explode: true}}; string encodedRequestBody = createFormURLEncodedRequestBody(payload, requestBodyEncoding); request.setPayload(encodedRequestBody, "application/x-www-form-urlencoded"); - Customer response = check self.clientEp->post(resourcePath, request); - return response; + return self.clientEp->post(resourcePath, request); } } diff --git a/ballerina-test/src/test/resources/openapi/expected/filtered_tags.bal b/ballerina-test/src/test/resources/openapi/expected/filtered_tags.bal index 0ae81c7422..f8bda7b4bb 100644 --- a/ballerina-test/src/test/resources/openapi/expected/filtered_tags.bal +++ b/ballerina-test/src/test/resources/openapi/expected/filtered_tags.bal @@ -1,6 +1,5 @@ // AUTO-GENERATED FILE. // This file is auto-generated by the Ballerina OpenAPI tool. - import ballerina/http; listener http:Listener ep0 = new (80, config = {host: "petstore.openapi.io"}); @@ -10,7 +9,7 @@ service /v1 on ep0 { # # + 'limit - How many items to return at one time (max 100) # + return - returns can be any of following types - # Pets (An paged array of pets) + # http:Ok (An paged array of pets) # http:Response (unexpected error) resource function get pets(int:Signed32? 'limit) returns Pets|http:Response { } diff --git a/ballerina-test/src/test/resources/openapi/expected/types.bal b/ballerina-test/src/test/resources/openapi/expected/types.bal index 68ab1456e2..c0f5bab44a 100644 --- a/ballerina-test/src/test/resources/openapi/expected/types.bal +++ b/ballerina-test/src/test/resources/openapi/expected/types.bal @@ -1,9 +1,58 @@ // AUTO-GENERATED FILE. DO NOT MODIFY. // This file is auto-generated by the Ballerina OpenAPI tool. - import ballerina/constraint; import ballerina/http; +public type Customer_customer_body record { + Customer_address address?; + # An integer amount in %s that represents the customer's current balance, which affect the customer's future invoices. A negative amount represents a credit that decreases the amount due on an invoice; a positive amount increases the amount due on an invoice. + int balance?; +}; + +public type Customer_address record { + @constraint:String {maxLength: 5000} + string city?; + @constraint:String {maxLength: 5000} + string country?; + @constraint:String {maxLength: 5000} + string line1?; + @constraint:String {maxLength: 5000} + string line2?; + @constraint:String {maxLength: 5000} + string postal_code?; + @constraint:String {maxLength: 5000} + string state?; +}; + +public type Customer record { + # The customer's address. + Customer_address? address?; + string name?; +}; + +# Provides settings related to HTTP/1.x protocol. +public type ClientHttp1Settings record {| + # Specifies whether to reuse a connection for multiple requests + http:KeepAlive keepAlive = http:KEEPALIVE_AUTO; + # The chunking behaviour of the request + http:Chunking chunking = http:CHUNKING_AUTO; + # Proxy server related options + ProxyConfig proxy?; +|}; + +# Proxy server configurations to be used with the HTTP client endpoint. +public type ProxyConfig record {| + # Host name of the proxy server + string host = ""; + # Proxy server port + int port = 0; + # Proxy server username + string userName = ""; + # Proxy server password + @display {label: "", kind: "password"} + string password = ""; +|}; + # Provides a set of configurations for controlling the behaviours when communicating with a remote HTTP endpoint. @display {label: "Connection Config"} public type ConnectionConfig record {| @@ -38,53 +87,3 @@ public type ConnectionConfig record {| # Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default boolean validation = true; |}; - -# Provides settings related to HTTP/1.x protocol. -public type ClientHttp1Settings record {| - # Specifies whether to reuse a connection for multiple requests - http:KeepAlive keepAlive = http:KEEPALIVE_AUTO; - # The chunking behaviour of the request - http:Chunking chunking = http:CHUNKING_AUTO; - # Proxy server related options - ProxyConfig proxy?; -|}; - -# Proxy server configurations to be used with the HTTP client endpoint. -public type ProxyConfig record {| - # Host name of the proxy server - string host = ""; - # Proxy server port - int port = 0; - # Proxy server username - string userName = ""; - # Proxy server password - @display {label: "", kind: "password"} - string password = ""; -|}; - -public type Customer_customer_body record { - Customer_address address?; - # An integer amount in %s that represents the customer's current balance, which affect the customer's future invoices. A negative amount represents a credit that decreases the amount due on an invoice; a positive amount increases the amount due on an invoice. - int balance?; -}; - -public type Customer_address record { - @constraint:String {maxLength: 5000} - string city?; - @constraint:String {maxLength: 5000} - string country?; - @constraint:String {maxLength: 5000} - string line1?; - @constraint:String {maxLength: 5000} - string line2?; - @constraint:String {maxLength: 5000} - string postal_code?; - @constraint:String {maxLength: 5000} - string state?; -}; - -public type Customer record { - # The customer's address. - Customer_address? address?; - string name?; -}; diff --git a/gradle.properties b/gradle.properties index e582cbeac1..ddd95e4722 100644 --- a/gradle.properties +++ b/gradle.properties @@ -89,7 +89,7 @@ graphqlVersion=0.8.1 protocToolVersion=0.2.0-20230821-121200-8933a55 # OpenAPI Module -openapiVersion=1.8.0-20230901-175200-ccab317 +openapiVersion=1.9.0-20240410-132300-187429e # AsyncAPI Module asyncapiVersion=0.6.0