Skip to content

Commit

Permalink
Add support for missing NSwag studio options (RicoSuter#4554)
Browse files Browse the repository at this point in the history
* Add PropertySetterAccessModifier, GenerateNativeRecords into NSwagStudio

* Update .Net8 default nswag.json

* Add PropertySetterAccessModifier, GenerateNativeRecords into OpenApiToCSharpClientCommand
  • Loading branch information
trejjam authored and lahma committed Jan 20, 2024
1 parent 989b423 commit d766d33
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ public string TypeAccessModifier
set { Settings.CSharpGeneratorSettings.TypeAccessModifier = value; }
}

[Argument(Name = "PropertySetterAccessModifier", IsRequired = false, Description = "The access modifier of property setters (default: '').")]
public string PropertySetterAccessModifier
{
get { return Settings.CSharpGeneratorSettings.PropertySetterAccessModifier; }
set { Settings.CSharpGeneratorSettings.PropertySetterAccessModifier = value; }
}

[Argument(Name = "GenerateNativeRecords", IsRequired = false, Description = "Generate C# 9.0 record types instead of record-like classes (default: false).")]
public bool GenerateNativeRecords
{
get { return Settings.CSharpGeneratorSettings.GenerateNativeRecords; }
set { Settings.CSharpGeneratorSettings.GenerateNativeRecords = value; }
}

[Argument(Name = "GenerateContractsOutput", IsRequired = false,
Description = "Specifies whether to generate contracts output (interface and models in a separate file set with the ContractsOutput parameter).")]
public bool GenerateContractsOutput { get; set; }
Expand Down
4 changes: 3 additions & 1 deletion src/NSwag.Sample.NET80Minimal/nswag.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@
"exposeJsonSerializerSettings": false,
"clientClassAccessModifier": "public",
"typeAccessModifier": "public",
"propertySetterAccessModifier": "",
"generateContractsOutput": false,
"generateNativeRecords": false,
"contractsNamespace": null,
"contractsOutputFilePath": null,
"parameterDateTimeFormat": "s",
Expand Down Expand Up @@ -224,4 +226,4 @@
"newLineBehavior": "Auto"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
Content="Generate contracts output"
Margin="0,0,0,12" />

<CheckBox IsChecked="{Binding Command.GenerateNativeRecords, Mode=TwoWay}"
ToolTip="GenerateNativeRecords"
Content="Generate record types"
Margin="0,0,0,12" />

<StackPanel Visibility="{Binding Command.GenerateContractsOutput, Converter={StaticResource VisibilityConverter}}">
<TextBlock Text="Contracts Namespace"
FontWeight="Bold"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
<TextBox Text="{Binding Command.TypeAccessModifier, Mode=TwoWay}"
ToolTip="TypeAccessModifier" Margin="0,0,0,12" />

<CheckBox IsChecked="{Binding Command.GenerateDefaultValues, Mode=TwoWay}"
<TextBlock Text="DTO property setter access modifier" FontWeight="Bold" Margin="0,0,0,6" />
<TextBox Text="{Binding Command.PropertySetterAccessModifier, Mode=TwoWay}"
ToolTip="PropertySetterAccessModifier" Margin="0,0,0,12" />

<CheckBox IsChecked="{Binding Command.GenerateDefaultValues, Mode=TwoWay}"
ToolTip="GenerateDefaultValues" Margin="0,0,0,12">
<TextBlock Text="Generate default values for properties (if default value is specified)" TextWrapping="Wrap" />
</CheckBox>
Expand Down

0 comments on commit d766d33

Please sign in to comment.