public void GenerateOperationSpec(TSObject operationSpec) { operationSpec.QuotedStringProperty("httpMethod", HttpMethod.ToString().ToUpper()); if (IsAbsoluteUrl) { operationSpec.QuotedStringProperty("baseUrl", CodeModelTS.SchemeHostAndPort); } else { operationSpec.TextProperty("baseUrl", $"{ClientReference}.baseUri"); } string path = Path; if (!string.IsNullOrEmpty(path)) { operationSpec.QuotedStringProperty("path", path); } Parameter[] logicalParameters = LogicalParameters.ToArray(); GenerateParameters(operationSpec, "urlParameters", logicalParameters.Where(p => p.Location == ParameterLocation.Path), AddSkipEncodingProperty); GenerateParameters(operationSpec, "queryParameters", logicalParameters.Where(p => p.Location == ParameterLocation.Query), (TSObject queryParameterObject, Parameter queryParameter) => { AddSkipEncodingProperty(queryParameterObject, queryParameter); if (queryParameter.CollectionFormat != CollectionFormat.None) { queryParameterObject.TextProperty("collectionFormat", $"msRest.QueryCollectionFormat.{queryParameter.CollectionFormat}"); } }); GenerateParameters(operationSpec, "headerParameters", logicalParameters.Where(p => p.Location == ParameterLocation.Header)); if (RequestBody != null) { operationSpec.Property("requestBodyMapper", requestBodyMapper => ClientModelExtensions.ConstructRequestBodyMapper(requestBodyMapper, RequestBody)); operationSpec.QuotedStringProperty("requestBodyName", RequestBody.Name); operationSpec.QuotedStringProperty("contentType", RequestContentType); } else { IEnumerable <Parameter> formDataParameters = logicalParameters.Where(p => p.Location == ParameterLocation.FormData); if (formDataParameters.Any()) { GenerateParameters(operationSpec, "formDataParameters", formDataParameters); operationSpec.QuotedStringProperty("contentType", RequestContentType); } } if (CodeModel.ShouldGenerateXmlSerialization) { operationSpec.BooleanProperty("isXML", true); } }
internal static void GenerateRequestParameter(TSObject parameterObject, ParameterTS requestParameter, ParameterTransformations parameterTransformations) { GenerateRequestParameterPath(parameterObject, requestParameter, parameterTransformations); parameterObject.Property("mapper", mapper => ClientModelExtensions.ConstructMapper(mapper, requestParameter.ModelType, requestParameter.SerializedName, requestParameter, false, false, false)); ParameterLocation location = requestParameter.Location; if (location == ParameterLocation.Path || location == ParameterLocation.Query) { AddSkipEncodingProperty(parameterObject, requestParameter); } if (location == ParameterLocation.Query) { if (requestParameter.CollectionFormat != CollectionFormat.None) { parameterObject.TextProperty("collectionFormat", $"msRest.QueryCollectionFormat.{requestParameter.CollectionFormat}"); } } }