[csharp] fixes for netstandard (json serializing and project files) (#5590)

This commit is contained in:
Voydz 2017-05-10 09:24:43 +02:00 committed by wing328
parent fd3cae6c4b
commit 5a257a0558
9 changed files with 41 additions and 12 deletions

View File

@ -122,6 +122,10 @@ namespace {{packageName}}.Client
String contentType)
{
var request = new RestRequest(path, method);
{{#netStandard}}
// disable ResetSharp.Portable built-in serialization
request.Serializer = null;
{{/netStandard}}
// add path parameter, if any
foreach(var param in pathParams)
@ -161,11 +165,21 @@ namespace {{packageName}}.Client
{
if (postBody.GetType() == typeof(String))
{
{{#netStandard}}
request.AddParameter(new Parameter { Value = postBody, Type = ParameterType.RequestBody, ContentType = "application/json" });
{{/netStandard}}
{{^netStandard}}
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
{{/netStandard}}
}
else if (postBody.GetType() == typeof(byte[]))
{
{{#netStandard}}
request.AddParameter(new Parameter { Value = postBody, Type = ParameterType.RequestBody, ContentType = contentType });
{{/netStandard}}
{{^netStandard}}
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
{{/netStandard}}
}
}

View File

@ -88,7 +88,10 @@
{{/netStandard}}
</ItemGroup>
<ItemGroup>
<Compile Include="**\*.cs"/>
<Compile Include="Api\**\*.cs"/>
<Compile Include="Client\**\*.cs"/>
<Compile Include="Model\**\*.cs"/>
<Compile Include="Properties\**\*.cs"/>
</ItemGroup>
{{^netStandard}}
<ItemGroup>

View File

@ -239,7 +239,6 @@ namespace IO.Swagger.Api
if (exception != null) throw exception;
}
return new ApiResponse<Object>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
@ -306,7 +305,6 @@ namespace IO.Swagger.Api
if (exception != null) throw exception;
}
return new ApiResponse<Object>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);

View File

@ -62,7 +62,10 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
</ItemGroup>
<ItemGroup>
<Compile Include="**\*.cs"/>
<Compile Include="Api\**\*.cs"/>
<Compile Include="Client\**\*.cs"/>
<Compile Include="Model\**\*.cs"/>
<Compile Include="Properties\**\*.cs"/>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@ -62,7 +62,10 @@ Contact: apiteam@swagger.io
</ItemGroup>
<ItemGroup>
<Compile Include="**\*.cs"/>
<Compile Include="Api\**\*.cs"/>
<Compile Include="Client\**\*.cs"/>
<Compile Include="Model\**\*.cs"/>
<Compile Include="Properties\**\*.cs"/>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@ -115,6 +115,8 @@ namespace IO.Swagger.Client
String contentType)
{
var request = new RestRequest(path, method);
// disable ResetSharp.Portable built-in serialization
request.Serializer = null;
// add path parameter, if any
foreach(var param in pathParams)
@ -142,11 +144,11 @@ namespace IO.Swagger.Client
{
if (postBody.GetType() == typeof(String))
{
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
request.AddParameter(new Parameter { Value = postBody, Type = ParameterType.RequestBody, ContentType = "application/json" });
}
else if (postBody.GetType() == typeof(byte[]))
{
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
request.AddParameter(new Parameter { Value = postBody, Type = ParameterType.RequestBody, ContentType = contentType });
}
}

View File

@ -43,7 +43,10 @@ Contact: apiteam@swagger.io
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="**\*.cs"/>
<Compile Include="Api\**\*.cs"/>
<Compile Include="Client\**\*.cs"/>
<Compile Include="Model\**\*.cs"/>
<Compile Include="Properties\**\*.cs"/>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

View File

@ -64,7 +64,10 @@ Contact: apiteam@swagger.io
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="**\*.cs"/>
<Compile Include="Api\**\*.cs"/>
<Compile Include="Client\**\*.cs"/>
<Compile Include="Model\**\*.cs"/>
<Compile Include="Properties\**\*.cs"/>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />