-
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 #1739 from lnash94/test_example_improvements
[master]Add tests for example mapping
- Loading branch information
Showing
15 changed files
with
242 additions
and
11 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
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
1 change: 1 addition & 0 deletions
1
...-integration-tests/src/test/resources/ballerina_sources/examples/negative_test/.gitignore
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 @@ | ||
target |
8 changes: 8 additions & 0 deletions
8
...egration-tests/src/test/resources/ballerina_sources/examples/negative_test/Ballerina.toml
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,8 @@ | ||
[package] | ||
org = "openapi_example" | ||
name = "negative" | ||
version = "0.1.0" | ||
|
||
[build-options] | ||
observabilityIncluded = true | ||
|
7 changes: 7 additions & 0 deletions
7
...ntegration-tests/src/test/resources/ballerina_sources/examples/negative_test/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: "EUR", | ||
"toCurrency": "LKR", | ||
"fromAmount": 200, | ||
"toAmount": 60000, | ||
"timestamp": "2024-07-14" | ||
} |
41 changes: 41 additions & 0 deletions
41
...integration-tests/src/test/resources/ballerina_sources/examples/negative_test/service.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,41 @@ | ||
import ballerina/http; | ||
import ballerina/openapi; | ||
|
||
listener http:Listener httpListener = check new (9000); | ||
|
||
final http:Client xeClientSimple = check new ("https://xecdapi.xe.com/v1"); | ||
|
||
service /convert on httpListener { | ||
|
||
@openapi:ResourceInfo { | ||
examples: { | ||
"response": { | ||
"201": { | ||
"examples": { | ||
"application/json": { | ||
"responseExample01": { | ||
"filePath": "examples01.json" | ||
}, | ||
"responseExample02": { | ||
"filePath": "example.json" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"requestBody": { | ||
"application/json": { | ||
requestExample01: { | ||
"value": { | ||
"fromCurrancy": "LKR", | ||
"toCurrancy": "USD" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
resource function post rate(record {} payload) returns record {}? { | ||
return {}; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...tegration-tests/src/test/resources/ballerina_sources/examples/response_example/.gitignore
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 @@ | ||
target |
8 changes: 8 additions & 0 deletions
8
...ation-tests/src/test/resources/ballerina_sources/examples/response_example/Ballerina.toml
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,8 @@ | ||
[package] | ||
org = "openapi_example" | ||
name = "negative" | ||
version = "0.1.0" | ||
|
||
[build-options] | ||
observabilityIncluded = true | ||
|
7 changes: 7 additions & 0 deletions
7
...gration-tests/src/test/resources/ballerina_sources/examples/response_example/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": "EUR", | ||
"toCurrency": "LKR", | ||
"fromAmount": 200, | ||
"toAmount": 60000, | ||
"timestamp": "2024-07-14" | ||
} |
76 changes: 76 additions & 0 deletions
76
...egration-tests/src/test/resources/ballerina_sources/examples/response_example/result.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,76 @@ | ||
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: | ||
fromCurrancy: LKR | ||
toCurrancy: USD | ||
required: true | ||
responses: | ||
"201": | ||
description: Created | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: {} | ||
examples: | ||
responseExample01: | ||
value: | ||
toAmount: 60000 | ||
fromCurrency: 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 |
38 changes: 38 additions & 0 deletions
38
...egration-tests/src/test/resources/ballerina_sources/examples/response_example/service.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,38 @@ | ||
import ballerina/http; | ||
import ballerina/openapi; | ||
|
||
listener http:Listener httpListener = check new (9000); | ||
|
||
final http:Client xeClientSimple = check new ("https://xecdapi.xe.com/v1"); | ||
|
||
service /convert on httpListener { | ||
|
||
@openapi:ResourceInfo { | ||
examples: { | ||
"response": { | ||
"201": { | ||
"examples": { | ||
"application/json": { | ||
"responseExample01": { | ||
"filePath": "example.json" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"requestBody": { | ||
"application/json": { | ||
"requestExample01": { | ||
"value": { | ||
"fromCurrancy": "LKR", | ||
"toCurrancy": "USD" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
resource function post rate(record {} payload) returns record {}? { | ||
return {}; | ||
} | ||
} |