Skip to content

Commit ce045db

Browse files
jonaslagonifr-thasyncapi-botasyncapi-botallcontributors[bot]
authored
chore: update next with master (#2160)
Co-authored-by: fr-th <61010557+fr-th@users.noreply.github.com> Co-authored-by: asyncapi-bot <bot+chan@asyncapi.io> Co-authored-by: asyncapi-bot <info@asyncapi.io> Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: Jesse Wayde Brandão <jesse.brandao@fusionpowered.io>
1 parent 6a958a0 commit ce045db

File tree

16 files changed

+1632
-1776
lines changed

16 files changed

+1632
-1776
lines changed

.all-contributorsrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,17 @@
10721072
"contributions": [
10731073
"code"
10741074
]
1075+
},
1076+
{
1077+
"login": "fr-th",
1078+
"name": "fr-th",
1079+
"avatar_url": "https://avatars.githubusercontent.com/u/61010557?v=4",
1080+
"profile": "https://github.com/fr-th",
1081+
"contributions": [
1082+
"code",
1083+
"test",
1084+
"doc"
1085+
]
10751086
}
10761087
],
10771088
"contributorsPerLine": 7,

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![Discussions](https://img.shields.io/github/discussions/asyncapi/modelina)](https://github.com/asyncapi/modelina/discussions)
99
[![Website](https://img.shields.io/website?label=website&url=https%3A%2F%2Fwww.modelina.org)](https://www.modelina.org)
1010
[![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 -->
11-
[![All Contributors](https://img.shields.io/badge/all_contributors-99-orange.svg?style=flat-square)](#contributors-)
11+
[![All Contributors](https://img.shields.io/badge/all_contributors-100-orange.svg?style=flat-square)](#contributors-)
1212
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1313

1414

@@ -452,6 +452,7 @@ Thanks go out to these wonderful people ([emoji key](https://allcontributors.org
452452
</tr>
453453
<tr>
454454
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Shriya-Chauhan"><img src="https://avatars.githubusercontent.com/u/78415084?v=4?s=100" width="100px;" alt="Shriya Chauhan"/><br /><sub><b>Shriya Chauhan</b></sub></a><br /><a href="https://github.com/asyncapi/modelina/commits?author=Shriya-Chauhan" title="Code">💻</a></td>
455+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/fr-th"><img src="https://avatars.githubusercontent.com/u/61010557?v=4?s=100" width="100px;" alt="fr-th"/><br /><sub><b>fr-th</b></sub></a><br /><a href="https://github.com/asyncapi/modelina/commits?author=fr-th" title="Code">💻</a> <a href="https://github.com/asyncapi/modelina/commits?author=fr-th" title="Tests">⚠️</a> <a href="https://github.com/asyncapi/modelina/commits?author=fr-th" title="Documentation">📖</a></td>
455456
</tr>
456457
</tbody>
457458
</table>

docs/languages/Csharp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Requires [System.Text.Json](https://devblogs.microsoft.com/dotnet/try-the-new-sy
4747
#### Using Newtonsoft/Json.NET
4848

4949
To include functionality that convert the models using the [Newtonsoft/Json.NET](https://www.newtonsoft.com/json) framework, to use this, use the preset `CSHARP_NEWTONSOFT_SERIALIZER_PRESET`.
50+
You can use the option "enforceRequired" to prevent deserialization if any required field is missing.
5051

5152
Check out this [example for a live demonstration](../../examples/csharp-generate-newtonsoft-serializer).
5253

examples/csharp-generate-newtonsoft-serializer/__snapshots__/index.spec.ts.snap

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ Array [
55
"[JsonConverter(typeof(RootConverter))]
66
public partial class Root
77
{
8-
private string? email;
8+
private string email;
9+
private string? name;
910
10-
public string? Email
11+
public string Email
1112
{
1213
get { return email; }
1314
set { this.email = value; }
1415
}
1516
17+
public string? Name
18+
{
19+
get { return name; }
20+
set { this.name = value; }
21+
}
22+
1623
public string Serialize()
1724
{
1825
return JsonConvert.SerializeObject(this);
@@ -30,8 +37,14 @@ public class RootConverter : JsonConverter<Root>
3037
JObject jo = JObject.Load(reader);
3138
Root value = new Root();
3239
33-
if(jo[\\"email\\"] != null) {
34-
value.Email = jo[\\"email\\"].ToObject<string?>(serializer);
40+
if(jo[\\"email\\"] is null){
41+
throw new JsonSerializationException(\\"Required property 'email' is missing\\");
42+
}
43+
44+
value.Email = jo[\\"email\\"].ToObject<string>(serializer);
45+
46+
if(jo[\\"name\\"] != null) {
47+
value.Name = jo[\\"name\\"].ToObject<string?>(serializer);
3548
}
3649
3750
@@ -45,6 +58,10 @@ public class RootConverter : JsonConverter<Root>
4558
{
4659
jo.Add(\\"email\\", JToken.FromObject(value.Email, serializer));
4760
}
61+
if (value.Name != null)
62+
{
63+
jo.Add(\\"name\\", JToken.FromObject(value.Name, serializer));
64+
}
4865
4966
5067
jo.WriteTo(writer);

examples/csharp-generate-newtonsoft-serializer/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,28 @@ import {
44
} from '../../src';
55

66
const generator = new CSharpGenerator({
7-
presets: [CSHARP_NEWTONSOFT_SERIALIZER_PRESET]
7+
presets: [
8+
{
9+
preset: CSHARP_NEWTONSOFT_SERIALIZER_PRESET,
10+
options: {
11+
enforceRequired: true
12+
}
13+
}
14+
]
815
});
916

1017
const jsonSchemaDraft7 = {
1118
$schema: 'http://json-schema.org/draft-07/schema#',
1219
type: 'object',
1320
additionalProperties: false,
21+
required: ['email'],
1422
properties: {
1523
email: {
1624
type: 'string',
1725
format: 'email'
26+
},
27+
name: {
28+
type: 'string'
1829
}
1930
}
2031
};

examples/csharp-generate-newtonsoft-serializer/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/integrate-with-maven/maven-project/scripts/modelina/package-lock.json

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

0 commit comments

Comments
 (0)