diff --git a/PSSwagger/Definitions.psm1 b/PSSwagger/Definitions.psm1
index 39b7aa7..10ef031 100644
--- a/PSSwagger/Definitions.psm1
+++ b/PSSwagger/Definitions.psm1
@@ -988,26 +988,37 @@ function New-SwaggerDefinitionFormatFile
$ViewTypeName = $ViewName
$TableColumnItemsList = @()
$TableColumnItemCount = 0
- $ParametersCount = Get-HashtableKeyCount -Hashtable $FunctionDetails.ParametersTable
- $SkipParameterList = @('id', 'tags')
$FunctionDetails.ParametersTable.GetEnumerator() | ForEach-Object {
-
$ParameterDetails = $_.Value
-
- # Add all properties when definition has 4 or less properties.
- # Otherwise add the first 4 properties with basic types by skipping the complex types, id and tags.
- if(($ParametersCount -le 4) -or
- (($TableColumnItemCount -le 4) -and
- ($SkipParameterList -notcontains $ParameterDetails.Name) -and
- (-not $ParameterDetails.Type.StartsWith($Namespace, [System.StringComparison]::OrdinalIgnoreCase))))
+ # Add all properties otherthan complex typed properties.
+ # Complex typed properties are not displayed by the PowerShell Format viewer.
+ if(-not $ParameterDetails.Type.StartsWith($Namespace, [System.StringComparison]::OrdinalIgnoreCase))
{
$TableColumnItemsList += $TableColumnItemStr -f ($ParameterDetails.Name)
$TableColumnItemCount += 1
}
}
- $TableColumnHeaders = $null
+ if(-not $TableColumnItemCount) {
+ Write-Verbose -Message ($LocalizedData.FormatFileNotRequired -f $FunctionDetails.Name)
+ return
+ }
+
+ $TableColumnHeadersList = @()
+ $DefaultWindowSizeWidth = 120
+ # Getting the width value for each property column. Default console window width is 120.
+ $TableColumnHeaderWidth = [int]($DefaultWindowSizeWidth/$TableColumnItemCount)
+
+ if ($TableColumnItemCount -ge 2) {
+ 1..($TableColumnItemCount - 1) | ForEach-Object {
+ $TableColumnHeadersList += $TableColumnHeaderStr -f ($TableColumnHeaderWidth)
+ }
+ }
+ # Allowing the last property to get the remaining column width, this is useful when customer increases the default window width.
+ $TableColumnHeadersList += $LastTableColumnHeaderStr
+
+ $TableColumnHeaders = $TableColumnHeadersList -join "`r`n"
$TableColumnItems = $TableColumnItemsList -join "`r`n"
$FormatViewDefinition = $FormatViewDefinitionStr -f ($ViewName, $ViewTypeName, $TableColumnHeaders, $TableColumnItems, $XmlHeaderComment)
diff --git a/PSSwagger/PSSwagger.Constants.ps1 b/PSSwagger/PSSwagger.Constants.ps1
index 5da4695..6b84c48 100644
--- a/PSSwagger/PSSwagger.Constants.ps1
+++ b/PSSwagger/PSSwagger.Constants.ps1
@@ -491,7 +491,8 @@ $FormatViewDefinitionStr = @'
{1}
- {2}
+
+{2}
@@ -518,6 +519,10 @@ $TableColumnHeaderStr = @'
'@
+$LastTableColumnHeaderStr = @'
+
+'@
+
$DefaultGeneratedFileHeader = @'
Code generated by Microsoft (R) PSSwagger {0}
Changes may cause incorrect behavior and will be lost if the code is regenerated.
diff --git a/PSSwagger/PSSwagger.Resources.psd1 b/PSSwagger/PSSwagger.Resources.psd1
index 276c238..ee0a3cf 100644
--- a/PSSwagger/PSSwagger.Resources.psd1
+++ b/PSSwagger/PSSwagger.Resources.psd1
@@ -43,6 +43,7 @@ ConvertFrom-StringData @'
GeneratedPathCommand=Generated path command '{0}'.
GeneratedDefinitionCommand=Generated command '{0}' for the definition name '{1}'.
GeneratedFormatFile=Generated output format file for the definition name '{0}'.
+ FormatFileNotRequired=It is not required to generated the format file as this definition '{0}' doesn't have non-complex typed properties.
DeleteGeneratedFile=Deleting generated file '{0}'
ExtractingMetadata=Extracting metadata from generated assembly
ExpectedServiceClientTypeNotFound=Unable to find expected service client type: {0}