Skip to content

Commit b4002e4

Browse files
authored
refactor(WriterExtensions): change to optional for consistency (#68)
1 parent b671235 commit b4002e4

29 files changed

+81
-81
lines changed

src/LEGO.AsyncAPI/Models/AsyncApiChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
7878
writer.WriteStartObject();
7979

8080
// description
81-
writer.WriteProperty(AsyncApiConstants.Description, this.Description);
81+
writer.WriteOptionalProperty(AsyncApiConstants.Description, this.Description);
8282

8383
// servers
8484
writer.WriteOptionalCollection(AsyncApiConstants.Servers, this.Servers, (w, s) => w.WriteValue(s));

src/LEGO.AsyncAPI/Models/AsyncApiContact.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public void SerializeV2(IAsyncApiWriter writer)
4040
writer.WriteStartObject();
4141

4242
// name
43-
writer.WriteProperty(AsyncApiConstants.Name, this.Name);
43+
writer.WriteOptionalProperty(AsyncApiConstants.Name, this.Name);
4444

4545
// url
46-
writer.WriteProperty(AsyncApiConstants.Url, this.Url?.OriginalString);
46+
writer.WriteOptionalProperty(AsyncApiConstants.Url, this.Url?.OriginalString);
4747

4848
// email
49-
writer.WriteProperty(AsyncApiConstants.Email, this.Email);
49+
writer.WriteOptionalProperty(AsyncApiConstants.Email, this.Email);
5050

5151
// extensions
5252
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);

src/LEGO.AsyncAPI/Models/AsyncApiCorrelationId.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
5656

5757
writer.WriteStartObject();
5858

59-
writer.WriteProperty(AsyncApiConstants.Description, this.Description);
59+
writer.WriteOptionalProperty(AsyncApiConstants.Description, this.Description);
6060
writer.WriteRequiredProperty(AsyncApiConstants.Location, this.Location);
6161

6262
writer.WriteEndObject();

src/LEGO.AsyncAPI/Models/AsyncApiDocument.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ public void SerializeV2(IAsyncApiWriter writer)
7676
writer.WriteStartObject();
7777

7878
// asyncApi
79-
writer.WriteProperty(AsyncApiConstants.AsyncApi, "2.3.0");
79+
writer.WriteOptionalProperty(AsyncApiConstants.AsyncApi, "2.3.0");
8080

8181
// info
8282
writer.WriteRequiredObject(AsyncApiConstants.Info, this.Info, (w, i) => i.SerializeV2(w));
8383

8484
// id
85-
writer.WriteProperty(AsyncApiConstants.Id, this.Id);
85+
writer.WriteOptionalProperty(AsyncApiConstants.Id, this.Id);
8686

8787
// servers
8888
writer.WriteOptionalMap(AsyncApiConstants.Servers, this.Servers, (writer, key, component) =>
@@ -100,7 +100,7 @@ public void SerializeV2(IAsyncApiWriter writer)
100100
});
101101

102102
// content type
103-
writer.WriteProperty(AsyncApiConstants.DefaultContentType, this.DefaultContentType);
103+
writer.WriteOptionalProperty(AsyncApiConstants.DefaultContentType, this.DefaultContentType);
104104

105105
// channels
106106
writer.WriteRequiredMap(AsyncApiConstants.Channels, this.Channels, (writer, key, component) =>

src/LEGO.AsyncAPI/Models/AsyncApiExternalDocumentation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void SerializeV2(IAsyncApiWriter writer)
3434

3535
writer.WriteStartObject();
3636

37-
writer.WriteProperty(AsyncApiConstants.Description, this.Description);
37+
writer.WriteOptionalProperty(AsyncApiConstants.Description, this.Description);
3838

3939
writer.WriteRequiredProperty(AsyncApiConstants.Url, this.Url?.OriginalString);
4040

src/LEGO.AsyncAPI/Models/AsyncApiInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ public void SerializeV2(IAsyncApiWriter writer)
5555
writer.WriteStartObject();
5656

5757
// title
58-
writer.WriteProperty(AsyncApiConstants.Title, this.Title);
58+
writer.WriteOptionalProperty(AsyncApiConstants.Title, this.Title);
5959

6060
// description
61-
writer.WriteProperty(AsyncApiConstants.Description, this.Description);
61+
writer.WriteOptionalProperty(AsyncApiConstants.Description, this.Description);
6262

6363
// termsOfService
64-
writer.WriteProperty(AsyncApiConstants.TermsOfService, this.TermsOfService?.OriginalString);
64+
writer.WriteOptionalProperty(AsyncApiConstants.TermsOfService, this.TermsOfService?.OriginalString);
6565

6666
// contact object
6767
writer.WriteOptionalObject(AsyncApiConstants.Contact, this.Contact, (w, c) => c.SerializeV2(w));
@@ -70,7 +70,7 @@ public void SerializeV2(IAsyncApiWriter writer)
7070
writer.WriteOptionalObject(AsyncApiConstants.License, this.License, (w, l) => l.SerializeV2(w));
7171

7272
// version
73-
writer.WriteProperty(AsyncApiConstants.Version, this.Version);
73+
writer.WriteOptionalProperty(AsyncApiConstants.Version, this.Version);
7474

7575
// specification extensions
7676
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);

