Nswag: Nswag Log File and Typescript Generator

Created on 9 Feb 2017  路  4Comments  路  Source: RicoSuter/NSwag

Is there anyway to access a NSWAG Studio Log File? Because I am using this options http://imgur.com/a/be80L to generate my typescript but via command line I do not know how to do it. Is there anyway to know how to do it? Because the typescript generator via command line that you give is to basic and it generate the default content.

question

All 4 comments

Just save the .nswag file from NSwagStudio then run

nswag run myconfig.nswag

Otherwise you can run

nswag help

To see all available options and settings

many thanks but there is a problem with that solution, if I use the myconfig.swag file, if I edit my api to add a new controller I will need to create a new nswag file all over again since or edit the file manually :/

swagger specification:

{
  "swaggerGenerator": {
    "webApiToSwagger": {
      "assemblyPaths": [
        "AppBackend/AppBackend/bin/AppBackend.dll"
      ],
      "referencePaths": [],
      "isAspNetCore": false,
      "controllerNames": [
        "AppBackend.Controllers.AuthController",
        "AppBackend.Controllers.LessorController",
        "AppBackend.Controllers.UserController"
      ],
      "defaultUrlTemplate": "api/{controller}/{id}",
      "defaultPropertyNameHandling": "Default",
      "defaultEnumHandling": "Integer",
      "flattenInheritanceHierarchy": false,
      "generateKnownTypes": true,
      "generateXmlObjects": false,
      "addMissingPathParameters": false,
      "infoTitle": "Web API Swagger specification",
      "infoVersion": "1.0.0",
      "output": null
    }
  },
  "codeGenerators": {
    "swaggerToTypeScriptClient": {
      "className": "{controller}Client",
      "moduleName": "",
      "namespace": "",
      "typeScriptVersion": 1.8,
      "template": "AngularJS",
      "promiseType": "Promise",
      "dateTimeType": "Date",
      "generateClientClasses": true,
      "generateClientInterfaces": true,
      "wrapDtoExceptions": false,
      "useTransformOptionsMethod": false,
      "useTransformResultMethod": false,
      "generateDtoTypes": true,
      "operationGenerationMode": "MultipleClientsFromOperationId",
      "markOptionalProperties": true,
      "typeStyle": "Interface",
      "generateDefaultValues": true,
      "excludedTypeNames": [],
      "output": "RenterLogApiBackendClient.ts"
    },
    "swaggerToCSharpClient": {
      "exceptionClass": "SwaggerException",
      "generateClientClasses": true,
      "generateClientInterfaces": false,
      "generateDtoTypes": true,
      "injectHttpClient": false,
      "wrapSuccessResponses": false,
      "useHttpClientCreationMethod": false,
      "useHttpRequestMessageCreationMethod": false,
      "generateExceptionClasses": true,
      "generateContractsOutput": false,
      "className": "{controller}Client",
      "namespace": "MyNamespace",
      "requiredPropertiesMustBeDefined": true,
      "dateType": "System.DateTime",
      "dateTimeType": "System.DateTime",
      "timeType": "System.TimeSpan",
      "timeSpanType": "System.TimeSpan",
      "arrayType": "System.Collections.ObjectModel.ObservableCollection",
      "dictionaryType": "System.Collections.Generic.Dictionary",
      "classStyle": "Inpc",
      "operationGenerationMode": "MultipleClientsFromOperationId",
      "generateDefaultValues": true,
      "excludedTypeNames": [],
      "output": null
    },
    "swaggerToCSharpController": {
      "className": "{controller}",
      "namespace": "MyNamespace",
      "additionalNamespaceUsages": [
        "System.Web.Http"
      ],
      "requiredPropertiesMustBeDefined": true,
      "dateType": "System.DateTime",
      "dateTimeType": "System.DateTime",
      "timeType": "System.TimeSpan",
      "timeSpanType": "System.TimeSpan",
      "arrayType": "System.Collections.Generic.IEnumerable",
      "dictionaryType": "System.Collections.Generic.Dictionary",
      "classStyle": "Inpc",
      "operationGenerationMode": "MultipleClientsFromOperationId",
      "generateDefaultValues": true,
      "excludedTypeNames": [],
      "output": null
    }
  }
}

You can use * in the file:

  "controllerNames": [
    "AppBackend.Controllers.*"
  ],

but this will not work with the UI

Was this page helpful?
0 / 5 - 0 ratings