Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
add get host setting
  • Loading branch information
wing328 committed Mar 29, 2020
commit f5a0181a83a9078657e248c269aa5afdabc735df
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,51 @@ function Set-{{{apiNamePrefix}}}ConfigurationApiKeyPrefix {
$Script:Configuration["ApiKeyPrefix"][$Id] = $ApiKeyPrefix
}
}

<#
.SYNOPSIS

Get the host setting.

.DESCRIPTION

Get the host setting in the form of array of hashtables.

.OUTPUTS

System.Collections.Hashtable[]
#>
function Get-{{apiNamePrefix}}HostSetting {

return @(
{{#servers}}
@{
"Url" = "{{{url}}}";
"Description" = "{{{description}}}{{^description}}No description provided{{/description}}";
{{#variables}}
{{#-first}}
"Variables" = @{
{{/-first}}
"{{{name}}}" = @{
"Description" = "{{{description}}}{{^description}}No description provided{{/description}}";
"DefaultValue" = "{{{defaultValue}}}";
{{#enumValues}}
{{#-first}}
"EnumValues" => @(
{{/-first}}
"{{{.}}}"{{^-last}},{{/-last}}
{{#-last}}
)
{{/-last}}
{{/enumValues}}
}{{^-last}};{{/-last}}
{{#-last}}
}
{{/-last}}
{{/variables}}
}{{^-last}},{{/-last}}
{{/servers}}
)

}

Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
openapi: 3.0.0
servers:
- url: 'http://petstore.swagger.io/v2'
- url: 'http://{server}.swagger.io:{port}/v2'
description: petstore server
variables:
server:
enum:
- 'petstore'
- 'qa-petstore'
- 'dev-petstore'
default: 'petstore'
port:
enum:
- 80
- 8080
default: 80
- url: https://localhost:8080/{version}
description: The local server
variables:
version:
enum:
- 'v1'
- 'v2'
default: 'v2'
info:
description: >-
This is a sample server Petstore server. For this sample, you can use the api key
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/powershell-experimental/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Invoker-Pester

## Documentation for API Endpoints

All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://petstore.swagger.io:80/v2*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PSPetstore.PSPetstore/Api.PSPetApi

All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://petstore.swagger.io:80/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PSPetstore.PSPetstore/Api.PSStoreApi

All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://petstore.swagger.io:80/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PSPetstore.PSPetstore/Api.PSUserApi

All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://petstore.swagger.io:80/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Get-PSConfiguration {
$Configuration = $Script:Configuration

if ([string]::IsNullOrEmpty($Configuration["BaseUrl"])) {
$Configuration["BaseUrl"] = "http://petstore.swagger.io/v2";
$Configuration["BaseUrl"] = "http://petstore.swagger.io:80/v2";
}

if (!$Configuration.containsKey("Username")) {
Expand Down Expand Up @@ -215,3 +215,61 @@ function Set-PSConfigurationApiKeyPrefix {
$Script:Configuration["ApiKeyPrefix"][$Id] = $ApiKeyPrefix
}
}

<#
.SYNOPSIS

Get the host setting.

.DESCRIPTION

Get the host setting in the form of array of hashtables.

.OUTPUTS

System.Collections.Hashtable[]
#>
function Get-PSHostSetting {

return @(
@{
"Url" = "http://{server}.swagger.io:{port}/v2";
"Description" = "petstore server";
"Variables" = @{
"server" = @{
"Description" = "No description provided";
"DefaultValue" = "petstore";
"EnumValues" => @(
"petstore",
"qa-petstore",
"dev-petstore"
)
};
"port" = @{
"Description" = "No description provided";
"DefaultValue" = "80";
"EnumValues" => @(
"80",
"8080"
)
}
}
},
@{
"Url" = "https://localhost:8080/{version}";
"Description" = "The local server";
"Variables" = @{
"version" = @{
"Description" = "No description provided";
"DefaultValue" = "v2";
"EnumValues" => @(
"v1",
"v2"
)
}
}
}
)

}

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: OpenAPI Generator Team
#
# Generated on: 3/19/20
# Generated on: 3/29/20
#

@{
Expand Down Expand Up @@ -79,7 +79,8 @@ FunctionsToExport = 'Add-PSPet', 'Remove-Pet', 'Find-PSPetsByStatus', 'Find-PSPe
'Update-PSUser', 'New-PSApiResponse', 'New-PSCategory',
'New-PSInlineObject', 'New-PSInlineObject1', 'New-PSOrder', 'New-PSPet',
'New-PSTag', 'New-PSUser', 'Get-PSConfiguration', 'Set-PSConfiguration',
'Set-PSConfigurationApiKey', 'Set-PSConfigurationApiKeyPrefix'
'Set-PSConfigurationApiKey', 'Set-PSConfigurationApiKeyPrefix',
'Get-PSHostSetting'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
Expand Down