forked from loafle/openapi-generator-original
[csharp] fixes for netstandard (json serializing and project files) (#5590)
This commit is contained in:
parent
fd3cae6c4b
commit
5a257a0558
@ -122,6 +122,10 @@ namespace {{packageName}}.Client
|
|||||||
String contentType)
|
String contentType)
|
||||||
{
|
{
|
||||||
var request = new RestRequest(path, method);
|
var request = new RestRequest(path, method);
|
||||||
|
{{#netStandard}}
|
||||||
|
// disable ResetSharp.Portable built-in serialization
|
||||||
|
request.Serializer = null;
|
||||||
|
{{/netStandard}}
|
||||||
|
|
||||||
// add path parameter, if any
|
// add path parameter, if any
|
||||||
foreach(var param in pathParams)
|
foreach(var param in pathParams)
|
||||||
@ -161,11 +165,21 @@ namespace {{packageName}}.Client
|
|||||||
{
|
{
|
||||||
if (postBody.GetType() == typeof(String))
|
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);
|
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||||
|
{{/netStandard}}
|
||||||
}
|
}
|
||||||
else if (postBody.GetType() == typeof(byte[]))
|
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);
|
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
|
||||||
|
{{/netStandard}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,10 @@
|
|||||||
{{/netStandard}}
|
{{/netStandard}}
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="Api\**\*.cs"/>
|
||||||
|
<Compile Include="Client\**\*.cs"/>
|
||||||
|
<Compile Include="Model\**\*.cs"/>
|
||||||
|
<Compile Include="Properties\**\*.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
{{^netStandard}}
|
{{^netStandard}}
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -239,7 +239,6 @@ namespace IO.Swagger.Api
|
|||||||
if (exception != null) throw exception;
|
if (exception != null) throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new ApiResponse<Object>(localVarStatusCode,
|
return new ApiResponse<Object>(localVarStatusCode,
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||||
null);
|
null);
|
||||||
@ -306,7 +305,6 @@ namespace IO.Swagger.Api
|
|||||||
if (exception != null) throw exception;
|
if (exception != null) throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new ApiResponse<Object>(localVarStatusCode,
|
return new ApiResponse<Object>(localVarStatusCode,
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||||
null);
|
null);
|
||||||
|
@ -62,7 +62,10 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
|
|||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="Api\**\*.cs"/>
|
||||||
|
<Compile Include="Client\**\*.cs"/>
|
||||||
|
<Compile Include="Model\**\*.cs"/>
|
||||||
|
<Compile Include="Properties\**\*.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
@ -62,7 +62,10 @@ Contact: apiteam@swagger.io
|
|||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="Api\**\*.cs"/>
|
||||||
|
<Compile Include="Client\**\*.cs"/>
|
||||||
|
<Compile Include="Model\**\*.cs"/>
|
||||||
|
<Compile Include="Properties\**\*.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
@ -115,6 +115,8 @@ namespace IO.Swagger.Client
|
|||||||
String contentType)
|
String contentType)
|
||||||
{
|
{
|
||||||
var request = new RestRequest(path, method);
|
var request = new RestRequest(path, method);
|
||||||
|
// disable ResetSharp.Portable built-in serialization
|
||||||
|
request.Serializer = null;
|
||||||
|
|
||||||
// add path parameter, if any
|
// add path parameter, if any
|
||||||
foreach(var param in pathParams)
|
foreach(var param in pathParams)
|
||||||
@ -142,11 +144,11 @@ namespace IO.Swagger.Client
|
|||||||
{
|
{
|
||||||
if (postBody.GetType() == typeof(String))
|
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[]))
|
else if (postBody.GetType() == typeof(byte[]))
|
||||||
{
|
{
|
||||||
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
|
request.AddParameter(new Parameter { Value = postBody, Type = ParameterType.RequestBody, ContentType = contentType });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,10 @@ Contact: apiteam@swagger.io
|
|||||||
<None Include="project.json" />
|
<None Include="project.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="Api\**\*.cs"/>
|
||||||
|
<Compile Include="Client\**\*.cs"/>
|
||||||
|
<Compile Include="Model\**\*.cs"/>
|
||||||
|
<Compile Include="Properties\**\*.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
@ -64,7 +64,10 @@ Contact: apiteam@swagger.io
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="Api\**\*.cs"/>
|
||||||
|
<Compile Include="Client\**\*.cs"/>
|
||||||
|
<Compile Include="Model\**\*.cs"/>
|
||||||
|
<Compile Include="Properties\**\*.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user