src/LEGO.AsyncAPI/Models/AsyncApiLicense.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public void SerializeV2(IAsyncApiWriter writer)
3535
writer.WriteStartObject();
3636

3737
// name
38-
writer.WriteProperty(AsyncApiConstants.Name, this.Name);
38+
writer.WriteOptionalProperty(AsyncApiConstants.Name, this.Name);
3939

4040
// url
41-
writer.WriteProperty(AsyncApiConstants.Url, this.Url?.OriginalString);
41+
writer.WriteOptionalProperty(AsyncApiConstants.Url, this.Url?.OriginalString);
4242

4343
// specification extensions
4444
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);

src/LEGO.AsyncAPI/Models/AsyncApiMessage.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
121121
writer.WriteOptionalObject(AsyncApiConstants.Headers, this.Headers, (w, h) => h.SerializeV2(w));
122122
writer.WriteOptionalObject(AsyncApiConstants.Payload, this.Payload, (w, p) => w.WriteAny(p));
123123
writer.WriteOptionalObject(AsyncApiConstants.CorrelationId, this.CorrelationId, (w, c) => c.SerializeV2(w));
124-
writer.WriteProperty(AsyncApiConstants.SchemaFormat, this.SchemaFormat);
125-
writer.WriteProperty(AsyncApiConstants.ContentType, this.ContentType);
126-
writer.WriteProperty(AsyncApiConstants.Name, this.Name);
127-
writer.WriteProperty(AsyncApiConstants.Title, this.Title);
128-
writer.WriteProperty(AsyncApiConstants.Summary, this.Summary);
129-
writer.WriteProperty(AsyncApiConstants.Description, this.Description);
124+
writer.WriteOptionalProperty(AsyncApiConstants.SchemaFormat, this.SchemaFormat);
125+
writer.WriteOptionalProperty(AsyncApiConstants.ContentType, this.ContentType);
126+
writer.WriteOptionalProperty(AsyncApiConstants.Name, this.Name);
127+
writer.WriteOptionalProperty(AsyncApiConstants.Title, this.Title);
128+
writer.WriteOptionalProperty(AsyncApiConstants.Summary, this.Summary);
129+
writer.WriteOptionalProperty(AsyncApiConstants.Description, this.Description);
130130
writer.WriteOptionalCollection(AsyncApiConstants.Tags, this.Tags, (w, t) => t.SerializeV2(w));
131131
writer.WriteOptionalObject(AsyncApiConstants.ExternalDocs, this.ExternalDocs, (w, e) => e.SerializeV2(w));
132132

src/LEGO.AsyncAPI/Models/AsyncApiMessageExample.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public void SerializeV2(IAsyncApiWriter writer)
4343
}
4444

4545
writer.WriteStartObject();
46-
writer.WriteProperty(AsyncApiConstants.Name, this.Name);
47-
writer.WriteProperty(AsyncApiConstants.Summary, this.Summary);
46+
writer.WriteOptionalProperty(AsyncApiConstants.Name, this.Name);
47+
writer.WriteOptionalProperty(AsyncApiConstants.Summary, this.Summary);
4848
writer.WriteOptionalMap(AsyncApiConstants.Headers, this.Headers, (w, h) => w.WriteAny(h));
4949
writer.WriteOptionalObject(AsyncApiConstants.Payload, this.Payload, (w, p) => w.WriteAny(p));
5050
writer.WriteExtensions(this.Extensions, AsyncApiVersion.AsyncApi2_3_0);

src/LEGO.AsyncAPI/Models/AsyncApiMessageTrait.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
110110
writer.WriteStartObject();
111111
writer.WriteOptionalObject(AsyncApiConstants.Headers, this.Headers, (w, h) => h.SerializeV2(w));
112112
writer.WriteOptionalObject(AsyncApiConstants.CorrelationId, this.CorrelationId, (w, c) => c.SerializeV2(w));
113-
writer.WriteProperty(AsyncApiConstants.SchemaFormat, this.SchemaFormat);
114-
writer.WriteProperty(AsyncApiConstants.ContentType, this.ContentType);
115-
writer.WriteProperty(AsyncApiConstants.Name, this.Name);
116-
writer.WriteProperty(AsyncApiConstants.Title, this.Title);
117-
writer.WriteProperty(AsyncApiConstants.Summary, this.Summary);
118-
writer.WriteProperty(AsyncApiConstants.Description, this.Description);
113+
writer.WriteOptionalProperty(AsyncApiConstants.SchemaFormat, this.SchemaFormat);
114+
writer.WriteOptionalProperty(AsyncApiConstants.ContentType, this.ContentType);
115+
writer.WriteOptionalProperty(AsyncApiConstants.Name, this.Name);
116+
writer.WriteOptionalProperty(AsyncApiConstants.Title, this.Title);
117+
writer.WriteOptionalProperty(AsyncApiConstants.Summary, this.Summary);
118+
writer.WriteOptionalProperty(AsyncApiConstants.Description, this.Description);
119119
writer.WriteOptionalCollection(AsyncApiConstants.Tags, this.Tags, (w, t) => t.SerializeV2(w));
120120
writer.WriteOptionalObject(AsyncApiConstants.ExternalDocs, this.ExternalDocs, (w, e) => e.SerializeV2(w));
121121
writer.WriteOptionalObject(AsyncApiConstants.Bindings, this.Bindings, (w, t) => t.SerializeV2(w));

0 commit comments

Comments
 (0)