Skip to content

Commit cf4a552

Browse files
committed
update powershell samples
1 parent 2700d84 commit cf4a552

72 files changed

Lines changed: 915 additions & 916 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-generator/src/test/java/org/openapitools/codegen/powershell/PowerShellClientCodegenTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
22
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
3-
* Copyright 2018 SmartBear Software
43
*
54
* Licensed under the Apache License, Version 2.0 (the "License");
65
* you may not use this file except in compliance with the License.

samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Bird.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function Initialize-Bird {
4141

4242

4343
$PSO = [PSCustomObject]@{
44-
"size" = ${Size}
45-
"color" = ${Color}
44+
'size' = ${Size}
45+
'color' = ${Color}
4646
}
4747

4848

@@ -80,28 +80,28 @@ function ConvertFrom-JsonToBird {
8080
$JsonParameters = ConvertFrom-Json -InputObject $Json
8181

8282
# check if Json contains properties not defined in Bird
83-
$AllProperties = ("size", "color")
83+
$AllProperties = ('size', 'color')
8484
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
8585
if (!($AllProperties.Contains($name))) {
8686
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
8787
}
8888
}
8989

90-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "size"))) { #optional property not found
90+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'size'))) { #optional property not found
9191
$Size = $null
9292
} else {
93-
$Size = $JsonParameters.PSobject.Properties["size"].value
93+
$Size = $JsonParameters.PSobject.Properties['size'].value
9494
}
9595

96-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "color"))) { #optional property not found
96+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'color'))) { #optional property not found
9797
$Color = $null
9898
} else {
99-
$Color = $JsonParameters.PSobject.Properties["color"].value
99+
$Color = $JsonParameters.PSobject.Properties['color'].value
100100
}
101101

102102
$PSO = [PSCustomObject]@{
103-
"size" = ${Size}
104-
"color" = ${Color}
103+
'size' = ${Size}
104+
'color' = ${Color}
105105
}
106106

107107
return $PSO

samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Category.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function Initialize-Category {
4141

4242

4343
$PSO = [PSCustomObject]@{
44-
"id" = ${Id}
45-
"name" = ${Name}
44+
'id' = ${Id}
45+
'name' = ${Name}
4646
}
4747

4848

@@ -80,28 +80,28 @@ function ConvertFrom-JsonToCategory {
8080
$JsonParameters = ConvertFrom-Json -InputObject $Json
8181

8282
# check if Json contains properties not defined in Category
83-
$AllProperties = ("id", "name")
83+
$AllProperties = ('id', 'name')
8484
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
8585
if (!($AllProperties.Contains($name))) {
8686
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
8787
}
8888
}
8989

90-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) { #optional property not found
90+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'id'))) { #optional property not found
9191
$Id = $null
9292
} else {
93-
$Id = $JsonParameters.PSobject.Properties["id"].value
93+
$Id = $JsonParameters.PSobject.Properties['id'].value
9494
}
9595

96-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) { #optional property not found
96+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'name'))) { #optional property not found
9797
$Name = $null
9898
} else {
99-
$Name = $JsonParameters.PSobject.Properties["name"].value
99+
$Name = $JsonParameters.PSobject.Properties['name'].value
100100
}
101101

102102
$PSO = [PSCustomObject]@{
103-
"id" = ${Id}
104-
"name" = ${Name}
103+
'id' = ${Id}
104+
'name' = ${Name}
105105
}
106106

107107
return $PSO

samples/client/echo_api/powershell/src/PSOpenAPITools/Model/DataQuery.ps1

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ function Initialize-DataQuery {
5757

5858

5959
$PSO = [PSCustomObject]@{
60-
"id" = ${Id}
61-
"outcomes" = ${Outcomes}
62-
"suffix" = ${Suffix}
63-
"text" = ${Text}
64-
"date" = ${Date}
60+
'id' = ${Id}
61+
'outcomes' = ${Outcomes}
62+
'suffix' = ${Suffix}
63+
'text' = ${Text}
64+
'date' = ${Date}
6565
}
6666

6767

@@ -99,49 +99,49 @@ function ConvertFrom-JsonToDataQuery {
9999
$JsonParameters = ConvertFrom-Json -InputObject $Json
100100

101101
# check if Json contains properties not defined in DataQuery
102-
$AllProperties = ("id", "outcomes", "suffix", "text", "date")
102+
$AllProperties = ('id', 'outcomes', 'suffix', 'text', 'date')
103103
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
104104
if (!($AllProperties.Contains($name))) {
105105
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
106106
}
107107
}
108108

109-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) { #optional property not found
109+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'id'))) { #optional property not found
110110
$Id = $null
111111
} else {
112-
$Id = $JsonParameters.PSobject.Properties["id"].value
112+
$Id = $JsonParameters.PSobject.Properties['id'].value
113113
}
114114

115-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "outcomes"))) { #optional property not found
115+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'outcomes'))) { #optional property not found
116116
$Outcomes = $null
117117
} else {
118-
$Outcomes = $JsonParameters.PSobject.Properties["outcomes"].value
118+
$Outcomes = $JsonParameters.PSobject.Properties['outcomes'].value
119119
}
120120

