OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.34k stars 6.46k forks source link

[BUG][csharp-netcore] Outputs unexpected warning "Invalid .NET framework version, defaulting to v4.6.1" #3686

Open douggish opened 5 years ago

douggish commented 5 years ago

Bug Report Checklist

Description

When generating a client using the csharp-netcore generator with a targetFramework of netcoreapp2.0, there is the following warning output to the console:

[main] WARN  o.o.c.languages.CSharpClientCodegen - Invalid .NET framework version, defaulting to v4.6.1
[main] INFO  o.o.c.languages.CSharpClientCodegen - Generating code for .NET Framework v4.6.1 

This seems unexpected for a few reasons:

  1. v4.6.1 is not one of the valid target frameworks listed in the documentation when running the command openapi-generator config-help -g csharp-netcore (although it is listed as the default, which is confusing):

    targetFramework
        The target .NET framework version. (Default: v4.6.1)
            netstandard1.3 - .NET Standard 1.3 compatible
            netstandard1.4 - .NET Standard 1.4 compatible
            netstandard1.5 - .NET Standard 1.5 compatible
            netstandard1.6 - .NET Standard 1.6 compatible
            netstandard2.0 - .NET Standard 2.0 compatible
            netcoreapp2.0 - .NET Core 2.0 compatible
  2. The generate command sets targetFramework=netcoreapp2.0, which is listed as a valid value in the documentation, so it isn't clear why this warning is saying the framework version is invalid.

  3. The warning indicates the logger was for the class "o.o.c.languages.CSharpClientCodegen", but the csharp-netcore generator is defined in the CSharpNetCoreClientCodegen class. I think this class is not setting up its logger correctly.

openapi-generator version

4.1.0

OpenAPI declaration file content or url

I used the test yaml here: https://github.com/OpenAPITools/openapi-generator/blob/v4.1.0/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml

Command line used for generation

openapi-generator generate -g csharp-netcore -i ./petstore-with-fake-endpoints-models-for-testing.yaml --additional-properties targetFramework=netcoreapp2.0 -o ./netcoreapp2.0

Steps to reproduce

Run the command line above and look at the console output.

Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/issues/3682

Suggest a fix
wing328 commented 3 years ago

Can you please try the latest v5.1.0 to see if it's still an issue?