Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
TharmiganK committed Dec 15, 2023
1 parent e1e28a9 commit e8b5663
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public void testForTupleType() throws IOException {
TestUtils.compareWithGeneratedFile(ballerinaFilePath, "data_type/tuple_type.yaml");
}

@Test(description = "test for Ballerina built-in subtypes as record fields")
public void testForBuiltInSubTypes() throws IOException {
Path ballerinaFilePath = RES_DIR.resolve("data_type/built_in_sub_types_in_record.bal");
TestUtils.compareWithGeneratedFile(ballerinaFilePath, "data_type/built_in_sub_types_in_record.yaml");
}

@AfterMethod
public void cleanUp() {
TestUtils.deleteDirectory(this.tempDir);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import ballerina/http;

public type BalSignedInts record {|
int:Signed32 signed32;
int:Signed16 signed16;
int:Signed8 signed8;
|};

public type BalUnsignedInts record {|
int:Unsigned32 unsigned32;
int:Unsigned16 unsigned16;
int:Unsigned8 unsigned8;
|};

public type BalInts record {|
BalSignedInts signed;
BalUnsignedInts unsigned;
|};

public type BalXmls record {|
xml:Comment comment;
xml:Element element;
xml:ProcessingInstruction processingInstruction;
xml:Text text;
|};

public type BalSubTypes record {|
string:Char char;
BalInts ints;
BalXmls xmls;
|};

service /payloadV on new http:Listener(9090) {

resource function get path() returns BalSubTypes {
return {
char: "a",
ints: {
signed: {
signed32: 32,
signed16: 16,
signed8: 8
},
unsigned: {
unsigned32: 32,
unsigned16: 16,
unsigned8: 8
}
},
xmls: {
comment: xml`<!-- comment -->`,
element: xml`<element>element</element>`,
processingInstruction: xml`<?processing instruction?>`,
text: xml`text`
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
openapi: 3.0.1
info:
title: PayloadV
version: 0.0.0
servers:
- url: "{server}:{port}/payloadV"
variables:
server:
default: http://localhost
port:
default: "9090"
paths:
/path:
get:
operationId: getPath
responses:
"200":
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/BalSubTypes'
components:
schemas:
BalSubTypes:
required:
- char
- ints
- xmls
type: object
properties:
char:
type: string
ints:
$ref: '#/components/schemas/BalInts'
xmls:
$ref: '#/components/schemas/BalXmls'
BalUnsignedInts:
required:
- unsigned16
- unsigned32
- unsigned8
type: object
properties:
unsigned32:
type: integer
unsigned16:
type: integer
unsigned8:
type: integer
BalXmls:
required:
- comment
- element
- processingInstruction
- text
type: object
properties:
comment:
type: object
element:
type: object
processingInstruction:
type: object
text:
type: object
BalInts:
required:
- signed
- unsigned
type: object
properties:
signed:
$ref: '#/components/schemas/BalSignedInts'
unsigned:
$ref: '#/components/schemas/BalUnsignedInts'
BalSignedInts:
required:
- signed16
- signed32
- signed8
type: object
properties:
signed32:
type: integer
format: int32
signed16:
type: integer
signed8:
type: integer

0 comments on commit e8b5663

Please sign in to comment.