From a2fd2158785d956b1e010aea58a64884e24178c2 Mon Sep 17 00:00:00 2001 From: Rico Suter Date: Thu, 29 Nov 2018 08:08:29 +0100 Subject: [PATCH 1/3] Convert tabs to spaces in extension code, closes https://github.com/RSuter/NSwag/issues/1769 --- .../ExtensionCodeTests.cs | 3 ++- .../TypeScriptExtensionCode.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/ExtensionCodeTests.cs b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/ExtensionCodeTests.cs index 2686c3c25..a8f063720 100644 --- a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/ExtensionCodeTests.cs +++ b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/ExtensionCodeTests.cs @@ -5,6 +5,7 @@ namespace NJsonSchema.CodeGeneration.TypeScript.Tests { public class ExtensionCodeTests { + // Important: Line 18 has a \t private const string Code = @"/// @@ -14,7 +15,7 @@ public class ExtensionCodeTests import 'rxjs/add/operator/map'; export class Bar extends generated.Bar { - get title() { + get title() { return this.firstName + ' ' + this.lastName; } } diff --git a/src/NJsonSchema.CodeGeneration.TypeScript/TypeScriptExtensionCode.cs b/src/NJsonSchema.CodeGeneration.TypeScript/TypeScriptExtensionCode.cs index 1a220fa41..95deb6036 100644 --- a/src/NJsonSchema.CodeGeneration.TypeScript/TypeScriptExtensionCode.cs +++ b/src/NJsonSchema.CodeGeneration.TypeScript/TypeScriptExtensionCode.cs @@ -14,6 +14,7 @@ public TypeScriptExtensionCode(string code, string[] extendedClasses, string[] b { code = code .Replace("\r", string.Empty) + .Replace("\t", " ") .Replace("generated.", string.Empty) + "\n"; code = Regex.Replace(code, "(.*?)// ignore(.*?)\\n", string.Empty, RegexOptions.Multiline | RegexOptions.IgnoreCase); From f41566f966f8fd0d1a404644d2e71d6453c815c3 Mon Sep 17 00:00:00 2001 From: Rico Suter Date: Thu, 29 Nov 2018 20:40:35 +0100 Subject: [PATCH 2/3] Deprecate serializer settings, closes https://github.com/RSuter/NSwag/issues/1785 --- .../Generation/JsonSchemaGeneratorSettings.cs | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/NJsonSchema/Generation/JsonSchemaGeneratorSettings.cs b/src/NJsonSchema/Generation/JsonSchemaGeneratorSettings.cs index 19d75a8a2..4c034b765 100644 --- a/src/NJsonSchema/Generation/JsonSchemaGeneratorSettings.cs +++ b/src/NJsonSchema/Generation/JsonSchemaGeneratorSettings.cs @@ -19,6 +19,7 @@ using NJsonSchema.Infrastructure; using System.Linq; +#pragma warning disable CS0618 // Type or member is obsolete namespace NJsonSchema.Generation { /// The JSON Schema generator settings. @@ -27,11 +28,14 @@ public class JsonSchemaGeneratorSettings /// Initializes a new instance of the class. public JsonSchemaGeneratorSettings() { - DefaultEnumHandling = EnumHandling.Integer; DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.Null; - DefaultPropertyNameHandling = PropertyNameHandling.Default; SchemaType = SchemaType.JsonSchema; + // Obsolete, use SerializerSettings instead + DefaultEnumHandling = EnumHandling.Integer; + DefaultPropertyNameHandling = PropertyNameHandling.Default; + ContractResolver = null; + TypeNameGenerator = new DefaultTypeNameGenerator(); SchemaNameGenerator = new DefaultSchemaNameGenerator(); ReflectionService = new DefaultReflectionService(); @@ -39,15 +43,9 @@ public JsonSchemaGeneratorSettings() ExcludedTypeNames = new string[0]; } - /// Gets or sets the default enum handling (default: Integer). - public EnumHandling DefaultEnumHandling { get; set; } - /// Gets or sets the default null handling (if NotNullAttribute and CanBeNullAttribute are missing, default: Null). public ReferenceTypeNullHandling DefaultReferenceTypeNullHandling { get; set; } - /// Gets or sets the default property name handling (default: Default). - public PropertyNameHandling DefaultPropertyNameHandling { get; set; } - /// Gets or sets a value indicating whether to generate abstract properties (i.e. interface and abstract properties. Properties may defined multiple times in a inheritance hierarchy, default: false). public bool GenerateAbstractProperties { get; set; } @@ -70,11 +68,6 @@ public JsonSchemaGeneratorSettings() /// Gets or sets the schema type to generate (default: JsonSchema). public SchemaType SchemaType { get; set; } - /// Gets or sets the contract resolver. - /// will be ignored. - [JsonIgnore] - public IContractResolver ContractResolver { get; set; } - /// Gets or sets the serializer settings. /// , and will be ignored. [JsonIgnore] @@ -103,6 +96,20 @@ public JsonSchemaGeneratorSettings() [JsonIgnore] public ICollection SchemaProcessors { get; } = new Collection(); + /// Gets or sets the contract resolver. + /// will be ignored. + [JsonIgnore] + [Obsolete("Use SerializerSettings directly instead. In NSwag.AspNetCore the property is set automatically.")] + public IContractResolver ContractResolver { get; set; } + + /// Gets or sets the default property name handling (default: Default). + [Obsolete("Use SerializerSettings directly instead. In NSwag.AspNetCore the property is set automatically.")] + public PropertyNameHandling DefaultPropertyNameHandling { get; set; } + + /// Gets or sets the default enum handling (default: Integer). + [Obsolete("Use SerializerSettings directly instead. In NSwag.AspNetCore the property is set automatically.")] + public EnumHandling DefaultEnumHandling { get; set; } + /// Gets the contract resolver. /// The contract resolver. /// A setting is misconfigured. From 7a9266a60b64b45401425cf76a7a6f647f59cb2e Mon Sep 17 00:00:00 2001 From: Rico Suter Date: Thu, 29 Nov 2018 20:41:48 +0100 Subject: [PATCH 3/3] v9.12.6 --- .../NJsonSchema.CodeGeneration.CSharp.csproj | 2 +- .../NJsonSchema.CodeGeneration.TypeScript.csproj | 2 +- .../NJsonSchema.CodeGeneration.csproj | 2 +- src/NJsonSchema.Yaml/NJsonSchema.Yaml.csproj | 2 +- src/NJsonSchema/NJsonSchema.csproj | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NJsonSchema.CodeGeneration.CSharp/NJsonSchema.CodeGeneration.CSharp.csproj b/src/NJsonSchema.CodeGeneration.CSharp/NJsonSchema.CodeGeneration.CSharp.csproj index b444c6ad9..ddda834ca 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/NJsonSchema.CodeGeneration.CSharp.csproj +++ b/src/NJsonSchema.CodeGeneration.CSharp/NJsonSchema.CodeGeneration.CSharp.csproj @@ -2,7 +2,7 @@ netstandard1.3;net451 JSON Schema reader, generator and validator for .NET - 9.12.5 + 9.12.6 json schema validation generator .net Copyright © Rico Suter, 2017 https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md diff --git a/src/NJsonSchema.CodeGeneration.TypeScript/NJsonSchema.CodeGeneration.TypeScript.csproj b/src/NJsonSchema.CodeGeneration.TypeScript/NJsonSchema.CodeGeneration.TypeScript.csproj index 3cff4138e..63df7a7f0 100644 --- a/src/NJsonSchema.CodeGeneration.TypeScript/NJsonSchema.CodeGeneration.TypeScript.csproj +++ b/src/NJsonSchema.CodeGeneration.TypeScript/NJsonSchema.CodeGeneration.TypeScript.csproj @@ -2,7 +2,7 @@ netstandard1.3;net451 JSON Schema reader, generator and validator for .NET - 9.12.5 + 9.12.6 json schema validation generator .net Copyright © Rico Suter, 2017 https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md diff --git a/src/NJsonSchema.CodeGeneration/NJsonSchema.CodeGeneration.csproj b/src/NJsonSchema.CodeGeneration/NJsonSchema.CodeGeneration.csproj index 9eba9a24c..99663610b 100644 --- a/src/NJsonSchema.CodeGeneration/NJsonSchema.CodeGeneration.csproj +++ b/src/NJsonSchema.CodeGeneration/NJsonSchema.CodeGeneration.csproj @@ -2,7 +2,7 @@ netstandard1.3;net451 JSON Schema reader, generator and validator for .NET - 9.12.5 + 9.12.6 json schema validation generator .net Copyright © Rico Suter, 2017 https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md diff --git a/src/NJsonSchema.Yaml/NJsonSchema.Yaml.csproj b/src/NJsonSchema.Yaml/NJsonSchema.Yaml.csproj index da0fe2df4..a2fecdd05 100644 --- a/src/NJsonSchema.Yaml/NJsonSchema.Yaml.csproj +++ b/src/NJsonSchema.Yaml/NJsonSchema.Yaml.csproj @@ -2,7 +2,7 @@ netstandard1.3;net45 JSON Schema reader, generator and validator for .NET - 9.12.5 + 9.12.6 json schema validation generator .net Copyright © Rico Suter, 2017 https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md diff --git a/src/NJsonSchema/NJsonSchema.csproj b/src/NJsonSchema/NJsonSchema.csproj index 9a21df946..947a56511 100644 --- a/src/NJsonSchema/NJsonSchema.csproj +++ b/src/NJsonSchema/NJsonSchema.csproj @@ -2,7 +2,7 @@ netstandard1.0;net40;net45 JSON Schema reader, generator and validator for .NET - 9.12.5 + 9.12.6 json schema validation generator .net Copyright © Rico Suter, 2017 https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md