Skip to content

Csharp Net Standard

Sandor edited this page Aug 16, 2017 · 5 revisions

We provide netstandard 1.3 templates out of the box.

Features

We support client generated using this template on all the .net runtimes supported by .netstandard 1.3. It means that generated client supports .Net 452, .Net462 and NetCoreApps but also Xamarin.Ios and Xamarin.Android apps.

  • DTO classes generation
  • Supports for CancellationToken on operations
  • Supports for dependency injection
  • Uses an HttpClientFactory : which means underlying default HttpMessageHandler can be replaced by your own to do various things such as providing mocks, logging or using native message handlers on Xamarin.Ios and Xamarin.Android.
  • Support for Polly Policies : with this you can easily add retry policies and advanced error handling/retry policies without crippling your code.
  • Type mapping : Type from swagger schema can be remapped to type provided by a library (e.g. JsonPatch)

Modes

This template support three different modes

project-msbuild mode

This template generates a new msbuild based dotnet core project.

project mode

This template generates a project.json based dotnet core project. This mode will be deprecated, as project.json won't be supported by Microsoft.

This mode requires an additional mandatory option:

  • projectGuid: a guid for the xproj project

Options

 "templateOptions": {
                "clientName": "myClient",
                "rootNamespace": "My.Client.Namespace",
                "operation": {
                    "onError": {
                        "useOkSchema": true
                    }
                }
            }
  • clientName: The name of the generated file and of the generated class.
  • rootNamespace: RootNamespace also used as the package id.
  • operation/onError/useOKSchema: tells the generator that the same schema is used on errors (even if the schema has no error schema specified)