Repository navigation
Open
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
Generated a client using csharp-refactor and it doesn't build in .NET Core. Getting following errors:
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restoring packages for /Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj...
Installing Newtonsoft.Json 12.0.1.
Installing JsonSubTypes 1.5.1.
Generating MSBuild file /Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/obj/Org.OpenAPITools.csproj.nuget.g.props.
Generating MSBuild file /Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/obj/Org.OpenAPITools.csproj.nuget.g.targets.
Restore completed in 3.26 sec for /Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj.
Api/ActivitiesApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/CalculationsApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/CategoriesApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/CountriesApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/HealthCheckApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/ImportsApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/ItemsApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/ItemSelectorsApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/PriceListsApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Client/ApiClient.cs(35,48): error CS0234: The type or namespace name 'Serializers' does not exist in the namespace 'RestSharp' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Client/ApiClient.cs(35,83): error CS0234: The type or namespace name 'Deserializers' does not exist in the namespace 'RestSharp' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Build FAILED.
Api/ActivitiesApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/CalculationsApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/CategoriesApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/CountriesApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/HealthCheckApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/ImportsApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/ItemsApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/ItemSelectorsApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Api/PriceListsApi.cs(17,18): error CS0234: The type or namespace name 'Mime' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Client/ApiClient.cs(35,48): error CS0234: The type or namespace name 'Serializers' does not exist in the namespace 'RestSharp' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
Client/ApiClient.cs(35,83): error CS0234: The type or namespace name 'Deserializers' does not exist in the namespace 'RestSharp' (are you missing an assembly reference?) [/Users/i52017/dev/openapi-gen/output/src/Org.OpenAPITools/Org.OpenAPITools.csproj]
0 Warning(s)
11 Error(s)
Time Elapsed 00:00:04.35
openapi-generator version
4.0.0-beta
OpenAPI declaration file content or url
https://api.xactprm.com/pricing/swagger/current/swagger.json
Command line used for generation
openapi-generator generate -i swagger.json -g csharp-refactor -c config.json -o output
Config file:
{
"targetFramework": "v5.0",
"netCoreProjectFile": true
}
Steps to reproduce
- Generate code
cd outputdotnet build
Activity
auto-labeler commentedon Jan 29, 2019
👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
wing328 commentedon Jan 29, 2019
cc @jimschubert who refactored the csharp client generator
jimschubert commentedon Jan 29, 2019
Thanks, this is most likely just missing a reference
MathieuNls commentedon Jan 29, 2019
We are experiencing this too.
nlaveck commentedon Feb 13, 2019
This is a lot more than a missing package.
There's references to stuff that's not included with
FubarCoder.RestSharp.Portable.Core(RestSharp.Serializers, RestSharp.Deserializers)I'm not sure if this is fixable in NetStandard 1.3 since RestSharp doesn't support it. Maybe it would be better to just take v5.0 out of the supported frameworks for csharp-refactor and add support for NetStandard 2.0 later?
jimschubert commentedon Feb 13, 2019
@nlaveck By dependency, I did mean missing types. In the past, we have been able to workaround similar issues by adding or updating a dependency. We are at a little bit of a disadvantage by using RestSharp. It only supports .NET 4.5.2 and netstandard 2.0, and the Portable version doesn't have the same API in many cases.
The
v5.0option is confusing as it refers to PCL 5.0 and doesn't really relate to .NET Standard, aside from maybe being an early attempt at standardization.In addition to these things, the generator isn't only used for the built-in templates as many people extend the templates and will need support for the other options.
I have a branch where I'm working through some of these things. I'll be targeting removal of PCL and UWP support, since users and refer to openapi-generator 3.3.4 if these are needed. I just need to figure a way to expose warnings when users are targeting built-in templates wuth options that aren't supported because of our dependency on RestSharp.
My long-term goal is to remove RestSharp and possibly all third-party dependencies, allowing the templates to be generic enough to support all framework (or netstandard) versions targeted by the generator.
chrisdrobison commentedon Feb 13, 2019
Removing RestSharp would be a wonderful move.
jimschubert commentedon Feb 17, 2019
I worked on the csharp-refactor modifications, and after discussion with others... I'm thinking about repurposing the csharp-refactor generator to be .NET Standard and .NET Core App only. This will address many of my concerns that lead to refactoring.
It'll mean that if users want the client abstractions that I introduced in
csharp-refactorto enable replacing RestSharp with a user implementation, then those changes would need to be ported over to that generator and modified to support RestSharp Portable.I have my changes on the
csharp-refactor-improvementsbranch, with build/test working for netstandard2.0 and netcoreapp2.0. I've had to change the test framework to Xunit.Feel free to evaluate that branch and provide feedback. I'll need to work out CI changes before the changes get into master.