-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1753 from lnash94/regression_issues
[master]Fix some regression issues in RC1 pack
- Loading branch information
Showing
11 changed files
with
321 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
openapi-cli/src/test/java/io/ballerina/openapi/generators/openapi/ExampleTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package io.ballerina.openapi.generators.openapi; | ||
|
||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.AfterTest; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
/** | ||
* This test class for the covering the unit tests for example mapping scenarios. | ||
*/ | ||
public class ExampleTests { | ||
private static final Path RES_DIR = Paths.get("src/test/resources/ballerina-to-openapi").toAbsolutePath(); | ||
private Path tempDir; | ||
|
||
@BeforeMethod | ||
public void setup() throws IOException { | ||
this.tempDir = Files.createTempDirectory("bal-to-openapi-test-out-" + System.nanoTime()); | ||
} | ||
|
||
//TODO: Enable this test once the openapi package is published with new changes | ||
@Test(description = "Resource function api doc mapped to OAS operation summary", enabled = false) | ||
public void testsForResourceFunction() throws IOException { | ||
Path ballerinaFilePath = RES_DIR.resolve("metainfo/examples/resource_annotation_examples.bal"); | ||
TestUtils.compareWithGeneratedFile(ballerinaFilePath, "metainfo/examples/" + | ||
"resource_annotation_examples.yaml"); | ||
} | ||
|
||
@AfterMethod | ||
public void cleanUp() { | ||
TestUtils.deleteDirectory(this.tempDir); | ||
} | ||
|
||
@AfterTest | ||
public void clean() { | ||
System.setErr(null); | ||
System.setOut(null); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
openapi-cli/src/test/resources/ballerina-to-openapi/metainfo/examples/example.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"fromCurrency": "Same-EUR", | ||
"toCurrency": "LKR", | ||
"fromAmount": 200, | ||
"toAmount": 60000, | ||
"timestamp": "2024-07-14" | ||
} |
69 changes: 69 additions & 0 deletions
69
...rc/test/resources/ballerina-to-openapi/metainfo/examples/resource_annotation_examples.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import ballerina/http; | ||
import ballerina/openapi; | ||
|
||
listener http:Listener httpListener = check new (9000); | ||
|
||
service /convert on httpListener { | ||
|
||
@openapi:ResourceInfo { | ||
examples: { | ||
"response": { | ||
"201": { | ||
"examples": { | ||
"application/json": { | ||
"json01": { | ||
"filePath": "example.json" | ||
}, | ||
"json02": { | ||
"value": { | ||
"fromCurrency": "EUR", | ||
"toCurrency": "LKR", | ||
"fromAmount": 200, | ||
"toAmount": 60000, | ||
"timestamp": "2024-07-14" | ||
} | ||
} | ||
// "json03": { | ||
// "filePath": "example.json" | ||
// }, | ||
}, | ||
"application/xml": { | ||
"xml1": { | ||
"filePath": "example.json" | ||
}, | ||
"xml2": { | ||
"value": { | ||
"fromCurrency": "EUR", | ||
"toCurrency": "LKR", | ||
"fromAmount": 200, | ||
"toAmount": 60000, | ||
"timestamp": "2024-07-14" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"requestBody": { | ||
"application/json": { | ||
"requestExample01": { | ||
"filePath": "example.json" | ||
}, | ||
"requestExample02": { | ||
"value": { | ||
"fromCurrancy": "LKR", | ||
"toCurrancy": "USD" //comment | ||
} | ||
} | ||
// "requestExample03": { | ||
// "filePath": "example.json" | ||
// }, | ||
} | ||
} | ||
|
||
} | ||
} | ||
resource function post rate(record {} payload) returns record {}|xml? { | ||
return {}; | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
...c/test/resources/ballerina-to-openapi/metainfo/examples/resource_annotation_examples.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: Convert | ||
version: 0.1.0 | ||
servers: | ||
- url: "{server}:{port}/convert" | ||
variables: | ||
server: | ||
default: http://localhost | ||
port: | ||
default: "9000" | ||
paths: | ||
/rate: | ||
post: | ||
operationId: postRate | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: {} | ||
examples: | ||
requestExample01: | ||
value: | ||
toAmount: 60000 | ||
fromCurrency: Same-EUR | ||
toCurrency: LKR | ||
fromAmount: 200 | ||
timestamp: 2024-07-14 | ||
requestExample02: | ||
value: | ||
fromCurrancy: LKR | ||
toCurrancy: USD | ||
required: true | ||
responses: | ||
"201": | ||
description: Created | ||
content: | ||
application/xml: | ||
schema: | ||
type: object | ||
examples: | ||
xml1: | ||
value: | ||
toAmount: 60000 | ||
fromCurrency: Same-EUR | ||
toCurrency: LKR | ||
fromAmount: 200 | ||
timestamp: 2024-07-14 | ||
xml2: | ||
value: | ||
fromCurrency: EUR | ||
toCurrency: LKR | ||
fromAmount: 200 | ||
toAmount: 60000 | ||
timestamp: 2024-07-14 | ||
application/json: | ||
schema: | ||
type: object | ||
properties: {} | ||
examples: | ||
json02: | ||
value: | ||
fromCurrency: EUR | ||
toCurrency: LKR | ||
fromAmount: 200 | ||
toAmount: 60000 | ||
timestamp: 2024-07-14 | ||
json01: | ||
value: | ||
toAmount: 60000 | ||
fromCurrency: Same-EUR | ||
toCurrency: LKR | ||
fromAmount: 200 | ||
timestamp: 2024-07-14 | ||
"202": | ||
description: Accepted | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ErrorPayload' | ||
components: | ||
schemas: | ||
ErrorPayload: | ||
required: | ||
- message | ||
- method | ||
- path | ||
- reason | ||
- status | ||
- timestamp | ||
type: object | ||
properties: | ||
timestamp: | ||
type: string | ||
status: | ||
type: integer | ||
format: int64 | ||
reason: | ||
type: string | ||
message: | ||
type: string | ||
path: | ||
type: string | ||
method: | ||
type: string |
2 changes: 1 addition & 1 deletion
2
openapi-cli/src/test/resources/generators/client/mock/reference_example.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.