121-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "suffix"))) { #optional property not found
121+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'suffix'))) { #optional property not found
122122
$Suffix = $null
123123
} else {
124-
$Suffix = $JsonParameters.PSobject.Properties["suffix"].value
124+
$Suffix = $JsonParameters.PSobject.Properties['suffix'].value
125125
}
126126

127-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "text"))) { #optional property not found
127+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'text'))) { #optional property not found
128128
$Text = $null
129129
} else {
130-
$Text = $JsonParameters.PSobject.Properties["text"].value
130+
$Text = $JsonParameters.PSobject.Properties['text'].value
131131
}
132132

133-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "date"))) { #optional property not found
133+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'date'))) { #optional property not found
134134
$Date = $null
135135
} else {
136-
$Date = $JsonParameters.PSobject.Properties["date"].value
136+
$Date = $JsonParameters.PSobject.Properties['date'].value
137137
}
138138

139139
$PSO = [PSCustomObject]@{
140-
"id" = ${Id}
141-
"outcomes" = ${Outcomes}
142-
"suffix" = ${Suffix}
143-
"text" = ${Text}
144-
"date" = ${Date}
140+
'id' = ${Id}
141+
'outcomes' = ${Outcomes}
142+
'suffix' = ${Suffix}
143+
'text' = ${Text}
144+
'date' = ${Date}
145145
}
146146

147147
return $PSO

samples/client/echo_api/powershell/src/PSOpenAPITools/Model/DefaultValue.ps1

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ function Initialize-DefaultValue {
7272

7373

7474
$PSO = [PSCustomObject]@{
75-
"array_string_enum_ref_default" = ${ArrayStringEnumRefDefault}
76-
"array_string_enum_default" = ${ArrayStringEnumDefault}
77-
"array_string_default" = ${ArrayStringDefault}
78-
"array_integer_default" = ${ArrayIntegerDefault}
79-
"array_string" = ${ArrayString}
80-
"array_string_nullable" = ${ArrayStringNullable}
81-
"array_string_extension_nullable" = ${ArrayStringExtensionNullable}
82-
"string_nullable" = ${StringNullable}
75+
'array_string_enum_ref_default' = ${ArrayStringEnumRefDefault}
76+
'array_string_enum_default' = ${ArrayStringEnumDefault}
77+
'array_string_default' = ${ArrayStringDefault}
78+
'array_integer_default' = ${ArrayIntegerDefault}
79+
'array_string' = ${ArrayString}
80+
'array_string_nullable' = ${ArrayStringNullable}
81+
'array_string_extension_nullable' = ${ArrayStringExtensionNullable}
82+
'string_nullable' = ${StringNullable}
8383
}
8484

8585

@@ -117,70 +117,70 @@ function ConvertFrom-JsonToDefaultValue {
117117
$JsonParameters = ConvertFrom-Json -InputObject $Json
118118

119119
# check if Json contains properties not defined in DefaultValue
120-
$AllProperties = ("array_string_enum_ref_default", "array_string_enum_default", "array_string_default", "array_integer_default", "array_string", "array_string_nullable", "array_string_extension_nullable", "string_nullable")
120+
$AllProperties = ('array_string_enum_ref_default', 'array_string_enum_default', 'array_string_default', 'array_integer_default', 'array_string', 'array_string_nullable', 'array_string_extension_nullable', 'string_nullable')
121121
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
122122
if (!($AllProperties.Contains($name))) {
123123
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
124124
}
125125
}
126126

127-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string_enum_ref_default"))) { #optional property not found
127+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'array_string_enum_ref_default'))) { #optional property not found
128128
$ArrayStringEnumRefDefault = $null
129129
} else {
130-
$ArrayStringEnumRefDefault = $JsonParameters.PSobject.Properties["array_string_enum_ref_default"].value
130+
$ArrayStringEnumRefDefault = $JsonParameters.PSobject.Properties['array_string_enum_ref_default'].value
131131
}
132132

133-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string_enum_default"))) { #optional property not found
133+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'array_string_enum_default'))) { #optional property not found
134134
$ArrayStringEnumDefault = $null
135135
} else {
136-
$ArrayStringEnumDefault = $JsonParameters.PSobject.Properties["array_string_enum_default"].value
136+
$ArrayStringEnumDefault = $JsonParameters.PSobject.Properties['array_string_enum_default'].value
137137
}
138138

139-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string_default"))) { #optional property not found
139+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'array_string_default'))) { #optional property not found
140140
$ArrayStringDefault = $null
141141
} else {
142-
$ArrayStringDefault = $JsonParameters.PSobject.Properties["array_string_default"].value
142+
$ArrayStringDefault = $JsonParameters.PSobject.Properties['array_string_default'].value
143143
}
144144

145-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_integer_default"))) { #optional property not found
145+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'array_integer_default'))) { #optional property not found
146146
$ArrayIntegerDefault = $null
147147
} else {
148-
$ArrayIntegerDefault = $JsonParameters.PSobject.Properties["array_integer_default"].value
148+
$ArrayIntegerDefault = $JsonParameters.PSobject.Properties['array_integer_default'].value
149149
}
150150

151-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string"))) { #optional property not found
151+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'array_string'))) { #optional property not found
152152
$ArrayString = $null
153153
} else {
154-
$ArrayString = $JsonParameters.PSobject.Properties["array_string"].value
154+
$ArrayString = $JsonParameters.PSobject.Properties['array_string'].value
155155
}
156156

157-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string_nullable"))) { #optional property not found
157+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'array_string_nullable'))) { #optional property not found
158158
$ArrayStringNullable = $null
159159
} else {
160-
$ArrayStringNullable = $JsonParameters.PSobject.Properties["array_string_nullable"].value
160+
$ArrayStringNullable = $JsonParameters.PSobject.Properties['array_string_nullable'].value
161161
}
162162

163-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string_extension_nullable"))) { #optional property not found
163+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'array_string_extension_nullable'))) { #optional property not found
164164
$ArrayStringExtensionNullable = $null
165165
} else {
166-
$ArrayStringExtensionNullable = $JsonParameters.PSobject.Properties["array_string_extension_nullable"].value
166+
$ArrayStringExtensionNullable = $JsonParameters.PSobject.Properties['array_string_extension_nullable'].value
167167
}
168168

169-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "string_nullable"))) { #optional property not found
169+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'string_nullable'))) { #optional property not found
170170
$StringNullable = $null
171171
} else {
172-
$StringNullable = $JsonParameters.PSobject.Properties["string_nullable"].value
172+
$StringNullable = $JsonParameters.PSobject.Properties['string_nullable'].value
173173
}
174174

175175
$PSO = [PSCustomObject]@{
176-
"array_string_enum_ref_default" = ${ArrayStringEnumRefDefault}
177-
"array_string_enum_default" = ${ArrayStringEnumDefault}
178-
"array_string_default" = ${ArrayStringDefault}
179-
"array_integer_default" = ${ArrayIntegerDefault}
180-
"array_string" = ${ArrayString}
181-
"array_string_nullable" = ${ArrayStringNullable}
182-
"array_string_extension_nullable" = ${ArrayStringExtensionNullable}
183-
"string_nullable" = ${StringNullable}
176+
'array_string_enum_ref_default' = ${ArrayStringEnumRefDefault}
177+
'array_string_enum_default' = ${ArrayStringEnumDefault}
178+
'array_string_default' = ${ArrayStringDefault}
179+
'array_integer_default' = ${ArrayIntegerDefault}
180+
'array_string' = ${ArrayString}
181+
'array_string_nullable' = ${ArrayStringNullable}
182+
'array_string_extension_nullable' = ${ArrayStringExtensionNullable}
183+
'string_nullable' = ${StringNullable}
184184
}
185185

186186
return $PSO

samples/client/echo_api/powershell/src/PSOpenAPITools/Model/NumberPropertiesOnly.ps1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ function Initialize-NumberPropertiesOnly {
5454

5555

5656
$PSO = [PSCustomObject]@{
57-
"number" = ${Number}
58-
"float" = ${Float}
59-
"double" = ${Double}
57+
'number' = ${Number}
58+
'float' = ${Float}
59+
'double' = ${Double}
6060
}
6161

6262

@@ -94,35 +94,35 @@ function ConvertFrom-JsonToNumberPropertiesOnly {
9494
$JsonParameters = ConvertFrom-Json -InputObject $Json
9595

9696
# check if Json contains properties not defined in NumberPropertiesOnly
97-
$AllProperties = ("number", "float", "double")
97+
$AllProperties = ('number', 'float', 'double')
9898
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
9999
if (!($AllProperties.Contains($name))) {
100100
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
101101
}
102102
}
103103

104-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "number"))) { #optional property not found
104+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'number'))) { #optional property not found
105105
$Number = $null
106106
} else {
107-
$Number = $JsonParameters.PSobject.Properties["number"].value
107+
$Number = $JsonParameters.PSobject.Properties['number'].value
108108
}
109109

110-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "float"))) { #optional property not found
110+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'float'))) { #optional property not found
111111
$Float = $null
112112
} else {
113-
$Float = $JsonParameters.PSobject.Properties["float"].value
113+
$Float = $JsonParameters.PSobject.Properties['float'].value
114114
}
115115

116-
if (!([bool]($JsonParameters.PSobject.Properties.name -match "double"))) { #optional property not found
116+
if (!([bool]($JsonParameters.PSobject.Properties.name -match 'double'))) { #optional property not found
117117
$Double = $null
118118
} else {
119-
$Double = $JsonParameters.PSobject.Properties["double"].value
119+
$Double = $JsonParameters.PSobject.Properties['double'].value
120120
}
121121

122122
$PSO = [PSCustomObject]@{
123-
"number" = ${Number}
124-
"float" = ${Float}
125-
"double" = ${Double}
123+
'number' = ${Number}
124+
'float' = ${Float}
125+
'double' = ${Double}
126126
}
127127

128128
return $PSO

0 commit comments

Comments
 (0)