Skip to content

Commit

Permalink
Merge pull request #5305 from lnash94/master
Browse files Browse the repository at this point in the history
[master] Update OpenAPI tests
  • Loading branch information
LakshanWeerasinghe authored Apr 10, 2024
2 parents ed0003a + cf8530b commit ff30aa6
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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");
Expand All @@ -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));
}
Expand Down
9 changes: 4 additions & 5 deletions ballerina-test/src/test/resources/openapi/expected/client.bal
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -38,6 +37,7 @@ public isolated client class Client {
self.clientEp = httpEp;
return;
}

# Retrieves a PaymentMethod object.
#
# + payment_method - Payment Method
Expand All @@ -50,9 +50,9 @@ public isolated client class Client {
resourcePath = resourcePath + check getPathForQueryParam(queryParam);
map<any> headerValues = {"X-LIMIT": xLimit};
map<string|string[]> 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
Expand All @@ -64,7 +64,6 @@ public isolated client class Client {
map<Encoding> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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"});
Expand All @@ -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 {
}
Expand Down
101 changes: 50 additions & 51 deletions ballerina-test/src/test/resources/openapi/expected/types.bal
Original file line number Diff line number Diff line change
@@ -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 {|
Expand Down Expand Up @@ -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?;
};
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff30aa6

Please sign in to comment.