Skip to content

Commit 33e6cbf

Browse files
authored
Merge branch 'master' into new_generators_tweaks
2 parents 5e0d695 + 0ff7306 commit 33e6cbf

File tree

4 files changed

+54
-16
lines changed

4 files changed

+54
-16
lines changed

src/main/java/io/swagger/codegen/v3/generators/SchemaHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ protected CodegenModel processArrayItemSchema(CodegenModel codegenModel, ArraySc
124124
final Schema itemsSchema = arraySchema.getItems();
125125
if (itemsSchema instanceof ComposedSchema) {
126126
final CodegenModel composedModel = this.processComposedSchema(codegenModel.name + ARRAY_ITEMS_SUFFIX, (ComposedSchema) itemsSchema, allModels);
127+
if (composedModel == null) {
128+
return null;
129+
}
127130
this.updateArrayModel(codegenModel, composedModel.name, arraySchema);
128131
return composedModel;
129132
}

src/main/resources/handlebars/csharp/Configuration.mustache

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ namespace {{packageName}}.Client
113113
ApiKey = new {{^net35}}Concurrent{{/net35}}Dictionary<string, string>();
114114
ApiKeyPrefix = new {{^net35}}Concurrent{{/net35}}Dictionary<string, string>();
115115

116-
// Setting Timeout has side effects (forces ApiClient creation).
117116
Timeout = 100000;
118117
}
119118

@@ -236,15 +235,49 @@ namespace {{packageName}}.Client
236235
/// </summary>
237236
public virtual IDictionary<string, string> DefaultHeader { get; set; }
238237
238+
private int _timeout = 100000;
239239
/// <summary>
240240
/// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds.
241241
/// </summary>
242242
public virtual int Timeout
243243
{
244-
{{#netStandard}}get { return (int)ApiClient.RestClient.Timeout.GetValueOrDefault(TimeSpan.FromSeconds(0)).TotalMilliseconds; }
245-
set { ApiClient.RestClient.Timeout = TimeSpan.FromMilliseconds(value); }{{/netStandard}}{{^netStandard}}
246-
get { return ApiClient.RestClient.Timeout; }
247-
set { ApiClient.RestClient.Timeout = value; }{{/netStandard}}
244+
{{#netStandard}}get
245+
{
246+
if (_apiClient == null)
247+
{
248+
return _timeout;
249+
} else
250+
{
251+
return (int)ApiClient.RestClient.Timeout.GetValueOrDefault(TimeSpan.FromSeconds(0)).TotalMilliseconds;
252+
}
253+
}
254+
set
255+
{
256+
_timeout = value;
257+
if (_apiClient != null)
258+
{
259+
ApiClient.RestClient.Timeout = TimeSpan.FromMilliseconds(_timeout);
260+
}
261+
}{{/netStandard}}{{^netStandard}}
262+
get
263+
{
264+
if (_apiClient == null)
265+
{
266+
return _timeout;
267+
}
268+
else
269+
{
270+
return ApiClient.RestClient.Timeout;
271+
}
272+
}
273+
set
274+
{
275+
_timeout = value;
276+
if (_apiClient != null)
277+
{
278+
ApiClient.RestClient.Timeout = _timeout;
279+
}
280+
}{{/netStandard}}
248281
}
249282
250283
/// <summary>

src/main/resources/handlebars/php/ObjectSerializer.mustache

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ class ObjectSerializer
3333
* Serialize data
3434
*
3535
* @param mixed $data the data to serialize
36-
* @param string $type the SwaggerType of the data
3736
* @param string $format the format of the Swagger type of the data
3837
*
3938
* @return string|object serialized form of $data
4039
*/
41-
public static function sanitizeForSerialization($data, $type = null, $format = null)
40+
public static function sanitizeForSerialization($data, $format = null)
4241
{
4342
if (is_scalar($data) || null === $data) {
4443
return $data;
@@ -109,22 +108,23 @@ class ObjectSerializer
109108
* later.
110109
*
111110
* @param string[]|string|\DateTime $object an object to be serialized to a string
111+
* @param string|null $format the format of the parameter
112112
*
113113
* @return string the serialized object
114114
*/
115-
public static function toQueryValue($object)
115+
public static function toQueryValue($object, $format = null)
116116
{
117117
if (is_array($object)) {
118118
return implode(',', $object);
119119
} else {
120-
return self::toString($object);
120+
return self::toString($object, $format);
121121
}
122122
}
123123

124124
/**
125125
* Take value and turn it into a string suitable for inclusion in
126126
* the header. If it's a string, pass through unchanged
127-
* If it's a datetime object, format it in ISO8601
127+
* If it's a datetime object, format it in RFC3339
128128
*
129129
* @param string $value a string which will be part of the header
130130
*
@@ -138,7 +138,7 @@ class ObjectSerializer
138138
/**
139139
* Take value and turn it into a string suitable for inclusion in
140140
* the http body (form parameter). If it's a string, pass through unchanged
141-
* If it's a datetime object, format it in ISO8601
141+
* If it's a datetime object, format it in RFC3339
142142
*
143143
* @param string|\SplFileObject $value the value of the form parameter
144144
*
@@ -156,16 +156,18 @@ class ObjectSerializer
156156
/**
157157
* Take value and turn it into a string suitable for inclusion in
158158
* the parameter. If it's a string, pass through unchanged
159-
* If it's a datetime object, format it in ISO8601
159+
* If it's a datetime object, format it in RFC3339
160+
* If it's a date, format it in Y-m-d
160161
*
161162
* @param string|\DateTime $value the value of the parameter
163+
* @param string|null $format the format of the parameter
162164
*
163165
* @return string the header string
164166
*/
165-
public static function toString($value)
167+
public static function toString($value, $format = null)
166168
{
167-
if ($value instanceof \DateTime) { // datetime in ISO8601 format
168-
return $value->format(\DateTime::ATOM);
169+
if ($value instanceof \DateTime) {
170+
return ($format === 'date') ? $value->format('Y-m-d') : $value->format(\DateTime::ATOM);
169171
} else {
170172
return $value;
171173
}

src/main/resources/handlebars/php/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ use {{invokerPackage}}\ObjectSerializer;
361361
}
362362
{{/collectionFormat}}
363363
if (${{paramName}} !== null) {
364-
$queryParams['{{baseName}}'] = ObjectSerializer::toQueryValue(${{paramName}});
364+
$queryParams['{{baseName}}'] = ObjectSerializer::toQueryValue(${{paramName}}, {{#dataFormat}}'{{{dataFormat}}}'{{/dataFormat}}{{^dataFormat}}null{{/dataFormat}});
365365
}
366366
{{/queryParams}}
367367
{{#headerParams}}

0 commit comments

Comments
 (0)