Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default settings #1719

Merged
merged 1 commit into from
Nov 6, 2018
Merged

Conversation

RicoSuter
Copy link
Owner

@RicoSuter RicoSuter commented Nov 6, 2018

Change setting defaults.

Remarks:

  • When using an nswag.json file, the old settings are retained and this is not a breaking change.
  • When using the CLI directly (e.g. swagger2csharp) then these defaults may be a breaking change

Command line/NSwagStudio:

  • Change default runtime to /runtime:NetCore20 or 2.1 (before: WinX64)

Swagger generator:

  • Change default of AllowNullableBodyParameters to false (breaking change)
    • Setting is ignored in ASP.NET Core 2.0+ anyway
  • Change default of AllowReferencesWithProperties to true?
    • Not needed in OpenAPI v3 anyway

TypeScript generator:

  • Change default of TypeScriptVersion to 2.7 (before: 1.8)
  • Set default of SwaggerToTypeScriptClientGeneratorSettings.HttpClass to HttpClient also RxJs to 6.0
  • Set default of SwaggerToTypeScriptClientGeneratorSettings.InjectionTokenType to InjectionToken

CSharp generator:

  • Set default of SwaggerToCSharpClientGeneratorSettings.InjectHttpClient to true
  • Use ClassStyle POCO instead of INPC for C# DTOs
  • New default C# generator type settings:
// Client/Controller parameter/response types

ResponseArrayType = "System.Collections.Generic.ICollection";
ResponseDictionaryType = "System.Collections.Generic.IDictionary";

ParameterArrayType = "System.Collections.Generic.IEnumerable";
ParameterDictionaryType = "System.Collections.Generic.IDictionary";

// DTO Properties

DateType = "System.DateTimeOffset";
DateTimeType = "System.DateTimeOffset";
TimeType = "System.TimeSpan";
TimeSpanType = "System.TimeSpan";

ArrayType = "System.Collections.Generic.ICollection";
DictionaryType = "System.Collections.Generic.IDictionary";

// DTO base types
ArrayBaseType = "System.Collections.Generic.Collection";
DictionaryBaseType = "System.Collections.Generic.Dictionary";

Move default settings to NJS: RicoSuter/NJsonSchema#806

@RicoSuter RicoSuter mentioned this pull request Nov 6, 2018
5 tasks
@RicoSuter RicoSuter merged commit 3251f8c into master Nov 6, 2018
@blushingpenguin
Copy link

ArrayBaseType = "System.Collections.Generic.Collection";

There doesn't appear to be such a type (I tried using this setting locally in nswag.json and it produced code that didn't compile). The list in the docs doesn't have it either.

did you mean:
System.Collections.ObjectModel.Collection
or perhaps even
System.Collections.Generic.List
?

Thanks,

Mark

@RicoSuter
Copy link
Owner Author

It should be
System.Collections.ObjectModel.Collection

@RicoSuter RicoSuter deleted the feature/change-default-settings branch December 19, 2018 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants