Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a3e7a53
Increment PSSwagger version
brywang-msft Aug 8, 2017
3c20fd3
readme update (#292)
brywang-msft Aug 9, 2017
2d646f9
Support custom x-ms-pageable\NextLinkName field name (#294)
bmanikm Aug 11, 2017
3d2520e
Updated Readme and fixed an error related to importing the PSSwaggerU…
bmanikm Aug 14, 2017
092bcac
Fix localization error in SwaggerUtil (#303)
megamorf Aug 15, 2017
0f700d3
Ensure $oDataQuery expression is generated properly when a global par…
bmanikm Aug 17, 2017
090b304
Alpha 1 of test server (#309)
brywang-msft Aug 22, 2017
40c9abe
Support default and customizable header comment for the PSSwagger gen…
bmanikm Aug 23, 2017
7d6c8b9
Add support for generating the C# SDK assembly using CSC.exe on Windo…
bmanikm Aug 28, 2017
9594978
Support latest version of AutoRest in PSSwagger (#313)
bmanikm Aug 30, 2017
21a2a54
Removing the langversion from CSC parameters as latest is the default…
bmanikm Sep 6, 2017
15af392
Changes for test server to work for Azure SDK happy path tests (#315)
brywang-msft Sep 7, 2017
cb64bc7
Add support for predefined header values. (#320)
bmanikm Sep 7, 2017
37d8618
Add support for generating PowerShell cmdlets using pre-built SDK ass…
bmanikm Sep 9, 2017
7a8f321
Add New-ServiceClient utility function in generated module to enable …
bmanikm Sep 13, 2017
90ed6d0
Write exceptions in generated commands (#324)
brywang-msft Sep 13, 2017
31e3236
Update taskresult handling logic to give priority to the $taskResult.…
bmanikm Sep 15, 2017
ae8463d
Handle unwrapping exceptions to CloudError objects, update (#327)
brywang-msft Sep 18, 2017
37e72af
Fix for server spinning bug (#330)
brywang-msft Sep 18, 2017
d7a5528
Change warninglevel to 1 for generating assembly for Azure Swagger sp…
bmanikm Sep 19, 2017
c050b4c
Resolve UnableToExtractDetailsFromSdkAssembly error when OperationTyp…
bmanikm Sep 20, 2017
79d83fd
Rename IsOSX to IsMacOS after breaking change in PowerShell 6.0.0-bet…
ffeldhaus Sep 20, 2017
9891ec8
Generate SYNOPSIS help content in the generated cmdlets. (#337)
bmanikm Sep 20, 2017
f31ce37
Add support for AdditionalProperties Json schema with array type (#339)
bmanikm Sep 21, 2017
8fd56eb
Add support for parameter type references to enum definitions. (#341)
bmanikm Sep 22, 2017
f0e1c5a
Add AutoRest version in run-tests.ps1 (#344)
bmanikm Sep 28, 2017
fb8b946
Add support for generating proper output type for the Swagger operati…
bmanikm Sep 28, 2017
6360475
Add CHANGELOG.md, and minor update for releasing the 0.3.0 version of…
bmanikm Sep 29, 2017
4523634
Merge branch 'master' into developer
bmanikm Sep 29, 2017
2b2782e
New-ServiceClient error on custom host (#350)
deathly809 Oct 3, 2017
bdb849f
[Azure and AzureStack] Use IClientFactory to create ARM Client in Azu…
bmanikm Oct 3, 2017
33dfbcb
Verb map change: 'Regenerate' to 'New' instead of 'Update' as per the…
bmanikm Oct 3, 2017
0cb7ebe
Use separate PSCmdletOutputItemType variable for getting the output i…
bmanikm Oct 3, 2017
2b537ae
Escape '<#' and '#>', and replace '--' with '==' in Header content (#…
bmanikm Oct 3, 2017
248d5c2
Add all non-complex type properties in output format ps1xml files. (#…
bmanikm Oct 4, 2017
a9946e5
Add NoVersionFolder switch parameter on New-PSSwaggerModule cmdlet to…
bmanikm Oct 4, 2017
8b86be2
Add few verb mappings for Azure RPs (#356)
bmanikm Oct 4, 2017
2fb99b9
Move New-HttpClientHandler logic into New-ServiceClient for non-Azure…
bmanikm Oct 4, 2017
749c391
Generate single Verb-Noun cmdlet for OperationIds like Noun_Verb and …
bmanikm Oct 6, 2017
542c8c2
Update change log to include new changes into 0.3.0 release. (#359)
bmanikm Oct 9, 2017
cf98d71
Merge branch 'master' into developer
bmanikm Oct 9, 2017
87ae3ba
Revert the changes from automatic merge commit from master to develop…
bmanikm Oct 9, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog

## v0.3.0 - 2017-09-29
## v0.3.0
- Generate single Verb-Noun cmdlet for OperationIds like Noun_Verb and Noun_VerbBySomething (#358)
- Move New-HttpClientHandler logic into New-ServiceClient for non-Azure services. (#357)
- Add few verb mappings for Azure RPs (#356)
- Add NoVersionFolder switch parameter on New-PSSwaggerModule cmdlet to not create the version folder. (#355)
- Add all non-complex type properties in output format ps1xml files. (#354)
- Escape '<#' and '#>', and replace '--' with '==' in Header content (#352)
- Use separate PSCmdletOutputItemType variable for getting the output item type of pageable swagger operations. (#351)
- Verb map change: 'Regenerate' to 'New' instead of 'Update' as per the feedback recieved from Azure PowerShell team. (#347)
- [Azure and AzureStack] Use IClientFactory to create ARM Client in Azure PowerShell way. (#348)
- New-ServiceClient error on custom host (#350)
- Add CHANGELOG.md, and minor update for releasing the 0.3.0 version of PSSwagger and PSSwaggerUtility modules. (#345)
- Add support for generating proper output type for the Swagger operations with x-ms-pageable extension (#342)
- Add support for parameter type references to enum definitions (#341)
- Add support for AdditionalProperties Json schema with array type (#339)
Expand All @@ -21,7 +32,7 @@
- Update Readme and fix an error related to importing the PSSwaggerUtility module (#300)
- Support custom x-ms-pageable\NextLinkName field name (#294)

## v0.2.0 - 2017-08-15
## v0.2.0

* First preview release

Expand Down
8 changes: 0 additions & 8 deletions PSSwagger/AssemblyGenerationHelpers.Resources.psd1
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#########################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# Licensed under the MIT license.
#
#########################################################################################

ConvertFrom-StringData @'
###PSLOC

Expand Down
8 changes: 0 additions & 8 deletions PSSwagger/AssemblyGenerationHelpers.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#########################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# Licensed under the MIT license.
#
#########################################################################################

Microsoft.PowerShell.Core\Set-StrictMode -Version Latest
Microsoft.PowerShell.Utility\Import-LocalizedData LocalizedData -FileName AssemblyGenerationHelpers.Resources.psd1

Expand Down
33 changes: 22 additions & 11 deletions PSSwagger/Definitions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
96 changes: 0 additions & 96 deletions PSSwagger/GeneratedHelpers.ps1

This file was deleted.

49 changes: 49 additions & 0 deletions PSSwagger/New-ArmServiceClient.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Microsoft.PowerShell.Core\Set-StrictMode -Version Latest

<#
.DESCRIPTION
Creates Service Client object.

.PARAMETER FullClientTypeName
Client type full name.

.PARAMETER GlobalParameterHashtable
Global parameters to be set on client object.
#>
function New-ServiceClient {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]
$FullClientTypeName,

[Parameter(Mandatory = $false)]
[PSCustomObject]
$GlobalParameterHashtable
)

# Azure Powershell way
[Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContext]$Context = Get-AzureRmContext
if (-not $Context -or -not $Context.Account) {
Write-Error -Message 'Run Login-AzureRmAccount to login.' -ErrorId 'AzureRmContextError'
return
}

$Factory = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.ClientFactory
[System.Type[]]$Types = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContext], [string]
$CreateArmClientMethod = [Microsoft.Azure.Commands.Common.Authentication.IClientFactory].GetMethod('CreateArmClient', $Types)
$ClientType = $FullClientTypeName -as [Type]
$ClosedMethod = $CreateArmClientMethod.MakeGenericMethod($ClientType)
$Arguments = $Context, [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureEnvironment+Endpoint]::ResourceManager
$Client = $closedMethod.Invoke($Factory, $Arguments)

if ($GlobalParameterHashtable) {
$GlobalParameterHashtable.GetEnumerator() | ForEach-Object {
if ($_.Value -and (Get-Member -InputObject $Client -Name $_.Key -MemberType Property)) {
$Client."$($_.Key)" = $_.Value
}
}
}

return $Client
}
31 changes: 10 additions & 21 deletions PSSwagger/New-ServiceClient.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ Microsoft.PowerShell.Core\Set-StrictMode -Version Latest
Command should return a custom hostname string.
Overrides the default host in the specification.

.PARAMETER SubscriptionIdCommand
Custom command get SubscriptionId value.

.PARAMETER GlobalParameterHashtable
Global parameters to be set on client object.
#>
Expand Down Expand Up @@ -56,10 +53,6 @@ function New-ServiceClient {
[string]
$HostOverrideCommand,

[Parameter(Mandatory = $false)]
[string]
$SubscriptionIdCommand,

[Parameter(Mandatory = $false)]
[PSCustomObject]
$GlobalParameterHashtable
Expand All @@ -75,7 +68,12 @@ function New-ServiceClient {
$ClientArgumentList += Invoke-Command @InvokeCommand_parameters

if ($AddHttpClientHandler) {
$httpClientHandler = New-HttpClientHandler -Credential $Credential
if(-not ('System.Net.Http.HttpClientHandler' -as [Type])) {
Add-Type -AssemblyName System.Net.Http
}
$httpClientHandler = New-Object -TypeName System.Net.Http.HttpClientHandler
$httpClientHandler.PreAuthenticate = $true
$httpClientHandler.Credentials = $Credential
$ClientArgumentList += $httpClientHandler
}

Expand All @@ -85,23 +83,14 @@ function New-ServiceClient {
$Client = New-Object -TypeName $FullClientTypeName -ArgumentList $ClientArgumentList

if ($HostOverrideCommand) {
$Client.BaseUri = Invoke-Command -ScriptBlock [scriptblock]::Create($HostOverrideCommand)
[scriptblock]$HostOverrideCommand = [scriptblock]::Create($HostOverrideCommand)
$Client.BaseUri = Invoke-Command -ScriptBlock $HostOverrideCommand
}

if ($GlobalParameterHashtable) {
$GlobalParameterHashtable.GetEnumerator() | ForEach-Object {
if (Get-Member -InputObject $Client -Name $_.Key -MemberType Property) {
if ((-not $_.Value) -and ($_.Key -eq 'SubscriptionId')) {
if($SubscriptionIdCommand) {
$Client.SubscriptionId = Invoke-Command -ScriptBlock [scriptblock]::Create($SubscriptionIdCommand)
}
else {
$Client.SubscriptionId = Get-AzSubscriptionId
}
}
else {
$Client."$($_.Key)" = $_.Value
}
if ($_.Value -and (Get-Member -InputObject $Client -Name $_.Key -MemberType Property)) {
$Client."$($_.Key)" = $_.Value
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions PSSwagger/PSCommandVerbMap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ $script:PSCommandVerbMap = @{
Acquire = 'Get'
Examine = 'Get'
Suggest = 'Get'
Retrieve = 'Get'

Create = 'New'
Generate = 'New'
Allocate = 'New'
Provision = 'New'
Make = 'New'

Regenerate = 'New' # Alternatives: Redo, Update, Reset

CreateOrUpdate = 'New,Set'
Failover = 'Set'
Assign = 'Set'
Expand Down Expand Up @@ -53,10 +55,10 @@ $script:PSCommandVerbMap = @{

Patch = 'Update'
Refresh = 'Update'
Regenerate = 'Update' # Alternatives: Redo, New, Reset
Reprocess = "Update" # Alternatives: Redo
Upgrade = 'Update'
Reimage = 'Update' # Alternatives: Format, Reset
Retarget = 'Update'

Validate = 'Test'
Check = 'Test'
Expand Down Expand Up @@ -103,12 +105,14 @@ $script:PSCommandVerbMap = @{
Migrate = 'Move' # Alternatives: Export
Transfer = 'Move'
Name = 'Move'
Reassociate = 'Move'

Change = 'Rename'

Swap = 'Switch' # Alternatives: Move

Execute = 'Invoke'
Perform = 'Invoke'

Discover = 'Find' # Alternatives: Search
Locate = 'Find'
Expand Down Expand Up @@ -140,4 +144,8 @@ $script:PSCommandVerbMap = @{
Jump = 'Skip'

Separate = 'Split'

Notify = 'Send'

Authorize = 'Grant'
}
8 changes: 6 additions & 2 deletions PSSwagger/PSSwagger.Constants.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ if (Test-Path -Path `$ClrPath -PathType Container) {
}

. (Join-Path -Path `$PSScriptRoot -ChildPath 'New-ServiceClient.ps1')
. (Join-Path -Path `$PSScriptRoot -ChildPath 'GeneratedHelpers.ps1')

`$allPs1FilesPath = Join-Path -Path `$PSScriptRoot -ChildPath '$GeneratedCommandsName' | Join-Path -ChildPath '*.ps1'
Get-ChildItem -Path `$allPs1FilesPath -Recurse -File | ForEach-Object { . `$_.FullName}
Expand Down Expand Up @@ -491,7 +490,8 @@ $FormatViewDefinitionStr = @'
<TypeName>{1}</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>{2}
<TableHeaders>
{2}
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
Expand All @@ -518,6 +518,10 @@ $TableColumnHeaderStr = @'
</TableColumnHeader>
'@

$LastTableColumnHeaderStr = @'
<TableColumnHeader/>
'@

$DefaultGeneratedFileHeader = @'
Code generated by Microsoft (R) PSSwagger {0}
Changes may cause incorrect behavior and will be lost if the code is regenerated.
Expand Down
Loading