Skip to content

Commit 931e1d6

Browse files
Merge remote-tracking branch 'upstream/master' into shri
2 parents d70217f + 1feddbd commit 931e1d6

File tree

8 files changed

+65
-29
lines changed

8 files changed

+65
-29
lines changed

.all-contributorsrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,17 @@
10411041
"contributions": [
10421042
"doc"
10431043
]
1044+
},
1045+
{
1046+
"login": "jonjomckay",
1047+
"name": "Jonjo McKay",
1048+
"avatar_url": "https://avatars.githubusercontent.com/u/456645?v=4",
1049+
"profile": "https://jonjomckay.com",
1050+
"contributions": [
1051+
"code",
1052+
"bug",
1053+
"test"
1054+
]
10441055
}
10451056
],
10461057
"contributorsPerLine": 7,

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![Discussions](https://img.shields.io/github/discussions/asyncapi/modelina)](https://github.com/asyncapi/modelina/discussions)
1010
[![Website](https://img.shields.io/website?label=website&url=https%3A%2F%2Fwww.modelina.org)](https://www.modelina.org)
1111
[![Playground](https://img.shields.io/website?label=playground&url=https%3A%2F%2Fwww.modelina.org%2Fplayground)](https://www.modelina.org/playground) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
12-
[![All Contributors](https://img.shields.io/badge/all_contributors-96-orange.svg?style=flat-square)](#contributors-)
12+
[![All Contributors](https://img.shields.io/badge/all_contributors-97-orange.svg?style=flat-square)](#contributors-)
1313
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1414

1515
Your one-stop tool for generating accurate and well-tested models for representing the message payloads. Use it as a tool in your development workflow, or a library in a larger integrations, entirely in your control.
@@ -446,6 +446,7 @@ Thanks go out to these wonderful people ([emoji key](https://allcontributors.org
446446
<td align="center" valign="top" width="14.28%"><a href="https://github.com/memdal"><img src="https://avatars.githubusercontent.com/u/77838566?v=4?s=100" width="100px;" alt="memdal"/><br /><sub><b>memdal</b></sub></a><br /><a href="https://github.com/asyncapi/modelina/commits?author=memdal" title="Code">💻</a> <a href="https://github.com/asyncapi/modelina/commits?author=memdal" title="Tests">⚠️</a></td>
447447
<td align="center" valign="top" width="14.28%"><a href="https://github.com/maxplatov"><img src="https://avatars.githubusercontent.com/u/14889696?v=4?s=100" width="100px;" alt="maxplatov"/><br /><sub><b>maxplatov</b></sub></a><br /><a href="https://github.com/asyncapi/modelina/pulls?q=is%3Apr+reviewed-by%3Amaxplatov" title="Reviewed Pull Requests">👀</a></td>
448448
<td align="center" valign="top" width="14.28%"><a href="https://github.com/emmanuel-ferdman"><img src="https://avatars.githubusercontent.com/u/35470921?v=4?s=100" width="100px;" alt="Emmanuel Ferdman"/><br /><sub><b>Emmanuel Ferdman</b></sub></a><br /><a href="https://github.com/asyncapi/modelina/commits?author=emmanuel-ferdman" title="Documentation">📖</a></td>
449+
<td align="center" valign="top" width="14.28%"><a href="https://jonjomckay.com"><img src="https://avatars.githubusercontent.com/u/456645?v=4?s=100" width="100px;" alt="Jonjo McKay"/><br /><sub><b>Jonjo McKay</b></sub></a><br /><a href="https://github.com/asyncapi/modelina/commits?author=jonjomckay" title="Code">💻</a> <a href="https://github.com/asyncapi/modelina/issues?q=author%3Ajonjomckay" title="Bug reports">🐛</a> <a href="https://github.com/asyncapi/modelina/commits?author=jonjomckay" title="Tests">⚠️</a></td>
449450
</tr>
450451
</tbody>
451452
</table>

examples/integrate-with-next/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/integrate-with-react/package-lock.json

Lines changed: 30 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@asyncapi/modelina",
3-
"version": "3.8.0",
3+
"version": "3.10.0",
44
"description": "Library for generating data models based on inputs such as AsyncAPI, OpenAPI, or JSON Schema documents",
55
"license": "Apache-2.0",
66
"homepage": "https://www.modelina.org",

src/generators/typescript/presets/utils/UnmarshalFunction.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { ClassRenderer } from '../../renderers/ClassRenderer';
22
import { getDictionary, getNormalProperties } from '../../../../helpers';
33
import {
4+
ConstrainedArrayModel,
45
ConstrainedDictionaryModel,
56
ConstrainedEnumModel,
67
ConstrainedMetaModel,
78
ConstrainedObjectModel,
89
ConstrainedObjectPropertyModel,
9-
ConstrainedReferenceModel
10+
ConstrainedReferenceModel,
11+
ConstrainedUnionModel
1012
} from '../../../../models';
1113

1214
/**
@@ -22,6 +24,16 @@ function renderUnmarshalProperty(
2224
) {
2325
return `${model.type}.unmarshal(${modelInstanceVariable})`;
2426
}
27+
28+
if (
29+
model instanceof ConstrainedArrayModel &&
30+
!(model.valueModel instanceof ConstrainedUnionModel)
31+
) {
32+
return `${modelInstanceVariable} == null
33+
? null
34+
: ${modelInstanceVariable}.map((item: any) => ${model.valueModel.type}.unmarshal(item))`;
35+
}
36+
2537
return `${modelInstanceVariable}`;
2638
}
2739

test/generators/typescript/preset/__snapshots__/MarshallingPreset.spec.ts.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ exports[`Marshalling preset should render un/marshal code 1`] = `
158158
instance.unionArrayTest = obj[\\"unionArrayTest\\"];
159159
}
160160
if (obj[\\"arrayTest\\"] !== undefined) {
161-
instance.arrayTest = obj[\\"arrayTest\\"];
161+
instance.arrayTest = obj[\\"arrayTest\\"] == null
162+
? null
163+
: obj[\\"arrayTest\\"].map((item: any) => NestedTest.unmarshal(item));
162164
}
163165
if (obj[\\"tupleTest\\"] !== undefined) {
164166
instance.tupleTest = obj[\\"tupleTest\\"];

0 commit comments

Comments
 (0)