Skip to content

Commit 09158e2

Browse files
committed
chore: uses backing fields
Signed-off-by: Vincent Biret <[email protected]>
1 parent f27415d commit 09158e2

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

src/Microsoft.OpenApi/Models/OpenApiSchema.cs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ namespace Microsoft.OpenApi.Models
1717
/// </summary>
1818
public class OpenApiSchema : IOpenApiAnnotatable, IOpenApiExtensible, IOpenApiReferenceable
1919
{
20-
private JsonNode _example;
21-
private JsonNode _default;
22-
private IList<JsonNode> _examples;
23-
2420
/// <summary>
2521
/// Follow JSON Schema definition. Short text providing information about the data.
2622
/// </summary>
@@ -148,11 +144,7 @@ public class OpenApiSchema : IOpenApiAnnotatable, IOpenApiExtensible, IOpenApiRe
148144
/// Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level.
149145
/// For example, if type is string, then default can be "foo" but cannot be 1.
150146
/// </summary>
151-
public virtual JsonNode Default
152-
{
153-
get => _default;
154-
set => _default = value;
155-
}
147+
public virtual JsonNode Default { get; set; }
156148

157149
/// <summary>
158150
/// Relevant only for Schema "properties" definitions. Declares the property as "read only".
@@ -273,22 +265,14 @@ public virtual JsonNode Default
273265
/// To represent examples that cannot be naturally represented in JSON or YAML,
274266
/// a string value can be used to contain the example with escaping where necessary.
275267
/// </summary>
276-
public virtual JsonNode Example
277-
{
278-
get => _example;
279-
set => _example = value;
280-
}
268+
public virtual JsonNode Example { get; set; }
281269

282270
/// <summary>
283271
/// A free-form property to include examples of an instance for this schema.
284272
/// To represent examples that cannot be naturally represented in JSON or YAML,
285273
/// a list of values can be used to contain the examples with escaping where necessary.
286274
/// </summary>
287-
public virtual IList<JsonNode> Examples
288-
{
289-
get => _examples;
290-
set => _examples = value;
291-
}
275+
public virtual IList<JsonNode> Examples { get; set; }
292276

293277
/// <summary>
294278
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
@@ -378,7 +362,7 @@ public OpenApiSchema(OpenApiSchema schema)
378362
MinLength = schema?.MinLength ?? MinLength;
379363
Pattern = schema?.Pattern ?? Pattern;
380364
MultipleOf = schema?.MultipleOf ?? MultipleOf;
381-
_default = schema?.Default != null ? JsonNodeCloneHelper.Clone(schema?.Default) : null;
365+
Default = schema?.Default != null ? JsonNodeCloneHelper.Clone(schema?.Default) : null;
382366
ReadOnly = schema?.ReadOnly ?? ReadOnly;
383367
WriteOnly = schema?.WriteOnly ?? WriteOnly;
384368
AllOf = schema?.AllOf != null ? new List<OpenApiSchema>(schema.AllOf) : null;
@@ -397,8 +381,8 @@ public OpenApiSchema(OpenApiSchema schema)
397381
AdditionalPropertiesAllowed = schema?.AdditionalPropertiesAllowed ?? AdditionalPropertiesAllowed;
398382
AdditionalProperties = schema?.AdditionalProperties != null ? new(schema?.AdditionalProperties) : null;
399383
Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null;
400-
_example = schema?.Example != null ? JsonNodeCloneHelper.Clone(schema?.Example) : null;
401-
_examples = schema?.Examples != null ? new List<JsonNode>(schema.Examples) : null;
384+
Example = schema?.Example != null ? JsonNodeCloneHelper.Clone(schema?.Example) : null;
385+
Examples = schema?.Examples != null ? new List<JsonNode>(schema.Examples) : null;
402386
Enum = schema?.Enum != null ? new List<JsonNode>(schema.Enum) : null;
403387
Nullable = schema?.Nullable ?? Nullable;
404388
ExternalDocs = schema?.ExternalDocs != null ? new(schema?.ExternalDocs) : null;

0 commit comments

Comments
 (0)