diff --git a/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project.nswag b/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project.nswag index 1a2e525a54..a5aa3417ca 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project.nswag +++ b/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project.nswag @@ -4,8 +4,14 @@ "swaggerGenerator": { "aspNetCoreToSwagger": { "project": "Sample.AspNetCore20.csproj", + "msBuildProjectExtensionsPath": null, + "configuration": null, + "runtime": null, + "targetFramework": null, "noBuild": false, "verbose": true, + "workingDirectory": null, + "requireParametersWithoutDefault": true, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", "defaultEnumHandling": "Integer", @@ -16,12 +22,28 @@ "ignoreObsoleteProperties": false, "allowReferencesWithProperties": false, "excludedTypeNames": [], + "serviceHost": null, + "serviceBasePath": null, + "serviceSchemes": [], "infoTitle": "My Title", + "infoDescription": null, "infoVersion": "1.0.0", + "includedVersions": null, + "documentTemplate": null, + "documentProcessorTypes": [], + "operationProcessorTypes": [], + "typeNameGeneratorType": null, + "schemaNameGeneratorType": null, + "contractResolverType": null, + "serializerSettingsType": null, + "useDocumentProvider": false, + "startupType": null, "output": "nswag_project_swagger.json", "outputType": "Swagger2", "assemblyPaths": [], - "referencePaths": [] + "assemblyConfig": null, + "referencePaths": [], + "useNuGetCache": false } }, "codeGenerators": {} diff --git a/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project_swagger.json b/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project_swagger.json index 37193da6c8..8e1731f745 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project_swagger.json +++ b/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project_swagger.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v10.0.0.0))", + "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v10.0.0.0))", "swagger": "2.0", "info": { "title": "My Title", diff --git a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly.nswag b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly.nswag index a202872e21..040c4f7321 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly.nswag +++ b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly.nswag @@ -3,8 +3,15 @@ "defaultVariables": "configuration=Debug", "swaggerGenerator": { "aspNetCoreToSwagger": { + "project": null, + "msBuildProjectExtensionsPath": null, + "configuration": null, + "runtime": null, + "targetFramework": null, "noBuild": false, "verbose": false, + "workingDirectory": null, + "requireParametersWithoutDefault": true, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", "defaultEnumHandling": "Integer", @@ -15,13 +22,28 @@ "ignoreObsoleteProperties": false, "allowReferencesWithProperties": false, "excludedTypeNames": [], + "serviceHost": null, + "serviceBasePath": null, + "serviceSchemes": [], "infoTitle": "My Title", + "infoDescription": null, "infoVersion": "1.0.0", + "includedVersions": null, + "documentTemplate": null, + "documentProcessorTypes": [], + "operationProcessorTypes": [], + "typeNameGeneratorType": null, + "schemaNameGeneratorType": null, + "contractResolverType": null, + "serializerSettingsType": null, + "useDocumentProvider": false, + "startupType": null, "output": "nswag_assembly_swagger.json", "outputType": "Swagger2", "assemblyPaths": [ - "bin/$(configuration)/netcoreapp2.1/Sample.AspNetCore21.dll" + "bin/Release/netcoreapp2.1/Sample.AspNetCore21.dll" ], + "assemblyConfig": null, "referencePaths": [], "useNuGetCache": false } diff --git a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly_swagger.json b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly_swagger.json index 46032edcd5..1c2c146618 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly_swagger.json +++ b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly_swagger.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))", + "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))", "swagger": "2.0", "info": { "title": "My Title", diff --git a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project.nswag b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project.nswag index f3f3ae7db3..320b4c83e1 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project.nswag +++ b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project.nswag @@ -4,9 +4,14 @@ "swaggerGenerator": { "aspNetCoreToSwagger": { "project": "Sample.AspNetCore21.csproj", + "msBuildProjectExtensionsPath": null, "configuration": "", + "runtime": null, + "targetFramework": null, "noBuild": false, "verbose": false, + "workingDirectory": null, + "requireParametersWithoutDefault": true, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", "defaultEnumHandling": "Integer", @@ -17,12 +22,28 @@ "ignoreObsoleteProperties": false, "allowReferencesWithProperties": false, "excludedTypeNames": [], + "serviceHost": null, + "serviceBasePath": null, + "serviceSchemes": [], "infoTitle": "My Title", + "infoDescription": null, "infoVersion": "1.0.0", + "includedVersions": null, + "documentTemplate": null, + "documentProcessorTypes": [], + "operationProcessorTypes": [], + "typeNameGeneratorType": null, + "schemaNameGeneratorType": null, + "contractResolverType": null, + "serializerSettingsType": null, + "useDocumentProvider": false, + "startupType": null, "output": "nswag_project_swagger.json", "outputType": "Swagger2", "assemblyPaths": [], - "referencePaths": [] + "assemblyConfig": null, + "referencePaths": [], + "useNuGetCache": false } }, "codeGenerators": {} diff --git a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project_swagger.json b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project_swagger.json index cc1a9e97e9..68a58605cb 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project_swagger.json +++ b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project_swagger.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v11.0.0.0))", + "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v11.0.0.0))", "swagger": "2.0", "info": { "title": "My Title", diff --git a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_reflection_swagger.json b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_reflection_swagger.json index 1c438c29ea..1d54786f70 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_reflection_swagger.json +++ b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_reflection_swagger.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))", + "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))", "swagger": "2.0", "info": { "title": "My Title", diff --git a/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj b/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj index b312fed784..c51d2e4a53 100644 --- a/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj +++ b/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj @@ -46,7 +46,7 @@ - + diff --git a/src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj b/src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj index 4ceb41746f..9fc9756b39 100644 --- a/src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj +++ b/src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj @@ -21,7 +21,7 @@ TRACE;DEBUG;NET45 - + diff --git a/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj b/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj index a2cac59c39..5821ed9e1f 100644 --- a/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj +++ b/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj @@ -24,7 +24,7 @@ TRACE;RELEASE;FullNet;NET451 - + diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/NSwag.CodeGeneration.CSharp.Tests.csproj b/src/NSwag.CodeGeneration.CSharp.Tests/NSwag.CodeGeneration.CSharp.Tests.csproj index 4bd309a98a..88a5359f49 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/NSwag.CodeGeneration.CSharp.Tests.csproj +++ b/src/NSwag.CodeGeneration.CSharp.Tests/NSwag.CodeGeneration.CSharp.Tests.csproj @@ -40,8 +40,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.9.10.75\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.9.11.0\lib\net45\NJsonSchema.dll diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/packages.config b/src/NSwag.CodeGeneration.CSharp.Tests/packages.config index 003ec2aee4..ab89465654 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/packages.config +++ b/src/NSwag.CodeGeneration.CSharp.Tests/packages.config @@ -4,5 +4,5 @@ - + \ No newline at end of file diff --git a/src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs b/src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs index 0eda52ca78..754f664963 100644 --- a/src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs +++ b/src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs @@ -54,9 +54,19 @@ public class CSharpOperationModel : OperationModelBase !p.IsRequired).ThenBy(p => p.Default == null).ToList(); + { + parameters = parameters + .OrderBy(p => p.Position ?? 0) + .OrderBy(p => !p.IsRequired) + .ThenBy(p => p.Default == null).ToList(); + } else - parameters = parameters.OrderBy(p => !p.IsRequired).ToList(); + { + parameters = parameters + .OrderBy(p => p.Position ?? 0) + .OrderBy(p => !p.IsRequired) + .ToList(); + } } Parameters = parameters.Select(parameter => diff --git a/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj b/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj index 5e0bcab571..8191b2ccc7 100644 --- a/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj +++ b/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj @@ -41,7 +41,7 @@ - + diff --git a/src/NSwag.CodeGeneration.CSharp/SwaggerToCSharpClientGenerator.cs b/src/NSwag.CodeGeneration.CSharp/SwaggerToCSharpClientGenerator.cs index f86b75673b..8eaf709141 100644 --- a/src/NSwag.CodeGeneration.CSharp/SwaggerToCSharpClientGenerator.cs +++ b/src/NSwag.CodeGeneration.CSharp/SwaggerToCSharpClientGenerator.cs @@ -35,11 +35,8 @@ public SwaggerToCSharpClientGenerator(SwaggerDocument document, SwaggerToCSharpC public SwaggerToCSharpClientGenerator(SwaggerDocument document, SwaggerToCSharpClientGeneratorSettings settings, CSharpTypeResolver resolver) : base(document, settings, resolver) { - if (document == null) - throw new ArgumentNullException(nameof(document)); - Settings = settings; - _document = document; + _document = document ?? throw new ArgumentNullException(nameof(document)); } /// Gets or sets the generator settings. diff --git a/src/NSwag.CodeGeneration.CSharp/SwaggerToCSharpGeneratorBase.cs b/src/NSwag.CodeGeneration.CSharp/SwaggerToCSharpGeneratorBase.cs index 9b820dc895..43690f67a7 100644 --- a/src/NSwag.CodeGeneration.CSharp/SwaggerToCSharpGeneratorBase.cs +++ b/src/NSwag.CodeGeneration.CSharp/SwaggerToCSharpGeneratorBase.cs @@ -25,7 +25,7 @@ public abstract class SwaggerToCSharpGeneratorBase : ClientGeneratorBaseThe settings. /// The resolver. protected SwaggerToCSharpGeneratorBase(SwaggerDocument document, SwaggerToCSharpGeneratorSettings settings, CSharpTypeResolver resolver) - : base(resolver, settings.CodeGeneratorSettings) + : base(document, settings.CodeGeneratorSettings, resolver) { _document = document; _settings = settings; diff --git a/src/NSwag.CodeGeneration.CSharp/Templates/File.liquid b/src/NSwag.CodeGeneration.CSharp/Templates/File.liquid index 4afead112a..4ebf5eea44 100644 --- a/src/NSwag.CodeGeneration.CSharp/Templates/File.liquid +++ b/src/NSwag.CodeGeneration.CSharp/Templates/File.liquid @@ -118,7 +118,7 @@ namespace {{ Namespace }} public System.Collections.Generic.Dictionary> Headers { get; private set; } public {{ exceptionClassName }}(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) - : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : str.Length), innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) { StatusCode = statusCode; Response = response; diff --git a/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj b/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj index ebff143c5a..a0151ec8d6 100644 --- a/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj +++ b/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj @@ -75,17 +75,17 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.9.10.75\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.9.11.0\lib\net45\NJsonSchema.dll - - ..\packages\NJsonSchema.CodeGeneration.9.10.75\lib\net451\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.9.11.0\lib\net451\NJsonSchema.CodeGeneration.dll - - ..\packages\NJsonSchema.CodeGeneration.CSharp.9.10.75\lib\net451\NJsonSchema.CodeGeneration.CSharp.dll + + ..\packages\NJsonSchema.CodeGeneration.CSharp.9.11.0\lib\net451\NJsonSchema.CodeGeneration.CSharp.dll - - ..\packages\NJsonSchema.CodeGeneration.TypeScript.9.10.75\lib\net451\NJsonSchema.CodeGeneration.TypeScript.dll + + ..\packages\NJsonSchema.CodeGeneration.TypeScript.9.11.0\lib\net451\NJsonSchema.CodeGeneration.TypeScript.dll ..\packages\Swashbuckle.Core.5.5.3\lib\net40\Swashbuckle.Core.dll diff --git a/src/NSwag.CodeGeneration.Tests/packages.config b/src/NSwag.CodeGeneration.Tests/packages.config index 3120264702..7834e2470c 100644 --- a/src/NSwag.CodeGeneration.Tests/packages.config +++ b/src/NSwag.CodeGeneration.Tests/packages.config @@ -13,10 +13,10 @@ - - - - + + + + diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/NSwag.CodeGeneration.TypeScript.Tests.csproj b/src/NSwag.CodeGeneration.TypeScript.Tests/NSwag.CodeGeneration.TypeScript.Tests.csproj index 4d8ed4f777..5562b7ca04 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/NSwag.CodeGeneration.TypeScript.Tests.csproj +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/NSwag.CodeGeneration.TypeScript.Tests.csproj @@ -46,14 +46,14 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.9.10.75\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.9.11.0\lib\net45\NJsonSchema.dll - - ..\packages\NJsonSchema.CodeGeneration.9.10.75\lib\net451\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.9.11.0\lib\net451\NJsonSchema.CodeGeneration.dll - - ..\packages\NJsonSchema.CodeGeneration.TypeScript.9.10.75\lib\net451\NJsonSchema.CodeGeneration.TypeScript.dll + + ..\packages\NJsonSchema.CodeGeneration.TypeScript.9.11.0\lib\net451\NJsonSchema.CodeGeneration.TypeScript.dll diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/packages.config b/src/NSwag.CodeGeneration.TypeScript.Tests/packages.config index 7822b7af93..467590c538 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/packages.config +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/packages.config @@ -9,9 +9,9 @@ - - - + + + diff --git a/src/NSwag.CodeGeneration.TypeScript/Models/TypeScriptOperationModel.cs b/src/NSwag.CodeGeneration.TypeScript/Models/TypeScriptOperationModel.cs index b504e567e2..62721ce61d 100644 --- a/src/NSwag.CodeGeneration.TypeScript/Models/TypeScriptOperationModel.cs +++ b/src/NSwag.CodeGeneration.TypeScript/Models/TypeScriptOperationModel.cs @@ -38,7 +38,12 @@ public class TypeScriptOperationModel : OperationModelBase !p.IsRequired).ToList(); + { + parameters = parameters + .OrderBy(p => p.Position ?? 0) + .OrderBy(p => !p.IsRequired) + .ToList(); + } Parameters = parameters.Select(parameter => new TypeScriptParameterModel(parameter.Name, diff --git a/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj b/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj index 218f009426..2391bf8c69 100644 --- a/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj +++ b/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj @@ -36,7 +36,7 @@ - + diff --git a/src/NSwag.CodeGeneration.TypeScript/SwaggerToTypeScriptClientGenerator.cs b/src/NSwag.CodeGeneration.TypeScript/SwaggerToTypeScriptClientGenerator.cs index d4b7cb03f0..adaa2659a3 100644 --- a/src/NSwag.CodeGeneration.TypeScript/SwaggerToTypeScriptClientGenerator.cs +++ b/src/NSwag.CodeGeneration.TypeScript/SwaggerToTypeScriptClientGenerator.cs @@ -37,14 +37,11 @@ public SwaggerToTypeScriptClientGenerator(SwaggerDocument document, SwaggerToTyp /// The resolver. /// is . public SwaggerToTypeScriptClientGenerator(SwaggerDocument document, SwaggerToTypeScriptClientGeneratorSettings settings, TypeScriptTypeResolver resolver) - : base(resolver, settings.CodeGeneratorSettings) + : base(document, settings.CodeGeneratorSettings, resolver) { - if (document == null) - throw new ArgumentNullException(nameof(document)); - Settings = settings; - _document = document; + _document = document ?? throw new ArgumentNullException(nameof(document)); _resolver = resolver; _resolver.RegisterSchemaDefinitions(_document.Definitions); _extensionCode = new TypeScriptExtensionCode( diff --git a/src/NSwag.CodeGeneration/ClientGeneratorBase.cs b/src/NSwag.CodeGeneration/ClientGeneratorBase.cs index e93f38c60a..f6cf9b2b4e 100644 --- a/src/NSwag.CodeGeneration/ClientGeneratorBase.cs +++ b/src/NSwag.CodeGeneration/ClientGeneratorBase.cs @@ -25,12 +25,13 @@ public abstract class ClientGeneratorBaseInitializes a new instance of the class. - /// The type resolver. + /// The document. /// The code generator settings. - protected ClientGeneratorBase(TypeResolverBase resolver, CodeGeneratorSettingsBase codeGeneratorSettings) + /// The type resolver. + protected ClientGeneratorBase(SwaggerDocument document, CodeGeneratorSettingsBase codeGeneratorSettings, TypeResolverBase resolver) { Resolver = resolver; - codeGeneratorSettings.SchemaType = SchemaType.Swagger2; // enforce Swagger schema output + codeGeneratorSettings.SchemaType = document.SchemaType; // enforce Swagger schema output } /// Generates the the whole file containing all needed types. diff --git a/src/NSwag.CodeGeneration/JsonSchemaExtensions.cs b/src/NSwag.CodeGeneration/JsonSchemaExtensions.cs index 5c99f27205..d7ccc1857f 100644 --- a/src/NSwag.CodeGeneration/JsonSchemaExtensions.cs +++ b/src/NSwag.CodeGeneration/JsonSchemaExtensions.cs @@ -25,7 +25,7 @@ public static bool UsesComplexObjectSchema(this JsonSchema4 schema) private static bool UsesComplexObjectSchema(this JsonSchema4 schema, List checkedSchemas) { - schema = schema.ActualSchema; + schema = schema.ActualTypeSchema; if (checkedSchemas.Contains(schema)) return false; diff --git a/src/NSwag.CodeGeneration/Models/ParameterModelBase.cs b/src/NSwag.CodeGeneration/Models/ParameterModelBase.cs index 8a81d07a44..a84b81d5b1 100644 --- a/src/NSwag.CodeGeneration/Models/ParameterModelBase.cs +++ b/src/NSwag.CodeGeneration/Models/ParameterModelBase.cs @@ -159,7 +159,7 @@ public IEnumerable CollectionPropertyNames Schema.Item?.ActualSchema.IsAnyType == true); /// Gets a value indicating whether the parameter is of type object. - public bool IsBody => this.Kind == SwaggerParameterKind.Body; + public bool IsBody => Kind == SwaggerParameterKind.Body; /// Gets the operation extension data. public IDictionary ExtensionData => _parameter.ExtensionData; diff --git a/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj b/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj index 9c8614429c..e3c277717f 100644 --- a/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj +++ b/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/src/NSwag.Commands/NSwag.Commands.csproj b/src/NSwag.Commands/NSwag.Commands.csproj index 75ebeef3cd..77e6f862a3 100644 --- a/src/NSwag.Commands/NSwag.Commands.csproj +++ b/src/NSwag.Commands/NSwag.Commands.csproj @@ -50,11 +50,11 @@ - - - - - + + + + + diff --git a/src/NSwag.Core.Yaml/NSwag.Core.Yaml.csproj b/src/NSwag.Core.Yaml/NSwag.Core.Yaml.csproj index a01b272d91..f7dcd661eb 100644 --- a/src/NSwag.Core.Yaml/NSwag.Core.Yaml.csproj +++ b/src/NSwag.Core.Yaml/NSwag.Core.Yaml.csproj @@ -16,7 +16,7 @@ NSwag - + diff --git a/src/NSwag.Core/NSwag.Core.csproj b/src/NSwag.Core/NSwag.Core.csproj index 91ffe78e08..01f1320637 100644 --- a/src/NSwag.Core/NSwag.Core.csproj +++ b/src/NSwag.Core/NSwag.Core.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/NSwag.Core/OpenApiRequestBody.cs b/src/NSwag.Core/OpenApiRequestBody.cs index 98e636403e..65a0547211 100644 --- a/src/NSwag.Core/OpenApiRequestBody.cs +++ b/src/NSwag.Core/OpenApiRequestBody.cs @@ -18,6 +18,7 @@ public class OpenApiRequestBody private string _name; private bool _isRequired; private string _description; + private int? _position; /// Initializes a new instance of the class. public OpenApiRequestBody() @@ -78,6 +79,18 @@ public bool IsRequired } } + /// Gets or sets the name. + [JsonProperty(PropertyName = "x-position", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public int? Position + { + get => _position; + set + { + _position = value; + Parent?.UpdateBodyParameter(); + } + } + /// Gets the actual name of the request body parameter. [JsonIgnore] public string ActualName => string.IsNullOrEmpty(Name) ? "body" : Name; diff --git a/src/NSwag.Core/SwaggerDocument.Serialization.cs b/src/NSwag.Core/SwaggerDocument.Serialization.cs index 55194f63e8..c1377e4763 100644 --- a/src/NSwag.Core/SwaggerDocument.Serialization.cs +++ b/src/NSwag.Core/SwaggerDocument.Serialization.cs @@ -41,6 +41,8 @@ public static PropertyRenameAndIgnoreSerializerContractResolver CreateJsonSerial resolver.IgnoreProperty(typeof(SwaggerOperation), "consumes"); resolver.IgnoreProperty(typeof(SwaggerOperation), "produces"); + //resolver.IgnoreProperty(typeof(SwaggerParameter), "x-nullable"); + //resolver.IgnoreProperty(typeof(SwaggerResponse), "consumes"); => TODO map to response.content //resolver.IgnoreProperty(typeof(SwaggerResponse), "produces"); @@ -51,6 +53,7 @@ public static PropertyRenameAndIgnoreSerializerContractResolver CreateJsonSerial resolver.IgnoreProperty(typeof(SwaggerResponse), "schema"); resolver.IgnoreProperty(typeof(SwaggerResponse), "examples"); + resolver.IgnoreProperty(typeof(SwaggerResponse), "x-nullable"); resolver.IgnoreProperty(typeof(SwaggerSecurityScheme), "flow"); resolver.IgnoreProperty(typeof(SwaggerSecurityScheme), "authorizationUrl"); @@ -74,6 +77,7 @@ public static PropertyRenameAndIgnoreSerializerContractResolver CreateJsonSerial resolver.IgnoreProperty(typeof(SwaggerDocument), "components"); resolver.IgnoreProperty(typeof(SwaggerParameter), "examples"); + resolver.IgnoreProperty(typeof(SwaggerParameter), "x-position"); resolver.IgnoreProperty(typeof(SwaggerResponse), "content"); resolver.IgnoreProperty(typeof(SwaggerResponse), "links"); diff --git a/src/NSwag.Core/SwaggerOperation.cs b/src/NSwag.Core/SwaggerOperation.cs index 918a3a232c..e60edaad8d 100644 --- a/src/NSwag.Core/SwaggerOperation.cs +++ b/src/NSwag.Core/SwaggerOperation.cs @@ -194,6 +194,7 @@ internal void UpdateRequestBody(SwaggerParameter parameter) RequestBody = new OpenApiRequestBody(); RequestBody.Name = parameter.Name; + RequestBody.Position = parameter.Position; RequestBody.Description = parameter.Description; RequestBody.IsRequired = parameter.IsRequired; @@ -256,6 +257,7 @@ private void UpdateBodyParameter(SwaggerParameter parameter) { parameter.Kind = SwaggerParameterKind.Body; parameter.Name = RequestBody.ActualName; + parameter.Position = RequestBody.Position; parameter.Description = RequestBody.Description; parameter.IsRequired = RequestBody.IsRequired; parameter.Example = RequestBody.Content.FirstOrDefault().Value?.Example; diff --git a/src/NSwag.Core/SwaggerParameter.cs b/src/NSwag.Core/SwaggerParameter.cs index 9f8be9b706..20f1a5a868 100644 --- a/src/NSwag.Core/SwaggerParameter.cs +++ b/src/NSwag.Core/SwaggerParameter.cs @@ -24,6 +24,7 @@ public class SwaggerParameter : JsonSchema4 private JsonSchema4 _schema; private IDictionary _examples; private bool _explode; + private int? _position; [JsonIgnore] internal SwaggerOperation ParentOperation => Parent as SwaggerOperation; @@ -92,6 +93,38 @@ public bool IsRequired [JsonProperty(PropertyName = "allowEmptyValue", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] public bool AllowEmptyValue { get; set; } + /// Gets or sets the description. + [Newtonsoft.Json.JsonProperty("description", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public override string Description + { + get => base.Description; + set + { + base.Description = value; + ParentOperation?.UpdateRequestBody(this); + } + } + + /// Gets the actual parameter. + [JsonIgnore] + public SwaggerParameter ActualParameter => Reference is SwaggerParameter ? (SwaggerParameter)Reference : this; + + /// Gets or sets the format of the array if type array is used. + [JsonProperty(PropertyName = "collectionFormat", DefaultValueHandling = DefaultValueHandling.Ignore)] + public SwaggerParameterCollectionFormat CollectionFormat { get; set; } + + /// Gets or sets the headers (OpenAPI only). + [JsonProperty(PropertyName = "examples", DefaultValueHandling = DefaultValueHandling.Ignore)] + public IDictionary Examples + { + get => _examples; + set + { + _examples = value; + ParentOperation?.UpdateRequestBody(this); + } + } + /// Gets or sets the schema which is only available when == body. [JsonProperty(PropertyName = "schema", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] public JsonSchema4 Schema @@ -104,22 +137,22 @@ public JsonSchema4 Schema } } - /// Gets or sets the description. - [Newtonsoft.Json.JsonProperty("description", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public override string Description + /// Gets or sets the custom schema which is used when != body. + [JsonProperty(PropertyName = "x-schema", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public JsonSchema4 CustomSchema { get; set; } + + /// Gets or sets the name. + [JsonProperty(PropertyName = "x-position", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public int? Position { - get => base.Description; + get => _position; set { - base.Description = value; + _position = value; ParentOperation?.UpdateRequestBody(this); } } - /// Gets or sets the custom schema which is used when != body. - [JsonProperty(PropertyName = "x-schema", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public JsonSchema4 CustomSchema { get; set; } - /// Gets the actual schema, either the parameter schema itself (or its reference) or the property when == body. /// The schema reference path is not resolved. [JsonIgnore] @@ -134,26 +167,6 @@ public override JsonSchema4 ActualSchema } } - /// Gets the actual parameter. - [JsonIgnore] - public SwaggerParameter ActualParameter => Reference is SwaggerParameter ? (SwaggerParameter)Reference : this; - - /// Gets or sets the format of the array if type array is used. - [JsonProperty(PropertyName = "collectionFormat", DefaultValueHandling = DefaultValueHandling.Ignore)] - public SwaggerParameterCollectionFormat CollectionFormat { get; set; } - - /// Gets or sets the headers (OpenAPI only). - [JsonProperty(PropertyName = "examples", DefaultValueHandling = DefaultValueHandling.Ignore)] - public IDictionary Examples - { - get => _examples; - set - { - _examples = value; - ParentOperation?.UpdateRequestBody(this); - } - } - /// Gets a value indicating whether the validated data can be null. /// The schema type. /// The result. @@ -166,8 +179,15 @@ public override bool IsNullable(SchemaType schemaType) return IsNullableRaw.Value; } - else if (schemaType == SchemaType.OpenApi3 && IsNullableRaw.HasValue) - return IsNullableRaw.Value; + else if (schemaType == SchemaType.OpenApi3) + { + if (IsNullableRaw.HasValue) + return IsNullableRaw.Value; + else if (Schema != null) + return Schema.IsNullable(schemaType); + else if (CustomSchema != null) + return CustomSchema.IsNullable(schemaType); + } return base.IsNullable(schemaType); } diff --git a/src/NSwag.Core/SwaggerResponse.cs b/src/NSwag.Core/SwaggerResponse.cs index bd2bcf839f..a8ba4578e9 100644 --- a/src/NSwag.Core/SwaggerResponse.cs +++ b/src/NSwag.Core/SwaggerResponse.cs @@ -111,7 +111,7 @@ public bool IsNullable(SchemaType schemaType, bool fallbackValue) return IsNullableRaw.Value; } - return Schema?.ActualSchema.IsNullable(schemaType) ?? false; + return ActualResponse.Schema?.IsNullable(schemaType) ?? false; } private JsonSchema4 GetActualResponseSchema() diff --git a/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj b/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj index aa97fdb057..f63b656fe2 100644 --- a/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj +++ b/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj @@ -67,8 +67,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.9.10.75\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.9.11.0\lib\net45\NJsonSchema.dll ..\packages\Owin.1.0\lib\net40\Owin.dll diff --git a/src/NSwag.Demo.Web/packages.config b/src/NSwag.Demo.Web/packages.config index aec5229815..b2a69eed6d 100644 --- a/src/NSwag.Demo.Web/packages.config +++ b/src/NSwag.Demo.Web/packages.config @@ -15,6 +15,6 @@ - + \ No newline at end of file diff --git a/src/NSwag.Integration.ClientPCL/PetStoreClient.cs b/src/NSwag.Integration.ClientPCL/PetStoreClient.cs index 7c3e7320a1..92ca570206 100644 --- a/src/NSwag.Integration.ClientPCL/PetStoreClient.cs +++ b/src/NSwag.Integration.ClientPCL/PetStoreClient.cs @@ -1,6 +1,6 @@ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- @@ -8,7 +8,7 @@ namespace PetStore { #pragma warning disable // Disable all warnings - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial interface IPetStoreClient { /// Update an existing pet @@ -258,7 +258,7 @@ public partial interface IPetStoreClient } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class PetStoreClient : IPetStoreClient { private string _baseUrl = "https://petstore.swagger.io/v2"; @@ -1974,7 +1974,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Order : System.ComponentModel.INotifyPropertyChanged { private long? _id; @@ -2091,7 +2091,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class User : System.ComponentModel.INotifyPropertyChanged { private long? _id; @@ -2237,7 +2237,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Category : System.ComponentModel.INotifyPropertyChanged { private long? _id; @@ -2292,7 +2292,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Tag : System.ComponentModel.INotifyPropertyChanged { private long? _id; @@ -2347,7 +2347,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Pet : System.ComponentModel.INotifyPropertyChanged { private long? _id; @@ -2466,7 +2466,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class ApiResponse : System.ComponentModel.INotifyPropertyChanged { private int? _code; @@ -2536,7 +2536,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public enum Anonymous { [System.Runtime.Serialization.EnumMember(Value = "available")] @@ -2550,7 +2550,7 @@ public enum Anonymous } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public enum OrderStatus { [System.Runtime.Serialization.EnumMember(Value = "placed")] @@ -2564,7 +2564,7 @@ public enum OrderStatus } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public enum PetStatus { [System.Runtime.Serialization.EnumMember(Value = "available")] @@ -2578,7 +2578,7 @@ public enum PetStatus } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class FileParameter { public FileParameter(System.IO.Stream data) @@ -2597,7 +2597,7 @@ public FileParameter(System.IO.Stream data, string fileName) public string FileName { get; private set; } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class SwaggerException : System.Exception { public int StatusCode { get; private set; } @@ -2607,7 +2607,7 @@ public partial class SwaggerException : System.Exception public System.Collections.Generic.Dictionary> Headers { get; private set; } public SwaggerException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) - : base(message, innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) { StatusCode = statusCode; Response = response; @@ -2620,7 +2620,7 @@ public override string ToString() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class SwaggerException : SwaggerException { public TResult Result { get; private set; } diff --git a/src/NSwag.Integration.ClientPCL/ServiceClients.cs b/src/NSwag.Integration.ClientPCL/ServiceClients.cs index 51dce0e3d0..d7ad296f58 100644 --- a/src/NSwag.Integration.ClientPCL/ServiceClients.cs +++ b/src/NSwag.Integration.ClientPCL/ServiceClients.cs @@ -1,6 +1,6 @@ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- @@ -10,7 +10,7 @@ namespace NSwag.Integration.ClientPCL { #pragma warning disable // Disable all warnings - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class GeoClient : ClientBase { private string _baseUrl = "http://localhost:13452"; @@ -886,7 +886,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class PersonsClient : ClientBase { private string _baseUrl = "http://localhost:13452"; @@ -1853,7 +1853,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] internal class JsonExceptionConverter : Newtonsoft.Json.JsonConverter { private readonly Newtonsoft.Json.Serialization.DefaultContractResolver _defaultContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); diff --git a/src/NSwag.Integration.ClientPCL/ServiceClientsContracts.cs b/src/NSwag.Integration.ClientPCL/ServiceClientsContracts.cs index 838c2dc8d4..20dcdf13f1 100644 --- a/src/NSwag.Integration.ClientPCL/ServiceClientsContracts.cs +++ b/src/NSwag.Integration.ClientPCL/ServiceClientsContracts.cs @@ -1,6 +1,6 @@ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- @@ -14,7 +14,7 @@ namespace NSwag.Integration.ClientPCL.Contracts - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class GeoPoint { [Newtonsoft.Json.JsonProperty("Latitude", Required = Newtonsoft.Json.Required.Always)] @@ -35,7 +35,7 @@ public static GeoPoint FromJson(string data) } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class GenericRequestOfAddressAndPerson { [Newtonsoft.Json.JsonProperty("Item1", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -56,7 +56,7 @@ public static GenericRequestOfAddressAndPerson FromJson(string data) } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Address { [Newtonsoft.Json.JsonProperty("IsPrimary", Required = Newtonsoft.Json.Required.Always)] @@ -79,7 +79,7 @@ public static Address FromJson(string data) [Newtonsoft.Json.JsonConverter(typeof(JsonInheritanceConverter), "discriminator")] [JsonInheritanceAttribute("Teacher", typeof(Teacher))] - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Person { [Newtonsoft.Json.JsonProperty("Id", Required = Newtonsoft.Json.Required.Always)] @@ -143,7 +143,7 @@ public static Person FromJson(string data) } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public enum Gender { [System.Runtime.Serialization.EnumMember(Value = "Male")] @@ -154,7 +154,7 @@ public enum Gender } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public enum SkillLevel { Low = 0, @@ -165,7 +165,7 @@ public enum SkillLevel } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Teacher : Person { [Newtonsoft.Json.JsonProperty("Course", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -186,7 +186,7 @@ public static Teacher FromJson(string data) } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] [Newtonsoft.Json.JsonObjectAttribute] public partial class PersonNotFoundException : System.Exception { @@ -206,7 +206,7 @@ public static PersonNotFoundException FromJson(string data) } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] [System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple = true)] internal class JsonInheritanceAttribute : System.Attribute { @@ -221,7 +221,7 @@ public JsonInheritanceAttribute(string key, System.Type type) public System.Type Type { get; } } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] internal class JsonInheritanceConverter : Newtonsoft.Json.JsonConverter { internal static readonly string DefaultDiscriminatorName = "discriminator"; @@ -334,7 +334,7 @@ private string GetSubtypeDiscriminator(System.Type objectType) } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class FileParameter { public FileParameter(System.IO.Stream data) @@ -389,7 +389,7 @@ public void Dispose() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class SwaggerResponse { public int StatusCode { get; private set; } @@ -403,7 +403,7 @@ public SwaggerResponse(int statusCode, System.Collections.Generic.Dictionary : SwaggerResponse { public TResult Result { get; private set; } @@ -415,7 +415,7 @@ public SwaggerResponse(int statusCode, System.Collections.Generic.Dictionary> Headers { get; private set; } public GeoClientException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) - : base(message, innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) { StatusCode = statusCode; Response = response; @@ -438,7 +438,7 @@ public override string ToString() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class GeoClientException : GeoClientException { public TResult Result { get; private set; } @@ -450,7 +450,7 @@ public GeoClientException(string message, int statusCode, string response, Syste } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class PersonsClientException : System.Exception { public int StatusCode { get; private set; } @@ -460,7 +460,7 @@ public partial class PersonsClientException : System.Exception public System.Collections.Generic.Dictionary> Headers { get; private set; } public PersonsClientException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) - : base(message, innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) { StatusCode = statusCode; Response = response; @@ -473,7 +473,7 @@ public override string ToString() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class PersonsClientException : PersonsClientException { public TResult Result { get; private set; } diff --git a/src/NSwag.Integration.ClientPCL/UberClient.cs b/src/NSwag.Integration.ClientPCL/UberClient.cs index 9d971ac3c2..6a1c04cd63 100644 --- a/src/NSwag.Integration.ClientPCL/UberClient.cs +++ b/src/NSwag.Integration.ClientPCL/UberClient.cs @@ -1,6 +1,6 @@ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- @@ -8,7 +8,7 @@ namespace Uber { #pragma warning disable // Disable all warnings - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class Client { private string _baseUrl = "https://api.uber.com/v1"; @@ -578,7 +578,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Product : System.ComponentModel.INotifyPropertyChanged { private string _product_id; @@ -683,7 +683,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class PriceEstimate : System.ComponentModel.INotifyPropertyChanged { private string _product_id; @@ -820,7 +820,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Profile : System.ComponentModel.INotifyPropertyChanged { private string _first_name; @@ -925,7 +925,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Activity : System.ComponentModel.INotifyPropertyChanged { private string _uuid; @@ -966,7 +966,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Activities : System.ComponentModel.INotifyPropertyChanged { private int? _offset; @@ -1054,7 +1054,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Error : System.ComponentModel.INotifyPropertyChanged { private int? _code; @@ -1124,7 +1124,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class SwaggerException : System.Exception { public int StatusCode { get; private set; } @@ -1134,7 +1134,7 @@ public partial class SwaggerException : System.Exception public System.Collections.Generic.Dictionary> Headers { get; private set; } public SwaggerException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) - : base(message, innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) { StatusCode = statusCode; Response = response; @@ -1147,7 +1147,7 @@ public override string ToString() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class SwaggerException : SwaggerException { public TResult Result { get; private set; } diff --git a/src/NSwag.Integration.ClientPCL/swagger.json b/src/NSwag.Integration.ClientPCL/swagger.json index 71abecb8cf..ddb259545f 100644 --- a/src/NSwag.Integration.ClientPCL/swagger.json +++ b/src/NSwag.Integration.ClientPCL/swagger.json @@ -1,7 +1,7 @@ { - "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))", + "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))", "info": { - "title": "Web API Swagger specification", + "title": "Swagger specification", "version": "1.0.0" }, "host": "localhost:13452", @@ -595,7 +595,8 @@ "in": "body", "required": true, "schema": { - "type": "string" + "type": "string", + "x-nullable": true }, "x-nullable": true } @@ -627,7 +628,8 @@ "required": true, "schema": { "type": "string", - "format": "byte" + "format": "byte", + "x-nullable": true }, "x-nullable": true } @@ -814,45 +816,49 @@ ] }, "Teacher": { - "type": "object", - "additionalProperties": false, - "required": [ - "SkillLevel" - ], - "properties": { - "Course": { - "type": "string" - }, - "SkillLevel": { - "default": 1, - "allOf": [ - { - "$ref": "#/definitions/SkillLevel" - } - ] - } - }, "allOf": [ { "$ref": "#/definitions/Person" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "SkillLevel" + ], + "properties": { + "Course": { + "type": "string" + }, + "SkillLevel": { + "default": 1, + "allOf": [ + { + "$ref": "#/definitions/SkillLevel" + } + ] + } + } } ] }, "PersonNotFoundException": { - "type": "object", - "additionalProperties": false, - "required": [ - "id" - ], - "properties": { - "id": { - "type": "string", - "format": "guid" - } - }, "allOf": [ { "$ref": "#/definitions/Exception" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "id" + ], + "properties": { + "id": { + "type": "string", + "format": "guid" + } + } } ] } diff --git a/src/NSwag.Integration.Console/Controllers.cs b/src/NSwag.Integration.Console/Controllers.cs index d00d90ce24..57efa8e661 100644 --- a/src/NSwag.Integration.Console/Controllers.cs +++ b/src/NSwag.Integration.Console/Controllers.cs @@ -1,6 +1,6 @@ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- @@ -10,7 +10,7 @@ namespace MyNamespace { #pragma warning disable // Disable all warnings - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public interface IGeoController { System.Threading.Tasks.Task FromBodyTestAsync(GeoPoint location); @@ -37,7 +37,7 @@ public interface IGeoController } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class GeoController : System.Web.Http.ApiController { private IGeoController _implementation; @@ -115,7 +115,7 @@ public System.Threading.Tasks.Task GetUploadedFile(int id, bool? @ } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public interface IPersonsController { System.Threading.Tasks.Task> GetAllAsync(); @@ -145,7 +145,7 @@ public interface IPersonsController } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class PersonsController : System.Web.Http.ApiController { private IPersonsController _implementation; @@ -228,7 +228,7 @@ public System.Threading.Tasks.Task Upload([System.Web.Http.FromBody] Sys - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class GeoPoint : System.ComponentModel.INotifyPropertyChanged { private double _latitude; @@ -283,7 +283,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class GenericRequestOfAddressAndPerson : System.ComponentModel.INotifyPropertyChanged { private Address _item1; @@ -338,7 +338,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Address : System.ComponentModel.INotifyPropertyChanged { private bool _isPrimary; @@ -395,7 +395,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal [Newtonsoft.Json.JsonConverter(typeof(JsonInheritanceConverter), "discriminator")] [JsonInheritanceAttribute("Teacher", typeof(Teacher))] - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Person : System.ComponentModel.INotifyPropertyChanged { private System.Guid _id; @@ -613,7 +613,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public enum Gender { [System.Runtime.Serialization.EnumMember(Value = "Male")] @@ -624,7 +624,7 @@ public enum Gender } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public enum SkillLevel { Low = 0, @@ -635,7 +635,7 @@ public enum SkillLevel } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Teacher : Person, System.ComponentModel.INotifyPropertyChanged { private string _course; @@ -690,7 +690,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] [Newtonsoft.Json.JsonObjectAttribute] public partial class PersonNotFoundException : System.Exception, System.ComponentModel.INotifyPropertyChanged { @@ -732,7 +732,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] [System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple = true)] internal class JsonInheritanceAttribute : System.Attribute { @@ -747,7 +747,7 @@ public JsonInheritanceAttribute(string key, System.Type type) public System.Type Type { get; } } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] internal class JsonInheritanceConverter : Newtonsoft.Json.JsonConverter { internal static readonly string DefaultDiscriminatorName = "discriminator"; @@ -860,7 +860,7 @@ private string GetSubtypeDiscriminator(System.Type objectType) } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class FileParameter { public FileParameter(System.IO.Stream data) @@ -915,7 +915,7 @@ public void Dispose() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] internal class JsonExceptionConverter : Newtonsoft.Json.JsonConverter { private readonly Newtonsoft.Json.Serialization.DefaultContractResolver _defaultContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); diff --git a/src/NSwag.Integration.Console/ServiceClients.cs b/src/NSwag.Integration.Console/ServiceClients.cs index d15d373b74..d2e085cf81 100644 --- a/src/NSwag.Integration.Console/ServiceClients.cs +++ b/src/NSwag.Integration.Console/ServiceClients.cs @@ -1,6 +1,6 @@ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- @@ -10,7 +10,7 @@ namespace NSwag.Integration.Console { #pragma warning disable // Disable all warnings - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class GeoClient { private System.Lazy _settings; @@ -886,7 +886,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class PersonsClient { private System.Lazy _settings; @@ -1863,7 +1863,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] internal class JsonExceptionConverter : Newtonsoft.Json.JsonConverter { private readonly Newtonsoft.Json.Serialization.DefaultContractResolver _defaultContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); diff --git a/src/NSwag.Integration.Console/ServiceClientsContracts.cs b/src/NSwag.Integration.Console/ServiceClientsContracts.cs index b0620fab9c..a39e73510c 100644 --- a/src/NSwag.Integration.Console/ServiceClientsContracts.cs +++ b/src/NSwag.Integration.Console/ServiceClientsContracts.cs @@ -1,6 +1,6 @@ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- @@ -14,7 +14,7 @@ namespace NSwag.Integration.Console.Contracts - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class GeoPoint { [Newtonsoft.Json.JsonProperty("Latitude", Required = Newtonsoft.Json.Required.Always)] @@ -35,7 +35,7 @@ public static GeoPoint FromJson(string data) } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class GenericRequestOfAddressAndPerson { [Newtonsoft.Json.JsonProperty("Item1", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -56,7 +56,7 @@ public static GenericRequestOfAddressAndPerson FromJson(string data) } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Address { [Newtonsoft.Json.JsonProperty("IsPrimary", Required = Newtonsoft.Json.Required.Always)] @@ -79,7 +79,7 @@ public static Address FromJson(string data) [Newtonsoft.Json.JsonConverter(typeof(JsonInheritanceConverter), "discriminator")] [JsonInheritanceAttribute("Teacher", typeof(Teacher))] - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Person { [Newtonsoft.Json.JsonProperty("Id", Required = Newtonsoft.Json.Required.Always)] @@ -143,7 +143,7 @@ public static Person FromJson(string data) } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public enum Gender { [System.Runtime.Serialization.EnumMember(Value = "Male")] @@ -154,7 +154,7 @@ public enum Gender } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public enum SkillLevel { Low = 0, @@ -165,7 +165,7 @@ public enum SkillLevel } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] public partial class Teacher : Person { [Newtonsoft.Json.JsonProperty("Course", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -186,7 +186,7 @@ public static Teacher FromJson(string data) } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.73.0 (Newtonsoft.Json v9.0.0.0)")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.11.0.0 (Newtonsoft.Json v9.0.0.0)")] [Newtonsoft.Json.JsonObjectAttribute] public partial class PersonNotFoundException : System.Exception { @@ -206,7 +206,7 @@ public static PersonNotFoundException FromJson(string data) } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] [System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple = true)] internal class JsonInheritanceAttribute : System.Attribute { @@ -221,7 +221,7 @@ public JsonInheritanceAttribute(string key, System.Type type) public System.Type Type { get; } } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] internal class JsonInheritanceConverter : Newtonsoft.Json.JsonConverter { internal static readonly string DefaultDiscriminatorName = "discriminator"; @@ -334,7 +334,7 @@ private string GetSubtypeDiscriminator(System.Type objectType) } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class FileParameter { public FileParameter(System.IO.Stream data) @@ -389,7 +389,7 @@ public void Dispose() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class SwaggerException : System.Exception { public int StatusCode { get; private set; } @@ -399,7 +399,7 @@ public partial class SwaggerException : System.Exception public System.Collections.Generic.Dictionary> Headers { get; private set; } public SwaggerException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) - : base(message, innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) { StatusCode = statusCode; Response = response; @@ -412,7 +412,7 @@ public override string ToString() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))")] public partial class SwaggerException : SwaggerException { public TResult Result { get; private set; } diff --git a/src/NSwag.Integration.NETCore11/NSwag.Integration.NETCore11.csproj b/src/NSwag.Integration.NETCore11/NSwag.Integration.NETCore11.csproj index 7ebb515315..d06501a8ba 100644 --- a/src/NSwag.Integration.NETCore11/NSwag.Integration.NETCore11.csproj +++ b/src/NSwag.Integration.NETCore11/NSwag.Integration.NETCore11.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngular.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngular.ts index 59ed167792..3a977fb381 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngular.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngular.ts @@ -1,7 +1,7 @@ /* tslint:disable */ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- // ReSharper disable InconsistentNaming diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngularJS.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngularJS.ts index 86ce08bee6..9f08e2b498 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngularJS.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngularJS.ts @@ -1,7 +1,7 @@ /* tslint:disable */ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- // ReSharper disable InconsistentNaming diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAurelia.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAurelia.ts index 6c637b274e..ec5674e833 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAurelia.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAurelia.ts @@ -1,7 +1,7 @@ /* tslint:disable */ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- // ReSharper disable InconsistentNaming diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsFetch.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsFetch.ts index ace3d07255..b9a8cd9800 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsFetch.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsFetch.ts @@ -1,7 +1,7 @@ /* tslint:disable */ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- // ReSharper disable InconsistentNaming diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryCallbacks.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryCallbacks.ts index 8ef311ce82..e9d7fa7672 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryCallbacks.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryCallbacks.ts @@ -1,7 +1,7 @@ /* tslint:disable */ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- // ReSharper disable InconsistentNaming diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromises.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromises.ts index 635a960fb2..ca5d5a147b 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromises.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromises.ts @@ -1,7 +1,7 @@ /* tslint:disable */ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- // ReSharper disable InconsistentNaming diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromisesKO.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromisesKO.ts index e14e0d1ea7..772dfcebb5 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromisesKO.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromisesKO.ts @@ -1,7 +1,7 @@ /* tslint:disable */ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- // ReSharper disable InconsistentNaming diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsPetStoreFetch.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsPetStoreFetch.ts index c94f93d287..c2f74931b9 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsPetStoreFetch.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsPetStoreFetch.ts @@ -1,7 +1,7 @@ /* tslint:disable */ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- // ReSharper disable InconsistentNaming diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsUberFetch.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsUberFetch.ts index e26ca9fb84..45d12ca9d5 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsUberFetch.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsUberFetch.ts @@ -1,7 +1,7 @@ /* tslint:disable */ //---------------------- // -// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- // ReSharper disable InconsistentNaming diff --git a/src/NSwag.Integration.WebAPI/NSwag.Integration.WebAPI.csproj b/src/NSwag.Integration.WebAPI/NSwag.Integration.WebAPI.csproj index de8f7d2ce7..02c7e04778 100644 --- a/src/NSwag.Integration.WebAPI/NSwag.Integration.WebAPI.csproj +++ b/src/NSwag.Integration.WebAPI/NSwag.Integration.WebAPI.csproj @@ -62,8 +62,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.9.10.75\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.9.11.0\lib\net45\NJsonSchema.dll ..\packages\Owin.1.0\lib\net40\Owin.dll diff --git a/src/NSwag.Integration.WebAPI/packages.config b/src/NSwag.Integration.WebAPI/packages.config index 27b52370d0..ba7d8d93ae 100644 --- a/src/NSwag.Integration.WebAPI/packages.config +++ b/src/NSwag.Integration.WebAPI/packages.config @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/src/NSwag.Sample.NETCore11/swagger.json b/src/NSwag.Sample.NETCore11/swagger.json index 5e369e982a..9b1768b0b4 100644 --- a/src/NSwag.Sample.NETCore11/swagger.json +++ b/src/NSwag.Sample.NETCore11/swagger.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))", + "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))", "swagger": "2.0", "info": { "title": "My Title", @@ -423,13 +423,7 @@ "definitions": { "SerializableError": { "type": "object", - "additionalProperties": false, - "allOf": [ - { - "type": "object", - "additionalProperties": {} - } - ] + "additionalProperties": {} }, "Pet": { "type": "object", diff --git a/src/NSwag.Sample.NETCore20/swagger.json b/src/NSwag.Sample.NETCore20/swagger.json index 5e369e982a..9b1768b0b4 100644 --- a/src/NSwag.Sample.NETCore20/swagger.json +++ b/src/NSwag.Sample.NETCore20/swagger.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))", + "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))", "swagger": "2.0", "info": { "title": "My Title", @@ -423,13 +423,7 @@ "definitions": { "SerializableError": { "type": "object", - "additionalProperties": false, - "allOf": [ - { - "type": "object", - "additionalProperties": {} - } - ] + "additionalProperties": {} }, "Pet": { "type": "object", diff --git a/src/NSwag.Sample.NetGlobalAsax/NSwag.Sample.NetGlobalAsax.csproj b/src/NSwag.Sample.NetGlobalAsax/NSwag.Sample.NetGlobalAsax.csproj index 1fb02ca4a9..75bc707f76 100644 --- a/src/NSwag.Sample.NetGlobalAsax/NSwag.Sample.NetGlobalAsax.csproj +++ b/src/NSwag.Sample.NetGlobalAsax/NSwag.Sample.NetGlobalAsax.csproj @@ -59,8 +59,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - ..\packages\NJsonSchema.9.10.75\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.9.11.0\lib\net45\NJsonSchema.dll ..\packages\Owin.1.0\lib\net40\Owin.dll diff --git a/src/NSwag.Sample.NetGlobalAsax/packages.config b/src/NSwag.Sample.NetGlobalAsax/packages.config index 4b6e3dc434..367add9e10 100644 --- a/src/NSwag.Sample.NetGlobalAsax/packages.config +++ b/src/NSwag.Sample.NetGlobalAsax/packages.config @@ -27,7 +27,7 @@ - + diff --git a/src/NSwag.Sample.NetGlobalAsax/swagger.json b/src/NSwag.Sample.NetGlobalAsax/swagger.json index ba88384cc6..523010d293 100644 --- a/src/NSwag.Sample.NetGlobalAsax/swagger.json +++ b/src/NSwag.Sample.NetGlobalAsax/swagger.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0))", + "x-generator": "NSwag v11.19.2.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0))", "swagger": "2.0", "info": { "title": "My Title", diff --git a/src/NSwag.SwaggerGeneration.AspNetCore/NSwag.SwaggerGeneration.AspNetCore.csproj b/src/NSwag.SwaggerGeneration.AspNetCore/NSwag.SwaggerGeneration.AspNetCore.csproj index 1a86f09e13..ba865c8916 100644 --- a/src/NSwag.SwaggerGeneration.AspNetCore/NSwag.SwaggerGeneration.AspNetCore.csproj +++ b/src/NSwag.SwaggerGeneration.AspNetCore/NSwag.SwaggerGeneration.AspNetCore.csproj @@ -24,7 +24,7 @@ - + diff --git a/src/NSwag.SwaggerGeneration.AspNetCore/Processors/OperationParameterProcessor.cs b/src/NSwag.SwaggerGeneration.AspNetCore/Processors/OperationParameterProcessor.cs index 1f1ba9fc11..37121e1991 100644 --- a/src/NSwag.SwaggerGeneration.AspNetCore/Processors/OperationParameterProcessor.cs +++ b/src/NSwag.SwaggerGeneration.AspNetCore/Processors/OperationParameterProcessor.cs @@ -48,6 +48,7 @@ public async Task ProcessAsync(OperationProcessorContext operationProcesso var methodParameters = context.MethodInfo.GetParameters(); + var position = 1; foreach (var apiParameter in parameters.Where(p => p.Source != null)) { // TODO: Provide extension point so that this can be implemented in the ApiVersionProcessor class @@ -158,7 +159,14 @@ public async Task ProcessAsync(OperationProcessorContext operationProcesso if (parameter != null && operationParameter != null) { + if (_settings.SchemaType == SchemaType.OpenApi3) + { + operationParameter.IsNullableRaw = null; + } + + operationParameter.Position = position; ((Dictionary)operationProcessorContext.Parameters)[parameter] = operationParameter; + position++; } } @@ -244,6 +252,7 @@ private async Task AddBodyParameterAsync(OperationProcessorCon { SwaggerParameter operationParameter; + // TODO: Check IsNullableRaw here var operation = context.OperationDescription.Operation; var parameterType = extendedApiParameter.ParameterType; if (parameterType.Name == "XmlDocument" || parameterType.InheritsFrom("XmlDocument", TypeNameStyle.Name)) @@ -253,7 +262,11 @@ private async Task AddBodyParameterAsync(OperationProcessorCon { Name = extendedApiParameter.ApiParameter.Name, Kind = SwaggerParameterKind.Body, - Schema = new JsonSchema4 { Type = JsonObjectType.String }, + Schema = new JsonSchema4 + { + Type = JsonObjectType.String, + IsNullableRaw = true + }, IsNullableRaw = true, IsRequired = extendedApiParameter.IsRequired(_settings.RequireParametersWithoutDefault), Description = await extendedApiParameter.GetDocumentationAsync().ConfigureAwait(false) @@ -266,13 +279,18 @@ private async Task AddBodyParameterAsync(OperationProcessorCon { Name = extendedApiParameter.ApiParameter.Name, Kind = SwaggerParameterKind.Body, - Schema = new JsonSchema4 { Type = JsonObjectType.String, Format = JsonFormatStrings.Byte }, + Schema = new JsonSchema4 + { + Type = JsonObjectType.String, + Format = JsonFormatStrings.Byte, + IsNullableRaw = true + }, IsNullableRaw = true, IsRequired = extendedApiParameter.IsRequired(_settings.RequireParametersWithoutDefault), Description = await extendedApiParameter.GetDocumentationAsync().ConfigureAwait(false) }; } - else + else // body from type { var typeDescription = _settings.ReflectionService.GetDescription(extendedApiParameter.ParameterType, extendedApiParameter.Attributes, _settings); @@ -284,7 +302,7 @@ private async Task AddBodyParameterAsync(OperationProcessorCon IsNullableRaw = typeDescription.IsNullable, Description = await extendedApiParameter.GetDocumentationAsync().ConfigureAwait(false), Schema = await context.SchemaGenerator.GenerateWithReferenceAndNullabilityAsync( - extendedApiParameter.ParameterType, extendedApiParameter.Attributes, isNullable: false, schemaResolver: context.SchemaResolver).ConfigureAwait(false) + extendedApiParameter.ParameterType, extendedApiParameter.Attributes, isNullable: false/*typeDescription.IsNullable*/, schemaResolver: context.SchemaResolver).ConfigureAwait(false) }; } diff --git a/src/NSwag.SwaggerGeneration.WebApi.Tests/NSwag.SwaggerGeneration.WebApi.Tests.csproj b/src/NSwag.SwaggerGeneration.WebApi.Tests/NSwag.SwaggerGeneration.WebApi.Tests.csproj index f204f09ce2..f4dd26fc83 100644 --- a/src/NSwag.SwaggerGeneration.WebApi.Tests/NSwag.SwaggerGeneration.WebApi.Tests.csproj +++ b/src/NSwag.SwaggerGeneration.WebApi.Tests/NSwag.SwaggerGeneration.WebApi.Tests.csproj @@ -47,8 +47,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.9.10.75\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.9.11.0\lib\net45\NJsonSchema.dll ..\packages\Swashbuckle.Core.5.5.3\lib\net40\Swashbuckle.Core.dll diff --git a/src/NSwag.SwaggerGeneration.WebApi.Tests/packages.config b/src/NSwag.SwaggerGeneration.WebApi.Tests/packages.config index d9e9e6aeae..6a19a17723 100644 --- a/src/NSwag.SwaggerGeneration.WebApi.Tests/packages.config +++ b/src/NSwag.SwaggerGeneration.WebApi.Tests/packages.config @@ -10,7 +10,7 @@ - + diff --git a/src/NSwag.SwaggerGeneration.WebApi/NSwag.SwaggerGeneration.WebApi.csproj b/src/NSwag.SwaggerGeneration.WebApi/NSwag.SwaggerGeneration.WebApi.csproj index c9edb7953e..d1b8269f8c 100644 --- a/src/NSwag.SwaggerGeneration.WebApi/NSwag.SwaggerGeneration.WebApi.csproj +++ b/src/NSwag.SwaggerGeneration.WebApi/NSwag.SwaggerGeneration.WebApi.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/NSwag.SwaggerGeneration.WebApi/Processors/OperationParameterProcessor.cs b/src/NSwag.SwaggerGeneration.WebApi/Processors/OperationParameterProcessor.cs index 1902bc3d92..b8b1ace353 100644 --- a/src/NSwag.SwaggerGeneration.WebApi/Processors/OperationParameterProcessor.cs +++ b/src/NSwag.SwaggerGeneration.WebApi/Processors/OperationParameterProcessor.cs @@ -41,6 +41,8 @@ public async Task ProcessAsync(OperationProcessorContext context) { var httpPath = context.OperationDescription.Path; var parameters = context.MethodInfo.GetParameters().ToList(); + + var position = 1; foreach (var parameter in parameters.Where(p => p.ParameterType != typeof(CancellationToken) && p.GetCustomAttributes().All(a => a.GetType().Name != "SwaggerIgnoreAttribute") && p.GetCustomAttributes().All(a => a.GetType().Name != "FromServicesAttribute") && @@ -159,7 +161,14 @@ public async Task ProcessAsync(OperationProcessorContext context) if (operationParameter != null) { + if (_settings.SchemaType == SchemaType.OpenApi3) + { + operationParameter.IsNullableRaw = null; + } + + operationParameter.Position = position; ((Dictionary)context.Parameters)[parameter] = operationParameter; + position++; } } @@ -261,7 +270,11 @@ private async Task AddBodyParameterAsync(OperationProcessorCon { Name = name, Kind = SwaggerParameterKind.Body, - Schema = new JsonSchema4 { Type = JsonObjectType.String }, + Schema = new JsonSchema4 + { + Type = JsonObjectType.String, + IsNullableRaw = true + }, IsNullableRaw = true, IsRequired = parameter.HasDefaultValue == false, Description = await parameter.GetDescriptionAsync(parameter.GetCustomAttributes()).ConfigureAwait(false) @@ -275,7 +288,12 @@ private async Task AddBodyParameterAsync(OperationProcessorCon { Name = name, Kind = SwaggerParameterKind.Body, - Schema = new JsonSchema4 { Type = JsonObjectType.String, Format = JsonFormatStrings.Byte }, + Schema = new JsonSchema4 + { + Type = JsonObjectType.String, + Format = JsonFormatStrings.Byte, + IsNullableRaw = true + }, IsNullableRaw = true, IsRequired = parameter.HasDefaultValue == false, Description = await parameter.GetDescriptionAsync(parameter.GetCustomAttributes()).ConfigureAwait(false) diff --git a/src/NSwag.SwaggerGeneration/NSwag.SwaggerGeneration.csproj b/src/NSwag.SwaggerGeneration/NSwag.SwaggerGeneration.csproj index 779f571f85..710ff5ce11 100644 --- a/src/NSwag.SwaggerGeneration/NSwag.SwaggerGeneration.csproj +++ b/src/NSwag.SwaggerGeneration/NSwag.SwaggerGeneration.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/NSwag.SwaggerGeneration/Processors/OperationResponseProcessorBase.cs b/src/NSwag.SwaggerGeneration/Processors/OperationResponseProcessorBase.cs index f31ffa040e..5952d65d3e 100644 --- a/src/NSwag.SwaggerGeneration/Processors/OperationResponseProcessorBase.cs +++ b/src/NSwag.SwaggerGeneration/Processors/OperationResponseProcessorBase.cs @@ -129,11 +129,12 @@ private async Task ProcessOperationDescriptionsAsync(IEnumerable r.IsNullable) && typeDescription.IsNullable; + var isNullable = statusCodeGroup.Any(r => r.IsNullable) && typeDescription.IsNullable; + + response.IsNullableRaw = isNullable; response.ExpectedSchemas = await GenerateExpectedSchemasAsync(statusCodeGroup, context); response.Schema = await context.SchemaGenerator - .GenerateWithReferenceAndNullabilityAsync( - returnType, null, typeDescription.IsNullable, context.SchemaResolver) + .GenerateWithReferenceAndNullabilityAsync(returnType, null, isNullable, context.SchemaResolver) .ConfigureAwait(false); } diff --git a/src/NSwag.SwaggerGeneration/SwaggerGenerator.cs b/src/NSwag.SwaggerGeneration/SwaggerGenerator.cs index ee38807967..6ccb45b0f1 100644 --- a/src/NSwag.SwaggerGeneration/SwaggerGenerator.cs +++ b/src/NSwag.SwaggerGeneration/SwaggerGenerator.cs @@ -112,7 +112,15 @@ public async Task CreatePrimitiveParameterAsync(string name, P } else { - operationParameter.Schema = new JsonSchema4 { Reference = schema.ActualSchema }; + if (typeDescription.IsNullable) + { + operationParameter.Schema = new JsonSchema4 { IsNullableRaw = true }; + operationParameter.Schema.OneOf.Add(new JsonSchema4 { Reference = schema.ActualSchema }); + } + else + { + operationParameter.Schema = new JsonSchema4 { Reference = schema.ActualSchema }; + } } } else @@ -128,7 +136,8 @@ public async Task CreatePrimitiveParameterAsync(string name, P operationParameter = new SwaggerParameter { Schema = await _schemaGenerator - .GenerateAsync(parameterType, parentAttributes, _schemaResolver) + .GenerateWithReferenceAndNullabilityAsync( + parameterType, parentAttributes, typeDescription.IsNullable, _schemaResolver) .ConfigureAwait(false) }; } diff --git a/src/NSwag.SwaggerGeneration/SwaggerJsonSchemaGenerator.cs b/src/NSwag.SwaggerGeneration/SwaggerJsonSchemaGenerator.cs index f044037c93..37664d9c4c 100644 --- a/src/NSwag.SwaggerGeneration/SwaggerJsonSchemaGenerator.cs +++ b/src/NSwag.SwaggerGeneration/SwaggerJsonSchemaGenerator.cs @@ -28,17 +28,17 @@ public SwaggerJsonSchemaGenerator(JsonSchemaGeneratorSettings settings) : base(s } /// Generates the properties for the given type and schema. - /// The type of the schema type. /// The types. + /// The type desription. /// The properties /// The schema resolver. /// - protected override async Task GenerateObjectAsync(Type type, TSchemaType schema, JsonSchemaResolver schemaResolver) + protected override async Task GenerateObjectAsync(Type type, JsonTypeDescription typeDescription, JsonSchema4 schema, JsonSchemaResolver schemaResolver) { if (_isRootType) { _isRootType = false; - await base.GenerateObjectAsync(type, schema, schemaResolver); + await base.GenerateObjectAsync(type, typeDescription, schema, schemaResolver); _isRootType = true; } else diff --git a/src/NSwag.Tests/NSwag.Tests.csproj b/src/NSwag.Tests/NSwag.Tests.csproj index 68a76775af..5ba629c39b 100644 --- a/src/NSwag.Tests/NSwag.Tests.csproj +++ b/src/NSwag.Tests/NSwag.Tests.csproj @@ -63,8 +63,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.9.10.75\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.9.11.0\lib\net45\NJsonSchema.dll diff --git a/src/NSwag.Tests/packages.config b/src/NSwag.Tests/packages.config index 4807531eaa..c2d31ed040 100644 --- a/src/NSwag.Tests/packages.config +++ b/src/NSwag.Tests/packages.config @@ -4,5 +4,5 @@ - + \ No newline at end of file diff --git a/src/NSwagStudio/NSwagStudio.csproj b/src/NSwagStudio/NSwagStudio.csproj index 44133cbab0..2edc3a757d 100644 --- a/src/NSwagStudio/NSwagStudio.csproj +++ b/src/NSwagStudio/NSwagStudio.csproj @@ -93,17 +93,17 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - ..\packages\NJsonSchema.9.10.75\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.9.11.0\lib\net45\NJsonSchema.dll - - ..\packages\NJsonSchema.CodeGeneration.9.10.75\lib\net451\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.9.11.0\lib\net451\NJsonSchema.CodeGeneration.dll - - ..\packages\NJsonSchema.CodeGeneration.CSharp.9.10.75\lib\net451\NJsonSchema.CodeGeneration.CSharp.dll + + ..\packages\NJsonSchema.CodeGeneration.CSharp.9.11.0\lib\net451\NJsonSchema.CodeGeneration.CSharp.dll - - ..\packages\NJsonSchema.CodeGeneration.TypeScript.9.10.75\lib\net451\NJsonSchema.CodeGeneration.TypeScript.dll + + ..\packages\NJsonSchema.CodeGeneration.TypeScript.9.11.0\lib\net451\NJsonSchema.CodeGeneration.TypeScript.dll diff --git a/src/NSwagStudio/Views/SwaggerGenerators/AspNetCoreToSwaggerGeneratorView.xaml b/src/NSwagStudio/Views/SwaggerGenerators/AspNetCoreToSwaggerGeneratorView.xaml index 7de8c004da..c49a0b4d6f 100644 --- a/src/NSwagStudio/Views/SwaggerGenerators/AspNetCoreToSwaggerGeneratorView.xaml +++ b/src/NSwagStudio/Views/SwaggerGenerators/AspNetCoreToSwaggerGeneratorView.xaml @@ -172,17 +172,25 @@ - - + + + + + + - - + + - - + + + - - - diff --git a/src/NSwagStudio/Views/SwaggerGenerators/WebApiToSwaggerGeneratorView.xaml b/src/NSwagStudio/Views/SwaggerGenerators/WebApiToSwaggerGeneratorView.xaml index 01ac7a8cf6..3d9ac4fd62 100644 --- a/src/NSwagStudio/Views/SwaggerGenerators/WebApiToSwaggerGeneratorView.xaml +++ b/src/NSwagStudio/Views/SwaggerGenerators/WebApiToSwaggerGeneratorView.xaml @@ -188,17 +188,25 @@ - - + + + + + + - - + + - - + + + - - - diff --git a/src/NSwagStudio/packages.config b/src/NSwagStudio/packages.config index d9d559344a..256a10c641 100644 --- a/src/NSwagStudio/packages.config +++ b/src/NSwagStudio/packages.config @@ -10,10 +10,10 @@ - - - - + + + +