Skip to content

Commit 58aae34

Browse files
committed
Updated nswag documents
1 parent 5e9d407 commit 58aae34

21 files changed

+784
-999
lines changed

src/NSwag.Commands/NSwagDocumentBase.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Newtonsoft.Json;
1717
using Newtonsoft.Json.Converters;
1818
using Newtonsoft.Json.Linq;
19+
using Newtonsoft.Json.Serialization;
1920
using NJsonSchema.Infrastructure;
2021
using NSwag.Commands.Base;
2122

@@ -68,15 +69,15 @@ internal JObject SelectedSwaggerGeneratorRaw
6869
key[0].ToString().ToLowerInvariant() + key.Substring(1),
6970
SelectedSwaggerGenerator
7071
}
71-
});
72+
}, JsonSerializer.Create(GetSerializerSettings()));
7273
}
7374
set
7475
{
7576
var generatorProperty = value.Properties().First();
7677
var key = generatorProperty.Name + "Command";
7778
var collectionProperty = SwaggerGenerators.GetType().GetRuntimeProperty(key[0].ToString().ToUpperInvariant() + key.Substring(1));
7879
var generator = collectionProperty.GetValue(SwaggerGenerators);
79-
var newGenerator = (OutputCommandBase)JsonConvert.DeserializeObject(generatorProperty.Value.ToString(), generator.GetType());
80+
var newGenerator = (OutputCommandBase)JsonConvert.DeserializeObject(generatorProperty.Value.ToString(), generator.GetType(), GetSerializerSettings());
8081
collectionProperty.SetValue(SwaggerGenerators, newGenerator);
8182
SelectedSwaggerGenerator = newGenerator;
8283
}
@@ -149,7 +150,10 @@ protected static Task<TDocument> LoadAsync<TDocument>(string filePath, IDictiona
149150
var data = DynamicApis.FileReadAllText(filePath);
150151
data = TransformLegacyDocument(data, out saveFile); // TODO: Remove this legacy stuff later
151152

152-
var document = JsonConvert.DeserializeObject<TDocument>(data, GetSerializerSettings(mappings));
153+
var settings = GetSerializerSettings();
154+
settings.ContractResolver = new BaseTypeMappingContractResolver(mappings);
155+
156+
var document = JsonConvert.DeserializeObject<TDocument>(data, settings);
153157
document.Path = filePath;
154158
document.ConvertToAbsolutePaths();
155159
document._latestData = JsonConvert.SerializeObject(document, Formatting.Indented, GetSerializerSettings());
@@ -168,7 +172,6 @@ public Task SaveAsync()
168172
return Task.Run(() =>
169173
{
170174
ConvertToRelativePaths();
171-
172175
_latestData = JsonConvert.SerializeObject(this, Formatting.Indented, GetSerializerSettings());
173176
ConvertToAbsolutePaths();
174177
DynamicApis.FileWriteAllText(Path, _latestData);
@@ -199,13 +202,12 @@ private async Task<SwaggerDocument> GenerateDocumentAsync()
199202
return await ((dynamic)SelectedSwaggerGenerator).RunAsync();
200203
}
201204

202-
private static JsonSerializerSettings GetSerializerSettings(IDictionary<Type, Type> mappings = null)
205+
private static JsonSerializerSettings GetSerializerSettings()
203206
{
204207
return new JsonSerializerSettings
205208
{
206209
NullValueHandling = NullValueHandling.Ignore,
207-
208-
ContractResolver = new BaseTypeMappingContractResolver(mappings),
210+
ContractResolver = new CamelCasePropertyNamesContractResolver(),
209211
Converters = new List<JsonConverter>
210212
{
211213
new StringEnumConverter()
@@ -326,7 +328,7 @@ private static string TransformLegacyDocument(string data, out bool saveFile)
326328
{"swaggerToCSharpController", obj["SwaggerToCSharpControllerGenerator"]}
327329
};
328330

329-
data = obj.ToString();
331+
data = obj.ToString().Replace("\"OutputFilePath\"", "\"output\"");
330332
saveFile = true;
331333
}
332334
else

src/NSwag.Integration.ClientPCL/ServiceClients.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//----------------------
22
// <auto-generated>
3-
// Generated using the NSwag toolchain v7.0.6156.31121 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
3+
// Generated using the NSwag toolchain v7.1.6163.24558 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
44
// </auto-generated>
55
//----------------------
66

@@ -31,7 +31,7 @@ namespace NSwag.Integration.ClientPCL
3131
{
3232
#pragma warning disable // Disable all warnings
3333

34-
[GeneratedCode("NSwag", "7.0.6156.31121")]
34+
[GeneratedCode("NSwag", "7.1.6163.24558")]
3535
public partial class GeoClient
3636
{
3737
private string _baseUrl = "http://localhost:13452";
@@ -389,7 +389,7 @@ public async Task<byte[]> GetUploadedFileAsync(int id, bool? @override, Cancella
389389

390390
}
391391

392-
[GeneratedCode("NSwag", "7.0.6156.31121")]
392+
[GeneratedCode("NSwag", "7.1.6163.24558")]
393393
public partial class PersonsClient
394394
{
395395
private string _baseUrl = "http://localhost:13452";
@@ -836,7 +836,7 @@ public async Task<string> GetNameAsync(Guid id, CancellationToken cancellationTo
836836

837837

838838

839-
[GeneratedCode("NSwag", "7.0.6156.31121")]
839+
[GeneratedCode("NSwag", "7.1.6163.24558")]
840840
internal class JsonExceptionConverter : JsonConverter
841841
{
842842
private readonly DefaultContractResolver _defaultContractResolver = new DefaultContractResolver();

src/NSwag.Integration.ClientPCL/ServiceClientsContracts.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//----------------------
22
// <auto-generated>
3-
// Generated using the NSwag toolchain v7.0.6156.31121 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
3+
// Generated using the NSwag toolchain v7.1.6163.24558 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
44
// </auto-generated>
55
//----------------------
66

@@ -332,7 +332,7 @@ private bool IsKnwonTypeTargetType(dynamic attribute, string discriminator)
332332
}
333333
}
334334

335-
[GeneratedCode("NSwag", "7.0.6156.31121")]
335+
[GeneratedCode("NSwag", "7.1.6163.24558")]
336336
public class FileParameter
337337
{
338338
public FileParameter(Stream data)
@@ -351,7 +351,7 @@ public FileParameter(Stream data, string fileName)
351351
public string FileName { get; private set; }
352352
}
353353

354-
[GeneratedCode("NSwag", "7.0.6156.31121")]
354+
[GeneratedCode("NSwag", "7.1.6163.24558")]
355355
public class GeoClientException : Exception
356356
{
357357
public string StatusCode { get; private set; }
@@ -371,7 +371,7 @@ public override string ToString()
371371
}
372372
}
373373

374-
[GeneratedCode("NSwag", "7.0.6156.31121")]
374+
[GeneratedCode("NSwag", "7.1.6163.24558")]
375375
public class GeoClientException<TResponse> : GeoClientException
376376
{
377377
public TResponse Response { get; private set; }
@@ -383,7 +383,7 @@ public GeoClientException(string message, string statusCode, byte[] responseData
383383
}
384384
}
385385

386-
[GeneratedCode("NSwag", "7.0.6156.31121")]
386+
[GeneratedCode("NSwag", "7.1.6163.24558")]
387387
public class PersonsClientException : Exception
388388
{
389389
public string StatusCode { get; private set; }
@@ -403,7 +403,7 @@ public override string ToString()
403403
}
404404
}
405405

406-
[GeneratedCode("NSwag", "7.0.6156.31121")]
406+
[GeneratedCode("NSwag", "7.1.6163.24558")]
407407
public class PersonsClientException<TResponse> : PersonsClientException
408408
{
409409
public TResponse Response { get; private set; }

src/NSwag.Integration.Console/ServiceClients.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//----------------------
22
// <auto-generated>
3-
// Generated using the NSwag toolchain v7.0.6156.31121 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
3+
// Generated using the NSwag toolchain v7.1.6163.24558 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
44
// </auto-generated>
55
//----------------------
66

@@ -31,7 +31,7 @@ namespace NSwag.Integration.Console
3131
{
3232
#pragma warning disable // Disable all warnings
3333

34-
[GeneratedCode("NSwag", "7.0.6156.31121")]
34+
[GeneratedCode("NSwag", "7.1.6163.24558")]
3535
public partial class GeoClient
3636
{
3737
private string _baseUrl = "http://localhost:13452";
@@ -389,7 +389,7 @@ public async Task<byte[]> GetUploadedFileAsync(int id, bool? @override, Cancella
389389

390390
}
391391

392-
[GeneratedCode("NSwag", "7.0.6156.31121")]
392+
[GeneratedCode("NSwag", "7.1.6163.24558")]
393393
public partial class PersonsClient
394394
{
395395
private string _baseUrl = "http://localhost:13452";
@@ -836,7 +836,7 @@ public async Task<string> GetNameAsync(Guid id, CancellationToken cancellationTo
836836

837837

838838

839-
[GeneratedCode("NSwag", "7.0.6156.31121")]
839+
[GeneratedCode("NSwag", "7.1.6163.24558")]
840840
internal class JsonExceptionConverter : JsonConverter
841841
{
842842
private readonly DefaultContractResolver _defaultContractResolver = new DefaultContractResolver();

src/NSwag.Integration.Console/ServiceClientsContracts.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//----------------------
22
// <auto-generated>
3-
// Generated using the NSwag toolchain v7.0.6156.31121 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
3+
// Generated using the NSwag toolchain v7.1.6163.24558 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
44
// </auto-generated>
55
//----------------------
66

@@ -332,7 +332,7 @@ private bool IsKnwonTypeTargetType(dynamic attribute, string discriminator)
332332
}
333333
}
334334

335-
[GeneratedCode("NSwag", "7.0.6156.31121")]
335+
[GeneratedCode("NSwag", "7.1.6163.24558")]
336336
public class FileParameter
337337
{
338338
public FileParameter(Stream data)
@@ -351,7 +351,7 @@ public FileParameter(Stream data, string fileName)
351351
public string FileName { get; private set; }
352352
}
353353

354-
[GeneratedCode("NSwag", "7.0.6156.31121")]
354+
[GeneratedCode("NSwag", "7.1.6163.24558")]
355355
public class SwaggerException : Exception
356356
{
357357
public string StatusCode { get; private set; }
@@ -371,7 +371,7 @@ public override string ToString()
371371
}
372372
}
373373

374-
[GeneratedCode("NSwag", "7.0.6156.31121")]
374+
[GeneratedCode("NSwag", "7.1.6163.24558")]
375375
public class SwaggerException<TResponse> : SwaggerException
376376
{
377377
public TResponse Response { get; private set; }

src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngular2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* tslint: disable */
22
//----------------------
33
// <auto-generated>
4-
// Generated using the NSwag toolchain v7.0.6156.31121 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
4+
// Generated using the NSwag toolchain v7.1.6163.24558 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
55
// </auto-generated>
66
//----------------------
77

src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngularJS.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* tslint: disable */
22
//----------------------
33
// <auto-generated>
4-
// Generated using the NSwag toolchain v7.0.6156.31121 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
4+
// Generated using the NSwag toolchain v7.1.6163.24558 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
55
// </auto-generated>
66
//----------------------
77

src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAurelia.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* tslint: disable */
22
//----------------------
33
// <auto-generated>
4-
// Generated using the NSwag toolchain v7.0.6156.31121 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
4+
// Generated using the NSwag toolchain v7.1.6163.24558 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
55
// </auto-generated>
66
//----------------------
77

src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsFetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* tslint: disable */
22
//----------------------
33
// <auto-generated>
4-
// Generated using the NSwag toolchain v7.0.6156.31121 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
4+
// Generated using the NSwag toolchain v7.1.6163.24558 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
55
// </auto-generated>
66
//----------------------
77

src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryCallbacks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* tslint: disable */
22
//----------------------
33
// <auto-generated>
4-
// Generated using the NSwag toolchain v7.0.6156.31121 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
4+
// Generated using the NSwag toolchain v7.1.6163.24558 (NJsonSchema v5.16.6156.29215) (http://NSwag.org)
55
// </auto-generated>
66
//----------------------
77

0 commit comments

Comments
 (0)