Skip to content

Commit

Permalink
Merge pull request #224 from LiveRamp/develop
Browse files Browse the repository at this point in the history
Release 6.2.4
  • Loading branch information
nhtzr authored Dec 30, 2021
2 parents 84a9afd + 0a134fc commit 32bb91b
Show file tree
Hide file tree
Showing 18 changed files with 1,397 additions and 50 deletions.
4 changes: 4 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.2.4 12/30/2021

- Include flag `--oneof-polymorphism` to translate `union` reslang definitions into swagger `oneOf` field instead of `allOf`

## 6.2.3 11/23/2021

- Include the descriptions from `/events` syntax in the generated description for operations in asyncapi spec.
Expand Down
4 changes: 4 additions & 0 deletions models/polymorphism/api.reslang
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace {
title "Polymorphism example"
version 0.0.1
}
5 changes: 5 additions & 0 deletions models/polymorphism/diagrams.reslang
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

diagram main {
/include
resource.reslang
}
31 changes: 31 additions & 0 deletions models/polymorphism/resource.reslang
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
resource MyResource {
id: string
basic: BasicUnion
normal: NormalUnion

/operations
MULTIGET POST
}

union BasicUnion {
myFirstStruct: MyFirstStruct
}

structure MyFirstStruct {
attributeA: int
attributeB: int optional
}

union NormalUnion {
mySecondStruct: MySecondStruct
myThirdStruct: MyThirdStruct
}

structure MySecondStruct {
attributeC: string
attributeD: string optional
}

structure MyThirdStruct {
attributeE: string
}
1 change: 1 addition & 0 deletions models/polymorphism/testdata/asyncapi.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Error: No events are listed in the specification
28 changes: 28 additions & 0 deletions models/polymorphism/testdata/dotviz.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
digraph G {
graph [fontname = "helvetica"];
node [fontname = "helvetica"];
edge [fontname = "helvetica"];
node [shape=none];

"MyResource" [label=<
<table border="3" cellborder="0" cellspacing="1" style='rounded' bgcolor='#ffffcc'>
<tr><td><b>MyResource </b></td></tr><hr/><tr><td align="left">id: string</td></tr><tr><td align="left">basic: BasicUnion</td></tr><tr><td align="left">normal: NormalUnion</td></tr><tr><td align="right"><font color="#0000ff" point-size="8"> MULTIGET POST</font></td></tr></table>>];
"BasicUnion" [label=<
<table border="1" cellborder="0" cellspacing="1" style='dashed' >
<tr><td><b>BasicUnion </b></td></tr> </table> >];
"MyFirstStruct" [label=<
<table border="1" cellborder="0" cellspacing="1" >
<tr><td><b>MyFirstStruct </b></td></tr> <hr/><tr><td align="left">attributeA: int</td></tr><tr><td align="left">attributeB: int</td></tr></table> >];
"NormalUnion" [label=<
<table border="1" cellborder="0" cellspacing="1" style='dashed' >
<tr><td><b>NormalUnion </b></td></tr> </table> >];
"MySecondStruct" [label=<
<table border="1" cellborder="0" cellspacing="1" >
<tr><td><b>MySecondStruct </b></td></tr> <hr/><tr><td align="left">attributeC: string</td></tr><tr><td align="left">attributeD: string</td></tr></table> >];
"MyThirdStruct" [label=<
<table border="1" cellborder="0" cellspacing="1" >
<tr><td><b>MyThirdStruct </b></td></tr> <hr/><tr><td align="left">attributeE: string</td></tr></table> >];
"BasicUnion" -> "MyFirstStruct" [dir="back" arrowtail="diamond" label=< <font point-size="8"> myFirstStruct</font> >];
"NormalUnion" -> "MySecondStruct" [dir="back" arrowtail="diamond" label=< <font point-size="8"> mySecondStruct</font> >];
"NormalUnion" -> "MyThirdStruct" [dir="back" arrowtail="diamond" label=< <font point-size="8"> myThirdStruct</font> >];
}
170 changes: 170 additions & 0 deletions models/polymorphism/testdata/jsonschema.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
"$id": "https://schemas.liveramp.com/noroot",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"MyResourceInput": {
"type": "object",
"properties": {
"basic": {
"$ref": "#/definitions/BasicUnion",
"type": "object"
},
"normal": {
"$ref": "#/definitions/NormalUnion",
"type": "object"
}
},
"required": [
"basic",
"normal"
]
},
"MyResourceOutput": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"basic": {
"$ref": "#/definitions/BasicUnion",
"type": "object"
},
"normal": {
"$ref": "#/definitions/NormalUnion",
"type": "object"
}
},
"required": [
"id",
"basic",
"normal"
]
},
"MyResourceMultiResponse": {
"type": "object",
"properties": {
"myResources": {
"description": "Array of retrieved MyResources",
"type": "array",
"items": {
"$ref": "#/definitions/MyResourceOutput"
}
}
}
},
"BasicUnion": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
},
"discriminator": {
"propertyName": "type",
"mapping": {
"myFirstStruct": "#/definitions/BasicUnionMyFirstStruct"
}
},
"required": [
"type",
"attributeA"
]
},
"BasicUnionMyFirstStruct": {
"allOf": [
{
"$ref": "#/definitions/BasicUnion"
},
{
"type": "object",
"properties": {
"attributeA": {
"type": "integer",
"format": "int32"
},
"attributeB": {
"type": "integer",
"format": "int32"
}
}
}
]
},
"NormalUnion": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
},
"discriminator": {
"propertyName": "type",
"mapping": {
"mySecondStruct": "#/definitions/NormalUnionMySecondStruct",
"myThirdStruct": "#/definitions/NormalUnionMyThirdStruct"
}
},
"required": [
"type",
"attributeC",
"attributeE"
]
},
"NormalUnionMySecondStruct": {
"allOf": [
{
"$ref": "#/definitions/NormalUnion"
},
{
"type": "object",
"properties": {
"attributeC": {
"type": "string"
},
"attributeD": {
"type": "string"
}
}
}
]
},
"NormalUnionMyThirdStruct": {
"allOf": [
{
"$ref": "#/definitions/NormalUnion"
},
{
"type": "object",
"properties": {
"attributeE": {
"type": "string"
}
}
}
]
},
"StandardError": {
"type": "object",
"properties": {
"httpStatus": {
"description": "HTTP error status code for this problem",
"type": "integer",
"format": "int32"
},
"errorCode": {
"description": "Service specific error code, more granular",
"type": "string"
},
"message": {
"description": "General, human readable error message",
"type": "string"
}
},
"required": [
"httpStatus",
"errorCode",
"message"
]
}
}
}
Loading

0 comments on commit 32bb91b

Please sign in to comment.