-
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 #1584 from ballerina-platform/built-in-sub-type-1.7.x
[1.7.x] Add built-in subtype support in record fields for OAS generation
- Loading branch information
Showing
6 changed files
with
297 additions
and
6 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
79 changes: 79 additions & 0 deletions
79
...pi-cli/src/test/resources/ballerina-to-openapi/data_type/built_in_sub_types_in_record.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,79 @@ | ||
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; | ||
|}; | ||
|
||
type Unsigned8 int:Unsigned8; | ||
type Unsigned16 int:Unsigned16; | ||
type Unsigned32 int:Unsigned32; | ||
type Signed8 int:Signed8; | ||
type Signed16 int:Signed16; | ||
type Signed32 int:Signed32; | ||
type Char string:Char; | ||
type XmlElement xml:Element; | ||
type XmlComment xml:Comment; | ||
type XmlText xml:Text; | ||
type XmlProcessingInstruction xml:ProcessingInstruction; | ||
|
||
|
||
service /payloadV on new http:Listener(9090) { | ||
|
||
resource function get path1() 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` | ||
} | ||
}; | ||
} | ||
|
||
resource function get path2() returns Unsigned8|Unsigned16|Unsigned32| | ||
Signed8|Signed16|Signed32| | ||
XmlElement|XmlComment|XmlText|XmlProcessingInstruction| | ||
Char { | ||
|
||
return 32; | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
...t/resources/ballerina-to-openapi/expected_gen/data_type/built_in_sub_types_in_record.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,130 @@ | ||
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: | ||
/path1: | ||
get: | ||
operationId: getPath1 | ||
responses: | ||
"200": | ||
description: Ok | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/BalSubTypes' | ||
/path2: | ||
get: | ||
operationId: getPath2 | ||
responses: | ||
"200": | ||
description: Ok | ||
content: | ||
application/json: | ||
schema: | ||
oneOf: | ||
- $ref: '#/components/schemas/Unsigned8' | ||
- $ref: '#/components/schemas/Unsigned16' | ||
- $ref: '#/components/schemas/Unsigned32' | ||
- $ref: '#/components/schemas/Signed8' | ||
- $ref: '#/components/schemas/Signed16' | ||
- $ref: '#/components/schemas/Signed32' | ||
- $ref: '#/components/schemas/XmlElement' | ||
- $ref: '#/components/schemas/XmlComment' | ||
- $ref: '#/components/schemas/XmlText' | ||
- $ref: '#/components/schemas/XmlProcessingInstruction' | ||
- $ref: '#/components/schemas/Char' | ||
components: | ||
schemas: | ||
BalInts: | ||
required: | ||
- signed | ||
- unsigned | ||
type: object | ||
properties: | ||
signed: | ||
$ref: '#/components/schemas/BalSignedInts' | ||
unsigned: | ||
$ref: '#/components/schemas/BalUnsignedInts' | ||
Signed32: | ||
type: integer | ||
format: int32 | ||
Signed8: | ||
type: integer | ||
BalSubTypes: | ||
required: | ||
- char | ||
- ints | ||
- xmls | ||
type: object | ||
properties: | ||
char: | ||
type: string | ||
ints: | ||
$ref: '#/components/schemas/BalInts' | ||
xmls: | ||
$ref: '#/components/schemas/BalXmls' | ||
Unsigned8: | ||
type: integer | ||
Signed16: | ||
type: integer | ||
BalUnsignedInts: | ||
required: | ||
- unsigned16 | ||
- unsigned32 | ||
- unsigned8 | ||
type: object | ||
properties: | ||
unsigned32: | ||
type: integer | ||
unsigned16: | ||
type: integer | ||
unsigned8: | ||
type: integer | ||
XmlProcessingInstruction: | ||
type: object | ||
Unsigned32: | ||
type: integer | ||
BalXmls: | ||
required: | ||
- comment | ||
- element | ||
- processingInstruction | ||
- text | ||
type: object | ||
properties: | ||
comment: {} | ||
element: {} | ||
processingInstruction: {} | ||
text: {} | ||
Char: | ||
type: string | ||
XmlComment: | ||
type: object | ||
XmlElement: | ||
type: object | ||
BalSignedInts: | ||
required: | ||
- signed16 | ||
- signed32 | ||
- signed8 | ||
type: object | ||
properties: | ||
signed32: | ||
type: integer | ||
format: int32 | ||
signed16: | ||
type: integer | ||
signed8: | ||
type: integer | ||
Unsigned16: | ||
type: integer | ||
XmlText: | ||
type: object |