diff --git a/src/node-swagger-generator/lib/generation.ts b/src/node-swagger-generator/lib/generation.ts index f0b9b7e..6705cc7 100644 --- a/src/node-swagger-generator/lib/generation.ts +++ b/src/node-swagger-generator/lib/generation.ts @@ -11,7 +11,7 @@ import { IAbstractedType, IType, ITyped, IImportedType, IDefinition, IProperty, IAbstractedTypeConverter, - SchemaLessAbstractedType, ArrayAbstractedType, BuiltinAbstractedType, CustomAbstractedType, FileAbstractedType, MapAbstractedType, GenericAbstractedType, ImportedAbstractedType + VoidAbstractedType, SchemaLessAbstractedType, ArrayAbstractedType, BuiltinAbstractedType, CustomAbstractedType, FileAbstractedType, MapAbstractedType, GenericAbstractedType, ImportedAbstractedType } from './typing'; //import servicesVersion = ts.servicesVersion; @@ -681,6 +681,9 @@ class GenericTypeConverter implements IAbstractedTypeConverter{ constructor(private contextBuilder: ContextBuilder) { } + voidTypeConvert(type: VoidAbstractedType): IAbstractedType { + return type; + } schemaLessTypeConvert(type: SchemaLessAbstractedType): IAbstractedType { return type; } diff --git a/src/node-swagger-generator/lib/languages/csharp.ts b/src/node-swagger-generator/lib/languages/csharp.ts index c23a12e..309ee10 100644 --- a/src/node-swagger-generator/lib/languages/csharp.ts +++ b/src/node-swagger-generator/lib/languages/csharp.ts @@ -4,7 +4,7 @@ import { IAbstractedType, IType, ITyped, IImportedType, IDefinition, IProperty, IAbstractedTypeConverter, - SchemaLessAbstractedType, ArrayAbstractedType, BuiltinAbstractedType, CustomAbstractedType, FileAbstractedType, MapAbstractedType, GenericAbstractedType, ImportedAbstractedType + VoidAbstractedType, SchemaLessAbstractedType, ArrayAbstractedType, BuiltinAbstractedType, CustomAbstractedType, FileAbstractedType, MapAbstractedType, GenericAbstractedType, ImportedAbstractedType } from '../typing'; import swagger = require('swagger-parser'); import _ = require('lodash'); @@ -35,6 +35,10 @@ class CSharpAbstractedTypeConverter implements IAbstractedTypeConverter { } + voidTypeConvert(type: VoidAbstractedType): CSharpType { + return CSharpType.void(); + } + schemaLessTypeConvert(type: SchemaLessAbstractedType): CSharpType { return CSharpType.any; } @@ -94,6 +98,7 @@ class CSharpType implements IType { isArray: boolean; itemType: CSharpType; isFile: boolean; + isVoid: boolean; isGeneric: boolean; genericArguments: CSharpType[]; isDictionary: boolean; @@ -124,6 +129,15 @@ class CSharpType implements IType { public static any: CSharpType = new CSharpType('object', null, true, false, false, false, false); public static file: CSharpType = new CSharpType('IFile', null, true, false, false, false, true); public static dateTimeOffset: CSharpType = new CSharpType('DateTimeOffset', null, true, false, false, false, false); + private static _void: CSharpType; + + public static void(){ + if (!CSharpType._void){ + CSharpType._void = new CSharpType('void', null, true, false, false, false, false); + CSharpType._void.isVoid = true; + } + return CSharpType._void; + } public static ambient(name: string, namespace: string): CSharpType { var type = new CSharpType(name.replace('<>', ""), null, true, false, false, false, false); diff --git a/src/node-swagger-generator/lib/languages/typescript.ts b/src/node-swagger-generator/lib/languages/typescript.ts index 736e1f9..d7109c3 100644 --- a/src/node-swagger-generator/lib/languages/typescript.ts +++ b/src/node-swagger-generator/lib/languages/typescript.ts @@ -4,7 +4,7 @@ import { IAbstractedType, IType, ITyped, IImportedType, IDefinition, IProperty, IAbstractedTypeConverter, - SchemaLessAbstractedType, ArrayAbstractedType, BuiltinAbstractedType, CustomAbstractedType, FileAbstractedType, MapAbstractedType, GenericAbstractedType, ImportedAbstractedType + VoidAbstractedType, SchemaLessAbstractedType, ArrayAbstractedType, BuiltinAbstractedType, CustomAbstractedType, FileAbstractedType, MapAbstractedType, GenericAbstractedType, ImportedAbstractedType } from '../typing'; import swagger = require('swagger-parser'); import _ = require('lodash'); @@ -35,6 +35,10 @@ class TypescriptAbstractedTypeConverter implements IAbstractedTypeConverter', ""), null, true, false, false, false, false); diff --git a/src/node-swagger-generator/lib/typing.ts b/src/node-swagger-generator/lib/typing.ts index c62b60a..6604606 100644 --- a/src/node-swagger-generator/lib/typing.ts +++ b/src/node-swagger-generator/lib/typing.ts @@ -16,6 +16,7 @@ export interface ITyped { } export interface IAbstractedTypeConverter { + voidTypeConvert(type: SchemaLessAbstractedType): T; schemaLessTypeConvert(type: SchemaLessAbstractedType): T; mapTypeConvert(type: MapAbstractedType): T; builtinTypeConvert(type: BuiltinAbstractedType): T; @@ -62,6 +63,12 @@ export interface IDefinition extends IExtensible { } +export class VoidAbstractedType implements IAbstractedType { + convert(converter: IAbstractedTypeConverter): T { + return converter.voidTypeConvert(this); + } +} + export class SchemaLessAbstractedType implements IAbstractedType { convert(converter: IAbstractedTypeConverter): T { return converter.schemaLessTypeConvert(this); diff --git a/src/node-swagger-generator/templates/csharp/netstandard/1.3/_task.hbs b/src/node-swagger-generator/templates/csharp/netstandard/1.3/_task.hbs new file mode 100644 index 0000000..39b3fe1 --- /dev/null +++ b/src/node-swagger-generator/templates/csharp/netstandard/1.3/_task.hbs @@ -0,0 +1,6 @@ +{{#if type.isVoid}} +Task +{{/if}} +{{#unless type.isVoid}} +Task<{{> type }}> +{{/unless}} \ No newline at end of file diff --git a/src/node-swagger-generator/templates/csharp/netstandard/1.3/client.hbs b/src/node-swagger-generator/templates/csharp/netstandard/1.3/client.hbs index 5f4df18..b042b68 100644 --- a/src/node-swagger-generator/templates/csharp/netstandard/1.3/client.hbs +++ b/src/node-swagger-generator/templates/csharp/netstandard/1.3/client.hbs @@ -65,7 +65,7 @@ namespace {{options.rootNamespace}} { }); {{/if}} - Func type successResponse.[0]}}>> executeRequest = async (ct) => + Func task successResponse.[0]}}> executeRequest = async (ct) => { var message = new HttpRequestMessage(); message.RequestUri = new Uri(uri, UriKind.Absolute); @@ -97,7 +97,9 @@ namespace {{options.rootNamespace}} { var response = await httpClient.SendAsync(message, ct); if (response.IsSuccessStatusCode){ - return await this.TransformResponseAsync<{{> type successResponse.[0]}}>(response); + {{#unless successResponse.[0].type.isVoid}} + return await this.TransformResponseAsync<{{> type successResponse.[0]}}>(response); + {{/unless}} } else { {{#if @root.options.operation.onError.useOKSchema}} throw await this.MapToException<{{> type successResponse.[0]}}>(response);