diff --git a/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project.nswag b/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project.nswag index df2ca8e948..d2525069e3 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project.nswag +++ b/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project.nswag @@ -15,7 +15,7 @@ "apiGroupNames": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project_swagger.json b/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project_swagger.json index ea135da725..a21a074032 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project_swagger.json +++ b/samples/WithoutMiddleware/Sample.AspNetCore20/nswag_project_swagger.json @@ -19,7 +19,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -82,7 +82,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "string" diff --git a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly.nswag b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly.nswag index e4ae04429e..0ffecb6bab 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly.nswag +++ b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly.nswag @@ -15,7 +15,7 @@ "apiGroupNames": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly_swagger.json b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly_swagger.json index 7260e93f00..ec562c88a6 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly_swagger.json +++ b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_assembly_swagger.json @@ -19,7 +19,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -82,7 +82,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "string" diff --git a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project.nswag b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project.nswag index 3ff480629d..99f950fe0b 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project.nswag +++ b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project.nswag @@ -15,7 +15,7 @@ "apiGroupNames": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project_swagger.json b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project_swagger.json index 7260e93f00..ec562c88a6 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project_swagger.json +++ b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_project_swagger.json @@ -19,7 +19,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -82,7 +82,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "string" diff --git a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_reflection.nswag b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_reflection.nswag index d002b0d288..1f39a63f70 100644 --- a/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_reflection.nswag +++ b/samples/WithoutMiddleware/Sample.AspNetCore21/nswag_reflection.nswag @@ -11,7 +11,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Responses/NullableResponseController.cs b/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Responses/NullableResponseController.cs new file mode 100644 index 0000000000..257361bacd --- /dev/null +++ b/src/NSwag.Generation.AspNetCore.Tests.Web/Controllers/Responses/NullableResponseController.cs @@ -0,0 +1,47 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace NSwag.Generation.AspNetCore.Tests.Web.Controllers.Responses +{ + [ApiController] + [Route("api/[controller]")] + public class NullableResponseController : Controller + { + /// + /// Gets an order. + /// + /// Order created. + /// Order not found. + [HttpPost("OperationWithNullableResponse")] + [Produces("application/json")] + [ProducesResponseType(typeof(string), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(SerializableError), StatusCodes.Status400BadRequest)] + public ActionResult OperationWithNullableResponse() + { + return Ok(); + } + + /// + /// Gets an order. + /// + /// Order created. + /// Order not found. + [HttpPost("OperationWithNonNullableResponse")] + [Produces("application/json")] + [ProducesResponseType(typeof(string), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(SerializableError), StatusCodes.Status400BadRequest)] + public ActionResult OperationWithNonNullableResponse() + { + return Ok(); + } + + [HttpPost("OperationWithNoXmlDocs")] + [Produces("application/json")] + [ProducesResponseType(typeof(string), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(SerializableError), StatusCodes.Status400BadRequest)] + public ActionResult OperationWithNoXmlDocs() + { + return Ok(); + } + } +} diff --git a/src/NSwag.Generation.AspNetCore.Tests/Responses/NullableResponseTests.cs b/src/NSwag.Generation.AspNetCore.Tests/Responses/NullableResponseTests.cs index 44cbd454c3..def679489f 100644 --- a/src/NSwag.Generation.AspNetCore.Tests/Responses/NullableResponseTests.cs +++ b/src/NSwag.Generation.AspNetCore.Tests/Responses/NullableResponseTests.cs @@ -3,6 +3,7 @@ using NJsonSchema; using NJsonSchema.Generation; using NSwag.Generation.AspNetCore.Tests.Web.Controllers; +using NSwag.Generation.AspNetCore.Tests.Web.Controllers.Responses; using Xunit; namespace NSwag.Generation.AspNetCore.Tests.Responses @@ -46,5 +47,81 @@ public async Task When_handling_is_Null_then_response_is_nullable() Assert.True(operation.ActualResponses.First().Value.Schema.IsNullable(SchemaType.OpenApi3)); } + + [Fact] + public async Task When_nullable_xml_docs_is_set_to_true_then_response_is_nullable() + { + // Arrange + var settings = new AspNetCoreOpenApiDocumentGeneratorSettings + { + SchemaType = SchemaType.OpenApi3, + DefaultResponseReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull + }; + + // Act + var document = await GenerateDocumentAsync(settings, typeof(NullableResponseController)); + + // Assert + var operation = document.Operations.First(o => o.Path.Contains(nameof(NullableResponseController.OperationWithNullableResponse))).Operation; + + Assert.True(operation.ActualResponses.First().Value.Schema.IsNullable(SchemaType.OpenApi3)); + } + + [Fact] + public async Task When_nullable_xml_docs_is_set_to_false_then_response_is_not_nullable() + { + // Arrange + var settings = new AspNetCoreOpenApiDocumentGeneratorSettings + { + SchemaType = SchemaType.OpenApi3, + DefaultResponseReferenceTypeNullHandling = ReferenceTypeNullHandling.Null + }; + + // Act + var document = await GenerateDocumentAsync(settings, typeof(NullableResponseController)); + + // Assert + var operation = document.Operations.First(o => o.Path.Contains(nameof(NullableResponseController.OperationWithNonNullableResponse))).Operation; + + Assert.False(operation.ActualResponses.First().Value.Schema.IsNullable(SchemaType.OpenApi3)); + } + + [Fact] + public async Task When_nullable_xml_docs_is_not_set_then_default_setting_NotNull_is_used() + { + // Arrange + var settings = new AspNetCoreOpenApiDocumentGeneratorSettings + { + SchemaType = SchemaType.OpenApi3, + DefaultResponseReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull + }; + + // Act + var document = await GenerateDocumentAsync(settings, typeof(NullableResponseController)); + + // Assert + var operation = document.Operations.First(o => o.Path.Contains(nameof(NullableResponseController.OperationWithNoXmlDocs))).Operation; + + Assert.False(operation.ActualResponses.First().Value.Schema.IsNullable(SchemaType.OpenApi3)); + } + + [Fact] + public async Task When_nullable_xml_docs_is_not_set_then_default_setting_Null_is_used() + { + // Arrange + var settings = new AspNetCoreOpenApiDocumentGeneratorSettings + { + SchemaType = SchemaType.OpenApi3, + DefaultResponseReferenceTypeNullHandling = ReferenceTypeNullHandling.Null + }; + + // Act + var document = await GenerateDocumentAsync(settings, typeof(NullableResponseController)); + + // Assert + var operation = document.Operations.First(o => o.Path.Contains(nameof(NullableResponseController.OperationWithNoXmlDocs))).Operation; + + Assert.True(operation.ActualResponses.First().Value.Schema.IsNullable(SchemaType.OpenApi3)); + } } } \ No newline at end of file diff --git a/src/NSwag.Generation.AspNetCore/Processors/OperationResponseProcessor.cs b/src/NSwag.Generation.AspNetCore/Processors/OperationResponseProcessor.cs index 6f285946fc..021139b765 100644 --- a/src/NSwag.Generation.AspNetCore/Processors/OperationResponseProcessor.cs +++ b/src/NSwag.Generation.AspNetCore/Processors/OperationResponseProcessor.cs @@ -82,12 +82,14 @@ public bool Process(OperationProcessorContext operationProcessorContext) var returnTypeAttributes = context.MethodInfo.ReturnParameter?.GetCustomAttributes(false).OfType(); var contextualReturnType = returnType.ToContextualType(returnTypeAttributes); - var typeDescription = _settings.ReflectionService.GetDescription( - contextualReturnType, _settings.DefaultResponseReferenceTypeNullHandling, _settings); + var nullableXmlAttribute = GetResponseXmlDocsElement(context.MethodInfo, httpStatusCode)?.Attribute("nullable"); + var isResponseNullable = nullableXmlAttribute != null ? + nullableXmlAttribute.Value.ToLowerInvariant() == "true" : + _settings.ReflectionService.GetDescription(contextualReturnType, _settings.DefaultResponseReferenceTypeNullHandling, _settings).IsNullable; - response.IsNullableRaw = typeDescription.IsNullable; - response.Schema = context.SchemaGenerator - .GenerateWithReferenceAndNullability(contextualReturnType, typeDescription.IsNullable, context.SchemaResolver); + response.IsNullableRaw = isResponseNullable; + response.Schema = context.SchemaGenerator.GenerateWithReferenceAndNullability( + contextualReturnType, isResponseNullable, context.SchemaResolver); } context.OperationDescription.Operation.Responses[httpStatusCode] = response; diff --git a/src/NSwag.Generation.WebApi.Tests/Nullability/ResponseNullabilityTests.cs b/src/NSwag.Generation.WebApi.Tests/Nullability/ResponseNullabilityTests.cs index af79d7a8a3..789f830846 100644 --- a/src/NSwag.Generation.WebApi.Tests/Nullability/ResponseNullabilityTests.cs +++ b/src/NSwag.Generation.WebApi.Tests/Nullability/ResponseNullabilityTests.cs @@ -5,6 +5,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NJsonSchema; using NJsonSchema.Annotations; +using NJsonSchema.Generation; using NSwag.Annotations; namespace NSwag.Generation.WebApi.Tests.Nullability @@ -41,7 +42,10 @@ public object Ghi() public async Task When_response_is_not_nullable_then_nullable_is_false_in_spec() { /// Arrange - var generator = new WebApiOpenApiDocumentGenerator(new WebApiOpenApiDocumentGeneratorSettings()); + var generator = new WebApiOpenApiDocumentGenerator(new WebApiOpenApiDocumentGeneratorSettings + { + DefaultResponseReferenceTypeNullHandling = ReferenceTypeNullHandling.Null + }); /// Act var document = await generator.GenerateForControllerAsync(); diff --git a/src/NSwag.Generation/OpenApiDocumentGeneratorSettings.cs b/src/NSwag.Generation/OpenApiDocumentGeneratorSettings.cs index 5a6d204730..70c969148f 100644 --- a/src/NSwag.Generation/OpenApiDocumentGeneratorSettings.cs +++ b/src/NSwag.Generation/OpenApiDocumentGeneratorSettings.cs @@ -25,7 +25,7 @@ public class OpenApiDocumentGeneratorSettings : JsonSchemaGeneratorSettings public OpenApiDocumentGeneratorSettings() { SchemaGenerator = new OpenApiSchemaGenerator(this); - DefaultResponseReferenceTypeNullHandling = ReferenceTypeNullHandling.Null; + DefaultResponseReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull; SchemaType = SchemaType.Swagger2; } diff --git a/src/NSwag.Generation/Processors/OperationResponseProcessorBase.cs b/src/NSwag.Generation/Processors/OperationResponseProcessorBase.cs index de1a2b4d2e..47509641ee 100644 --- a/src/NSwag.Generation/Processors/OperationResponseProcessorBase.cs +++ b/src/NSwag.Generation/Processors/OperationResponseProcessorBase.cs @@ -58,9 +58,8 @@ protected void UpdateResponseDescription(OperationProcessorContext operationProc { var returnParameter = operationProcessorContext.MethodInfo.ReturnParameter.ToContextualParameter(); - var operationXmlDocs = operationProcessorContext.MethodInfo.GetXmlDocsElement(); - var operationXmlDocsNodes = operationXmlDocs?.Nodes()?.OfType(); var returnParameterXmlDocs = returnParameter.GetDescription() ?? string.Empty; + var operationXmlDocsNodes = GetResponseXmlDocsNodes(operationProcessorContext.MethodInfo); if (!string.IsNullOrEmpty(returnParameterXmlDocs) || operationXmlDocsNodes?.Any() == true) { @@ -69,10 +68,7 @@ protected void UpdateResponseDescription(OperationProcessorContext operationProc if (string.IsNullOrEmpty(response.Value.Description)) { // Support for Order created tags - var responseXmlDocs = operationXmlDocsNodes?.SingleOrDefault(n => - n.Name == "response" && - n.Attributes().Any(a => a.Name == "code" && a.Value == response.Key))?.Value; - + var responseXmlDocs = GetResponseXmlDocsElement(operationProcessorContext.MethodInfo, response.Key)?.Value; if (!string.IsNullOrEmpty(responseXmlDocs)) { response.Value.Description = responseXmlDocs; @@ -86,6 +82,22 @@ protected void UpdateResponseDescription(OperationProcessorContext operationProc } } + /// Gets the XML documentation element for the given response code or null. + /// The method info. + /// The response code. + /// The XML element or null. + protected XElement GetResponseXmlDocsElement(MethodInfo methodInfo, string responseCode) + { + var operationXmlDocsNodes = GetResponseXmlDocsNodes(methodInfo); + return operationXmlDocsNodes?.SingleOrDefault(n => n.Name == "response" && n.Attributes().Any(a => a.Name == "code" && a.Value == responseCode)); + } + + private IEnumerable GetResponseXmlDocsNodes(MethodInfo methodInfo) + { + var operationXmlDocs = methodInfo.GetXmlDocsElement(); + return operationXmlDocs?.Nodes()?.OfType(); + } + private IEnumerable GetOperationResponseDescriptions(IEnumerable responseTypeAttributes, string successResponseDescription) { foreach (var attribute in responseTypeAttributes) @@ -165,12 +177,18 @@ private void ProcessOperationDescriptions(IEnumerable r.IsNullable) && typeDescription.IsNullable; - - response.IsNullableRaw = isNullable; response.ExpectedSchemas = GenerateExpectedSchemas(statusCodeGroup, context); - response.Schema = context.SchemaGenerator - .GenerateWithReferenceAndNullability(contextualReturnType, isNullable, context.SchemaResolver); + + var nullableXmlAttribute = GetResponseXmlDocsElement(context.MethodInfo, httpStatusCode)?.Attribute("nullable"); + + var isResponseNullable = nullableXmlAttribute != null ? + nullableXmlAttribute.Value.ToLowerInvariant() == "true" : + statusCodeGroup.Any(r => r.IsNullable) && + _settings.ReflectionService.GetDescription(contextualReturnType, _settings.DefaultResponseReferenceTypeNullHandling, _settings).IsNullable; + + response.IsNullableRaw = isResponseNullable; + response.Schema = context.SchemaGenerator.GenerateWithReferenceAndNullability( + contextualReturnType, isResponseNullable, context.SchemaResolver); } context.OperationDescription.Operation.Responses[httpStatusCode] = response; diff --git a/src/NSwag.Integration.ClientPCL/swagger.json b/src/NSwag.Integration.ClientPCL/swagger.json index fac8c76da0..ca8e1c807b 100644 --- a/src/NSwag.Integration.ClientPCL/swagger.json +++ b/src/NSwag.Integration.ClientPCL/swagger.json @@ -243,7 +243,7 @@ "description": "" }, "450": { - "x-nullable": true, + "x-nullable": false, "description": "A custom error occured.", "schema": { "$ref": "#/definitions/Exception" @@ -445,7 +445,7 @@ ], "responses": { "500": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/PersonNotFoundException" @@ -528,14 +528,14 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/Person" } }, "500": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/PersonNotFoundException" @@ -564,14 +564,14 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "The person's name.", "schema": { "type": "string" } }, "500": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/PersonNotFoundException" diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngular.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngular.ts index e69fcb6bc8..50e457ae00 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngular.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngular.ts @@ -493,7 +493,7 @@ export class GeoClient extends MyBaseClass { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { let result450: any = null; let resultData450 = _responseText === "" ? null : jsonParse(_responseText, this.jsonParseReviver); - result450 = resultData450 ? Exception.fromJS(resultData450, _mappings) : null; + result450 = resultData450 ? Exception.fromJS(resultData450, _mappings) : new Exception(); return throwException("A server error occurred.", status, _responseText, _headers, result450); })); } else if (status !== 200 && status !== 204) { @@ -889,7 +889,7 @@ export class PersonsClient extends MyBaseClass { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { let result500: any = null; let resultData500 = _responseText === "" ? null : jsonParse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500, _mappings) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500, _mappings) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); })); } else if (status === 200) { @@ -1011,7 +1011,7 @@ export class PersonsClient extends MyBaseClass { return _observableOf(null); } - throw(id: string): Observable { + throw(id: string): Observable { let url_ = this.baseUrl + "/api/Persons/Throw?"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined and cannot be null."); @@ -1036,14 +1036,14 @@ export class PersonsClient extends MyBaseClass { try { return this.transformResult(url_, response_, (r) => this.processThrow(r)); } catch (e) { - return >_observableThrow(e); + return >_observableThrow(e); } } else - return >_observableThrow(response_); + return >_observableThrow(response_); })); } - protected processThrow(response: HttpResponseBase): Observable { + protected processThrow(response: HttpResponseBase): Observable { const status = response.status; const responseBlob = response instanceof HttpResponse ? response.body : @@ -1055,14 +1055,14 @@ export class PersonsClient extends MyBaseClass { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { let result200: any = null; let resultData200 = _responseText === "" ? null : jsonParse(_responseText, this.jsonParseReviver); - result200 = resultData200 ? Person.fromJS(resultData200, _mappings) : null; + result200 = resultData200 ? Person.fromJS(resultData200, _mappings) : new Person(); return _observableOf(result200); })); } else if (status === 500) { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { let result500: any = null; let resultData500 = _responseText === "" ? null : jsonParse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500, _mappings) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500, _mappings) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); })); } else if (status !== 200 && status !== 204) { @@ -1070,7 +1070,7 @@ export class PersonsClient extends MyBaseClass { return throwException("An unexpected server error occurred.", status, _responseText, _headers); })); } - return _observableOf(null); + return _observableOf(null); } /** @@ -1078,7 +1078,7 @@ export class PersonsClient extends MyBaseClass { * @param id The person ID. * @return The person's name. */ - getName(id: string): Observable { + getName(id: string): Observable { let url_ = this.baseUrl + "/api/Persons/{id}/Name"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); @@ -1102,14 +1102,14 @@ export class PersonsClient extends MyBaseClass { try { return this.transformResult(url_, response_, (r) => this.processGetName(r)); } catch (e) { - return >_observableThrow(e); + return >_observableThrow(e); } } else - return >_observableThrow(response_); + return >_observableThrow(response_); })); } - protected processGetName(response: HttpResponseBase): Observable { + protected processGetName(response: HttpResponseBase): Observable { const status = response.status; const responseBlob = response instanceof HttpResponse ? response.body : @@ -1128,7 +1128,7 @@ export class PersonsClient extends MyBaseClass { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { let result500: any = null; let resultData500 = _responseText === "" ? null : jsonParse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500, _mappings) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500, _mappings) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); })); } else if (status !== 200 && status !== 204) { @@ -1136,7 +1136,7 @@ export class PersonsClient extends MyBaseClass { return throwException("An unexpected server error occurred.", status, _responseText, _headers); })); } - return _observableOf(null); + return _observableOf(null); } addXml(person: string | null): Observable { diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngularJS.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngularJS.ts index 30922bb46e..3a4807d545 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngularJS.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAngularJS.ts @@ -379,7 +379,7 @@ export class GeoClient { const _responseText = response.data; let result450: any = null; let resultData450 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result450 = resultData450 ? Exception.fromJS(resultData450) : null; + result450 = resultData450 ? Exception.fromJS(resultData450) : new Exception(); return throwException(this.q, "A server error occurred.", status, _responseText, _headers, result450); } else if (status !== 200 && status !== 204) { const _responseText = response.data; @@ -697,7 +697,7 @@ export class PersonsClient { const _responseText = response.data; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException(this.q, "A server error occurred.", status, _responseText, _headers, result500); } else if (status === 200) { const _responseText = response.data; @@ -793,7 +793,7 @@ export class PersonsClient { return this.q.resolve(null); } - throw(id: string): ng.IPromise { + throw(id: string): ng.IPromise { let url_ = this.baseUrl + "/api/Persons/Throw?"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined and cannot be null."); @@ -819,7 +819,7 @@ export class PersonsClient { }); } - protected processThrow(response: any): ng.IPromise { + protected processThrow(response: any): ng.IPromise { const status = response.status; let _headers: any = {}; @@ -827,19 +827,19 @@ export class PersonsClient { const _responseText = response.data; let result200: any = null; let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 ? Person.fromJS(resultData200) : null; + result200 = resultData200 ? Person.fromJS(resultData200) : new Person(); return this.q.resolve(result200); } else if (status === 500) { const _responseText = response.data; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException(this.q, "A server error occurred.", status, _responseText, _headers, result500); } else if (status !== 200 && status !== 204) { const _responseText = response.data; return throwException(this.q, "An unexpected server error occurred.", status, _responseText, _headers); } - return this.q.resolve(null); + return this.q.resolve(null); } /** @@ -847,7 +847,7 @@ export class PersonsClient { * @param id The person ID. * @return The person's name. */ - getName(id: string): ng.IPromise { + getName(id: string): ng.IPromise { let url_ = this.baseUrl + "/api/Persons/{id}/Name"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); @@ -872,7 +872,7 @@ export class PersonsClient { }); } - protected processGetName(response: any): ng.IPromise { + protected processGetName(response: any): ng.IPromise { const status = response.status; let _headers: any = {}; @@ -886,13 +886,13 @@ export class PersonsClient { const _responseText = response.data; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException(this.q, "A server error occurred.", status, _responseText, _headers, result500); } else if (status !== 200 && status !== 204) { const _responseText = response.data; return throwException(this.q, "An unexpected server error occurred.", status, _responseText, _headers); } - return this.q.resolve(null); + return this.q.resolve(null); } addXml(person: string | null): ng.IPromise { diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAurelia.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAurelia.ts index a56f6073cb..c3e49c4171 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAurelia.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsAurelia.ts @@ -333,7 +333,7 @@ export class GeoClient { return response.text().then((_responseText) => { let result450: any = null; let resultData450 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result450 = resultData450 ? Exception.fromJS(resultData450) : null; + result450 = resultData450 ? Exception.fromJS(resultData450) : new Exception(); return throwException("A server error occurred.", status, _responseText, _headers, result450); }); } else if (status !== 200 && status !== 204) { @@ -612,7 +612,7 @@ export class PersonsClient { return response.text().then((_responseText) => { let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); }); } else if (status === 200) { @@ -701,7 +701,7 @@ export class PersonsClient { return Promise.resolve(null); } - throw(id: string): Promise { + throw(id: string): Promise { let url_ = this.baseUrl + "/api/Persons/Throw?"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined and cannot be null."); @@ -721,21 +721,21 @@ export class PersonsClient { }); } - protected processThrow(response: Response): Promise { + protected processThrow(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 ? Person.fromJS(resultData200) : null; + result200 = resultData200 ? Person.fromJS(resultData200) : new Person(); return result200; }); } else if (status === 500) { return response.text().then((_responseText) => { let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); }); } else if (status !== 200 && status !== 204) { @@ -743,7 +743,7 @@ export class PersonsClient { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } - return Promise.resolve(null); + return Promise.resolve(null); } /** @@ -751,7 +751,7 @@ export class PersonsClient { * @param id The person ID. * @return The person's name. */ - getName(id: string): Promise { + getName(id: string): Promise { let url_ = this.baseUrl + "/api/Persons/{id}/Name"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); @@ -770,7 +770,7 @@ export class PersonsClient { }); } - protected processGetName(response: Response): Promise { + protected processGetName(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { @@ -784,7 +784,7 @@ export class PersonsClient { return response.text().then((_responseText) => { let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); }); } else if (status !== 200 && status !== 204) { @@ -792,7 +792,7 @@ export class PersonsClient { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } - return Promise.resolve(null); + return Promise.resolve(null); } addXml(person: string | null): Promise { diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsFetch.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsFetch.ts index 0c70760a9b..a6c1cafa12 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsFetch.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsFetch.ts @@ -329,7 +329,7 @@ export class GeoClient { return response.text().then((_responseText) => { let result450: any = null; let resultData450 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result450 = resultData450 ? Exception.fromJS(resultData450) : null; + result450 = resultData450 ? Exception.fromJS(resultData450) : new Exception(); return throwException("A server error occurred.", status, _responseText, _headers, result450); }); } else if (status !== 200 && status !== 204) { @@ -607,7 +607,7 @@ export class PersonsClient { return response.text().then((_responseText) => { let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); }); } else if (status === 200) { @@ -696,7 +696,7 @@ export class PersonsClient { return Promise.resolve(null); } - throw(id: string): Promise { + throw(id: string): Promise { let url_ = this.baseUrl + "/api/Persons/Throw?"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined and cannot be null."); @@ -716,21 +716,21 @@ export class PersonsClient { }); } - protected processThrow(response: Response): Promise { + protected processThrow(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { return response.text().then((_responseText) => { let result200: any = null; let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 ? Person.fromJS(resultData200) : null; + result200 = resultData200 ? Person.fromJS(resultData200) : new Person(); return result200; }); } else if (status === 500) { return response.text().then((_responseText) => { let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); }); } else if (status !== 200 && status !== 204) { @@ -738,7 +738,7 @@ export class PersonsClient { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } - return Promise.resolve(null); + return Promise.resolve(null); } /** @@ -746,7 +746,7 @@ export class PersonsClient { * @param id The person ID. * @return The person's name. */ - getName(id: string): Promise { + getName(id: string): Promise { let url_ = this.baseUrl + "/api/Persons/{id}/Name"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); @@ -765,7 +765,7 @@ export class PersonsClient { }); } - protected processGetName(response: Response): Promise { + protected processGetName(response: Response): Promise { const status = response.status; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; if (status === 200) { @@ -779,7 +779,7 @@ export class PersonsClient { return response.text().then((_responseText) => { let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); }); } else if (status !== 200 && status !== 204) { @@ -787,7 +787,7 @@ export class PersonsClient { return throwException("An unexpected server error occurred.", status, _responseText, _headers); }); } - return Promise.resolve(null); + return Promise.resolve(null); } addXml(person: string | null): Promise { diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryCallbacks.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryCallbacks.ts index a849cede7b..8496d7a41e 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryCallbacks.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryCallbacks.ts @@ -486,7 +486,7 @@ export class GeoClient { const _responseText = xhr.responseText; let result450: any = null; let resultData450 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result450 = resultData450 ? Exception.fromJS(resultData450) : null; + result450 = resultData450 ? Exception.fromJS(resultData450) : new Exception(); return throwException("A server error occurred.", status, _responseText, _headers, result450); } else if (status !== 200 && status !== 204) { const _responseText = xhr.responseText; @@ -884,7 +884,7 @@ export class PersonsClient { const _responseText = xhr.responseText; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); } else if (status === 200) { const _responseText = xhr.responseText; @@ -1004,7 +1004,7 @@ export class PersonsClient { return null; } - throw(id: string, onSuccess?: (result: Person | null) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void): JQueryXHR { + throw(id: string, onSuccess?: (result: Person) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void): JQueryXHR { let url_ = this.baseUrl + "/api/Persons/Throw?"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined and cannot be null."); @@ -1042,7 +1042,7 @@ export class PersonsClient { } } - protected processThrow(xhr: any): Person | null | null { + protected processThrow(xhr: any): Person | null { const status = xhr.status; let _headers: any = {}; @@ -1050,13 +1050,13 @@ export class PersonsClient { const _responseText = xhr.responseText; let result200: any = null; let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 ? Person.fromJS(resultData200) : null; + result200 = resultData200 ? Person.fromJS(resultData200) : new Person(); return result200; } else if (status === 500) { const _responseText = xhr.responseText; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); } else if (status !== 200 && status !== 204) { const _responseText = xhr.responseText; @@ -1070,7 +1070,7 @@ export class PersonsClient { * @param id The person ID. * @return The person's name. */ - getName(id: string, onSuccess?: (result: string | null) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void): JQueryXHR { + getName(id: string, onSuccess?: (result: string) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void): JQueryXHR { let url_ = this.baseUrl + "/api/Persons/{id}/Name"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); @@ -1107,7 +1107,7 @@ export class PersonsClient { } } - protected processGetName(xhr: any): string | null | null { + protected processGetName(xhr: any): string | null { const status = xhr.status; let _headers: any = {}; @@ -1121,7 +1121,7 @@ export class PersonsClient { const _responseText = xhr.responseText; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); } else if (status !== 200 && status !== 204) { const _responseText = xhr.responseText; diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromises.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromises.ts index 3fcbc0290c..cf6e679c72 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromises.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromises.ts @@ -504,7 +504,7 @@ export class GeoClient { const _responseText = xhr.responseText; let result450: any = null; let resultData450 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result450 = resultData450 ? Exception.fromJS(resultData450) : null; + result450 = resultData450 ? Exception.fromJS(resultData450) : new Exception(); return throwException("A server error occurred.", status, _responseText, _headers, result450); } else if (status !== 200 && status !== 204) { const _responseText = xhr.responseText; @@ -916,7 +916,7 @@ export class PersonsClient { const _responseText = xhr.responseText; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); } else if (status === 200) { const _responseText = xhr.responseText; @@ -1041,12 +1041,12 @@ export class PersonsClient { } throw(id: string) { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { this.throwWithCallbacks(id, (result) => resolve(result), (exception, _reason) => reject(exception)); }); } - private throwWithCallbacks(id: string, onSuccess?: (result: Person | null) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void) { + private throwWithCallbacks(id: string, onSuccess?: (result: Person) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void) { let url_ = this.baseUrl + "/api/Persons/Throw?"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined and cannot be null."); @@ -1080,7 +1080,7 @@ export class PersonsClient { } } - protected processThrow(xhr: any): Person | null | null { + protected processThrow(xhr: any): Person | null { const status = xhr.status; let _headers: any = {}; @@ -1088,13 +1088,13 @@ export class PersonsClient { const _responseText = xhr.responseText; let result200: any = null; let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 ? Person.fromJS(resultData200) : null; + result200 = resultData200 ? Person.fromJS(resultData200) : new Person(); return result200; } else if (status === 500) { const _responseText = xhr.responseText; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); } else if (status !== 200 && status !== 204) { const _responseText = xhr.responseText; @@ -1109,12 +1109,12 @@ export class PersonsClient { * @return The person's name. */ getName(id: string) { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { this.getNameWithCallbacks(id, (result) => resolve(result), (exception, _reason) => reject(exception)); }); } - private getNameWithCallbacks(id: string, onSuccess?: (result: string | null) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void) { + private getNameWithCallbacks(id: string, onSuccess?: (result: string) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void) { let url_ = this.baseUrl + "/api/Persons/{id}/Name"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); @@ -1147,7 +1147,7 @@ export class PersonsClient { } } - protected processGetName(xhr: any): string | null | null { + protected processGetName(xhr: any): string | null { const status = xhr.status; let _headers: any = {}; @@ -1161,7 +1161,7 @@ export class PersonsClient { const _responseText = xhr.responseText; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); } else if (status !== 200 && status !== 204) { const _responseText = xhr.responseText; diff --git a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromisesKO.ts b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromisesKO.ts index e9137916cf..507bc2428a 100644 --- a/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromisesKO.ts +++ b/src/NSwag.Integration.TypeScriptWeb/scripts/serviceClientsJQueryPromisesKO.ts @@ -506,7 +506,7 @@ export class GeoClient { const _responseText = xhr.responseText; let result450: any = null; let resultData450 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result450 = resultData450 ? Exception.fromJS(resultData450) : null; + result450 = resultData450 ? Exception.fromJS(resultData450) : new Exception(); return throwException("A server error occurred.", status, _responseText, _headers, result450); } else if (status !== 200 && status !== 204) { const _responseText = xhr.responseText; @@ -918,7 +918,7 @@ export class PersonsClient { const _responseText = xhr.responseText; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); } else if (status === 200) { const _responseText = xhr.responseText; @@ -1043,12 +1043,12 @@ export class PersonsClient { } throw(id: string) { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { this.throwWithCallbacks(id, (result) => resolve(result), (exception, _reason) => reject(exception)); }); } - private throwWithCallbacks(id: string, onSuccess?: (result: Person | null) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void) { + private throwWithCallbacks(id: string, onSuccess?: (result: Person) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void) { let url_ = this.baseUrl + "/api/Persons/Throw?"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined and cannot be null."); @@ -1082,7 +1082,7 @@ export class PersonsClient { } } - protected processThrow(xhr: any): Person | null | null { + protected processThrow(xhr: any): Person | null { const status = xhr.status; let _headers: any = {}; @@ -1090,13 +1090,13 @@ export class PersonsClient { const _responseText = xhr.responseText; let result200: any = null; let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 ? Person.fromJS(resultData200) : null; + result200 = resultData200 ? Person.fromJS(resultData200) : new Person(); return result200; } else if (status === 500) { const _responseText = xhr.responseText; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); } else if (status !== 200 && status !== 204) { const _responseText = xhr.responseText; @@ -1111,12 +1111,12 @@ export class PersonsClient { * @return The person's name. */ getName(id: string) { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { this.getNameWithCallbacks(id, (result) => resolve(result), (exception, _reason) => reject(exception)); }); } - private getNameWithCallbacks(id: string, onSuccess?: (result: string | null) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void) { + private getNameWithCallbacks(id: string, onSuccess?: (result: string) => void, onFail?: (exception: PersonNotFoundException | string, reason: string) => void) { let url_ = this.baseUrl + "/api/Persons/{id}/Name"; if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); @@ -1149,7 +1149,7 @@ export class PersonsClient { } } - protected processGetName(xhr: any): string | null | null { + protected processGetName(xhr: any): string | null { const status = xhr.status; let _headers: any = {}; @@ -1163,7 +1163,7 @@ export class PersonsClient { const _responseText = xhr.responseText; let result500: any = null; let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : null; + result500 = resultData500 ? PersonNotFoundException.fromJS(resultData500) : new PersonNotFoundException(); return throwException("A server error occurred.", status, _responseText, _headers, result500); } else if (status !== 200 && status !== 204) { const _responseText = xhr.responseText; diff --git a/src/NSwag.Integration.WebAPI/Swagger_Angular.nswag b/src/NSwag.Integration.WebAPI/Swagger_Angular.nswag index 711e596e94..8b88a6b0bf 100644 --- a/src/NSwag.Integration.WebAPI/Swagger_Angular.nswag +++ b/src/NSwag.Integration.WebAPI/Swagger_Angular.nswag @@ -14,7 +14,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Integration.WebAPI/Swagger_AngularJS.nswag b/src/NSwag.Integration.WebAPI/Swagger_AngularJS.nswag index 5f6d51d35d..61e10d1208 100644 --- a/src/NSwag.Integration.WebAPI/Swagger_AngularJS.nswag +++ b/src/NSwag.Integration.WebAPI/Swagger_AngularJS.nswag @@ -14,7 +14,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Integration.WebAPI/Swagger_Aurelia.nswag b/src/NSwag.Integration.WebAPI/Swagger_Aurelia.nswag index 5596f135b3..d79b14f826 100644 --- a/src/NSwag.Integration.WebAPI/Swagger_Aurelia.nswag +++ b/src/NSwag.Integration.WebAPI/Swagger_Aurelia.nswag @@ -14,7 +14,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Integration.WebAPI/Swagger_ClientConsole.nswag b/src/NSwag.Integration.WebAPI/Swagger_ClientConsole.nswag index 4778896d99..c04278dff1 100644 --- a/src/NSwag.Integration.WebAPI/Swagger_ClientConsole.nswag +++ b/src/NSwag.Integration.WebAPI/Swagger_ClientConsole.nswag @@ -14,7 +14,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Integration.WebAPI/Swagger_ClientPCL.nswag b/src/NSwag.Integration.WebAPI/Swagger_ClientPCL.nswag index 878168d66e..04a594bb3c 100644 --- a/src/NSwag.Integration.WebAPI/Swagger_ClientPCL.nswag +++ b/src/NSwag.Integration.WebAPI/Swagger_ClientPCL.nswag @@ -14,7 +14,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Integration.WebAPI/Swagger_Fetch.nswag b/src/NSwag.Integration.WebAPI/Swagger_Fetch.nswag index e991c1e155..336a388d41 100644 --- a/src/NSwag.Integration.WebAPI/Swagger_Fetch.nswag +++ b/src/NSwag.Integration.WebAPI/Swagger_Fetch.nswag @@ -14,7 +14,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Integration.WebAPI/Swagger_JQueryCallbacks.nswag b/src/NSwag.Integration.WebAPI/Swagger_JQueryCallbacks.nswag index c75a711039..4248fc68b0 100644 --- a/src/NSwag.Integration.WebAPI/Swagger_JQueryCallbacks.nswag +++ b/src/NSwag.Integration.WebAPI/Swagger_JQueryCallbacks.nswag @@ -14,7 +14,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Integration.WebAPI/Swagger_JQueryPromises.nswag b/src/NSwag.Integration.WebAPI/Swagger_JQueryPromises.nswag index 3cb47e3ea3..8f56747258 100644 --- a/src/NSwag.Integration.WebAPI/Swagger_JQueryPromises.nswag +++ b/src/NSwag.Integration.WebAPI/Swagger_JQueryPromises.nswag @@ -14,7 +14,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Integration.WebAPI/Swagger_JQueryPromises_KO.nswag b/src/NSwag.Integration.WebAPI/Swagger_JQueryPromises_KO.nswag index 828c3f3cf7..9a88685faa 100644 --- a/src/NSwag.Integration.WebAPI/Swagger_JQueryPromises_KO.nswag +++ b/src/NSwag.Integration.WebAPI/Swagger_JQueryPromises_KO.nswag @@ -14,7 +14,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Sample.NETCore11/nswag.json b/src/NSwag.Sample.NETCore11/nswag.json index a8b0c5e6f2..7d645081e5 100644 --- a/src/NSwag.Sample.NETCore11/nswag.json +++ b/src/NSwag.Sample.NETCore11/nswag.json @@ -11,7 +11,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "CamelCase", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Sample.NETCore11/swagger.json b/src/NSwag.Sample.NETCore11/swagger.json index b7254dd1f7..0204eda3c2 100644 --- a/src/NSwag.Sample.NETCore11/swagger.json +++ b/src/NSwag.Sample.NETCore11/swagger.json @@ -34,7 +34,7 @@ ], "responses": { "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -63,7 +63,7 @@ ], "responses": { "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -92,7 +92,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -102,7 +102,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -147,7 +147,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -157,7 +157,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -183,7 +183,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -193,7 +193,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -220,14 +220,14 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/Pet" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -267,7 +267,7 @@ ], "responses": { "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -295,7 +295,7 @@ ], "responses": { "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -335,14 +335,14 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ApiResponse" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" diff --git a/src/NSwag.Sample.NETCore20/nswag.json b/src/NSwag.Sample.NETCore20/nswag.json index f2c2cf577e..43df9c142e 100644 --- a/src/NSwag.Sample.NETCore20/nswag.json +++ b/src/NSwag.Sample.NETCore20/nswag.json @@ -15,7 +15,7 @@ "apiGroupNames": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Sample.NETCore20/swagger.json b/src/NSwag.Sample.NETCore20/swagger.json index 50dc846778..f46499e8b6 100644 --- a/src/NSwag.Sample.NETCore20/swagger.json +++ b/src/NSwag.Sample.NETCore20/swagger.json @@ -31,7 +31,7 @@ ], "responses": { "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -68,7 +68,7 @@ ], "responses": { "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -105,7 +105,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -115,7 +115,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -168,7 +168,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -178,7 +178,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -211,7 +211,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -221,7 +221,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -256,14 +256,14 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/Pet" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -368,7 +368,7 @@ ], "responses": { "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -404,7 +404,7 @@ ], "responses": { "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -451,14 +451,14 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ApiResponse" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -564,7 +564,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "string" diff --git a/src/NSwag.Sample.NETCore21/nswag_assembly.nswag b/src/NSwag.Sample.NETCore21/nswag_assembly.nswag index 59bdac2746..3e348e7642 100644 --- a/src/NSwag.Sample.NETCore21/nswag_assembly.nswag +++ b/src/NSwag.Sample.NETCore21/nswag_assembly.nswag @@ -15,7 +15,7 @@ "apiGroupNames": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Sample.NETCore21/nswag_project.nswag b/src/NSwag.Sample.NETCore21/nswag_project.nswag index eceeda4445..cfd575a0e8 100644 --- a/src/NSwag.Sample.NETCore21/nswag_project.nswag +++ b/src/NSwag.Sample.NETCore21/nswag_project.nswag @@ -15,7 +15,7 @@ "apiGroupNames": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Sample.NETCore21/swagger_assembly_cli.json b/src/NSwag.Sample.NETCore21/swagger_assembly_cli.json index 7977797c1e..0105d56de0 100644 --- a/src/NSwag.Sample.NETCore21/swagger_assembly_cli.json +++ b/src/NSwag.Sample.NETCore21/swagger_assembly_cli.json @@ -28,7 +28,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "Order invalid", "schema": { "type": "object", @@ -68,7 +68,7 @@ "description": "My success response description." }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -103,7 +103,7 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -136,7 +136,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -168,7 +168,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -178,7 +178,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -208,14 +208,14 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/Pet" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -327,7 +327,7 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -361,7 +361,7 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -404,14 +404,14 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ApiResponse" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" diff --git a/src/NSwag.Sample.NETCore21/swagger_project_cli.json b/src/NSwag.Sample.NETCore21/swagger_project_cli.json index 474c15926e..3c8d99ebe5 100644 --- a/src/NSwag.Sample.NETCore21/swagger_project_cli.json +++ b/src/NSwag.Sample.NETCore21/swagger_project_cli.json @@ -28,7 +28,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "Order invalid", "schema": { "type": "object", @@ -68,7 +68,7 @@ "description": "My success response description." }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -103,7 +103,7 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -136,7 +136,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -168,7 +168,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -178,7 +178,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -208,14 +208,14 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/Pet" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -327,7 +327,7 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -361,7 +361,7 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -404,14 +404,14 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ApiResponse" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" diff --git a/src/NSwag.Sample.NETCore22/nswag_assembly.nswag b/src/NSwag.Sample.NETCore22/nswag_assembly.nswag index ea77fd1fd6..94ca9f1f17 100644 --- a/src/NSwag.Sample.NETCore22/nswag_assembly.nswag +++ b/src/NSwag.Sample.NETCore22/nswag_assembly.nswag @@ -15,7 +15,7 @@ "apiGroupNames": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Sample.NETCore22/nswag_oas_project.nswag b/src/NSwag.Sample.NETCore22/nswag_oas_project.nswag index f217e3c82c..8dde1e4cf1 100644 --- a/src/NSwag.Sample.NETCore22/nswag_oas_project.nswag +++ b/src/NSwag.Sample.NETCore22/nswag_oas_project.nswag @@ -15,7 +15,7 @@ "apiGroupNames": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Sample.NETCore22/nswag_project.nswag b/src/NSwag.Sample.NETCore22/nswag_project.nswag index 470bfd53d3..1a53634cca 100644 --- a/src/NSwag.Sample.NETCore22/nswag_project.nswag +++ b/src/NSwag.Sample.NETCore22/nswag_project.nswag @@ -15,7 +15,7 @@ "apiGroupNames": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true, diff --git a/src/NSwag.Sample.NETCore22/openapi_project_cli.json b/src/NSwag.Sample.NETCore22/openapi_project_cli.json index b2b73bc015..6dd7ea6cd8 100644 --- a/src/NSwag.Sample.NETCore22/openapi_project_cli.json +++ b/src/NSwag.Sample.NETCore22/openapi_project_cli.json @@ -33,12 +33,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/SerializableError" - } - ] + "$ref": "#/components/schemas/SerializableError" } } } @@ -71,12 +66,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/SerializableError" - } - ] + "$ref": "#/components/schemas/SerializableError" } } } @@ -112,7 +102,6 @@ "application/json": { "schema": { "type": "array", - "nullable": true, "items": { "$ref": "#/components/schemas/Pet" } @@ -149,7 +138,6 @@ "application/json": { "schema": { "type": "array", - "nullable": true, "items": { "$ref": "#/components/schemas/Pet" } @@ -162,12 +150,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/SerializableError" - } - ] + "$ref": "#/components/schemas/SerializableError" } } } @@ -199,12 +182,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/Pet" - } - ] + "$ref": "#/components/schemas/Pet" } } } @@ -214,12 +192,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/SerializableError" - } - ] + "$ref": "#/components/schemas/SerializableError" } } } @@ -229,12 +202,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/ProblemDetails" - } - ] + "$ref": "#/components/schemas/ProblemDetails" } } } @@ -361,12 +329,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/SerializableError" - } - ] + "$ref": "#/components/schemas/SerializableError" } } } @@ -376,12 +339,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/ProblemDetails" - } - ] + "$ref": "#/components/schemas/ProblemDetails" } } } @@ -414,12 +372,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/SerializableError" - } - ] + "$ref": "#/components/schemas/SerializableError" } } } @@ -429,12 +382,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/ProblemDetails" - } - ] + "$ref": "#/components/schemas/ProblemDetails" } } } @@ -477,12 +425,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/ApiResponse" - } - ] + "$ref": "#/components/schemas/ApiResponse" } } } @@ -492,12 +435,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/SerializableError" - } - ] + "$ref": "#/components/schemas/SerializableError" } } } @@ -507,12 +445,7 @@ "content": { "application/json": { "schema": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/ProblemDetails" - } - ] + "$ref": "#/components/schemas/ProblemDetails" } } } diff --git a/src/NSwag.Sample.NETCore22/swagger_assembly_cli.json b/src/NSwag.Sample.NETCore22/swagger_assembly_cli.json index 74a74e69de..61b9f62208 100644 --- a/src/NSwag.Sample.NETCore22/swagger_assembly_cli.json +++ b/src/NSwag.Sample.NETCore22/swagger_assembly_cli.json @@ -36,7 +36,7 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -70,7 +70,7 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -107,7 +107,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -137,7 +137,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -147,7 +147,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -174,21 +174,21 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/Pet" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" } }, "404": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ProblemDetails" @@ -296,14 +296,14 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" } }, "404": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ProblemDetails" @@ -331,14 +331,14 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" } }, "404": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ProblemDetails" @@ -375,21 +375,21 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ApiResponse" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" } }, "404": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ProblemDetails" diff --git a/src/NSwag.Sample.NETCore22/swagger_project_cli.json b/src/NSwag.Sample.NETCore22/swagger_project_cli.json index 01d377e05c..33c05285b3 100644 --- a/src/NSwag.Sample.NETCore22/swagger_project_cli.json +++ b/src/NSwag.Sample.NETCore22/swagger_project_cli.json @@ -36,7 +36,7 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -70,7 +70,7 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -107,7 +107,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -137,7 +137,7 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "type": "array", @@ -147,7 +147,7 @@ } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" @@ -174,21 +174,21 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/Pet" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" } }, "404": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ProblemDetails" @@ -296,14 +296,14 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" } }, "404": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ProblemDetails" @@ -331,14 +331,14 @@ "description": "" }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" } }, "404": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ProblemDetails" @@ -375,21 +375,21 @@ ], "responses": { "200": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ApiResponse" } }, "400": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/SerializableError" } }, "404": { - "x-nullable": true, + "x-nullable": false, "description": "", "schema": { "$ref": "#/definitions/ProblemDetails" diff --git a/src/NSwag.Sample.NetGlobalAsax/nswag.json b/src/NSwag.Sample.NetGlobalAsax/nswag.json index 6140fd4eeb..c1afea00a9 100644 --- a/src/NSwag.Sample.NetGlobalAsax/nswag.json +++ b/src/NSwag.Sample.NetGlobalAsax/nswag.json @@ -13,7 +13,7 @@ "includedVersions": null, "defaultPropertyNameHandling": "Default", "defaultReferenceTypeNullHandling": "Null", - "defaultResponseReferenceTypeNullHandling": "Null", + "defaultResponseReferenceTypeNullHandling": "NotNull", "defaultEnumHandling": "Integer", "flattenInheritanceHierarchy": false, "generateKnownTypes": true,