OpenAPITools / OpenAPITools/openapi-generator

[C#] csharp client generation does not handle "sourceFolder" config setting

Open
#1,390 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: C-Sharp
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

If the source folder setting is changed via a configuration file, csharp client generation still generates some files with references to 'src'.

openapi-generator version

main

OpenAPI declaration file content or url

Not applicable. Configuration file, for -c option:

{
"sourceFolder":  "."
}

or any sourceFolder setting other than src.

Command line used for generation

java -jar openapi-generator-cli.jar generate -i swagger.json -l csharp -o ClientAPI -c .\openapi-generation-parameters.json

Steps to reproduce

Generate code. Try to build; it will fail.

Related issues/PRs

None.

Suggest a fix/enhancement

There are a significant number of .mustache files which have the literal string src instead of the {{sourceFolder}} macro; replacing these should fix the issue [not tested]:

Search "src" (12 hits in 5 files)
compile-mono.sh.mustache (2 hits)
Line 43: ${nuget_cmd} install src/{{packageName}}/packages.config -o packages;
Line 68: -recurse:'src/{{packageName}}/*.cs'
compile.mustache (2 hits)
Line 14: .\nuget.exe install src{{packageName}}\packages.config -o packages
Line 26: %CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\JsonSubTypes.dll;bin\RestSharp.dll;System.ComponentModel.DataAnnotations.dll {{#generatePropertyChanged}}/r:bin\Fody.dll;bin\PropertyChanged.Fody.dll;bin\PropertyChanged.dll{{/generatePropertyChanged}} /target:library /out:bin{{packageName}}.dll /recurse:src{{packageName}}*.cs /doc:bin{{packageName}}.xml
mono_nunit_test.mustache (3 hits)
Line 10: rm src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll 2> /dev/null
Line 15: mono nuget.exe install src/{{{packageName}}}.Test/packages.config -o packages
Line 22: mono ./packages/NUnit.Runners.2.6.4/tools/nunit-console.exe src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll
nuspec.mustache (3 hits)
Line 46: <file src="....\README.md" target="" />
Line 47: <file src="....\docs**." target="docs" />
Line 49: <file src="....\packages\Fody.1.29.4\build\portable-net+sl+win+wpa+wp\Fody.targets" target="build" />
Solution.mustache (2 hits)
Line 5: Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{packageName}}", "src{{packageName}}{{packageName}}.csproj", "{{packageGuid}}"
Line 7: {{^excludeTests}}Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{testPackageName}}", "src{{testPackageName}}{{testPackageName}}.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the five templates named in the issue: compile-mono.sh.mustache, compile.mustache, mono_nunit_test.mustache, nuspec.mustache, and Solution.mustache. Generate a C# client using a configuration file with sourceFolder set to a value other than src, then inspect the generated build files and try to build the client. Done means generated references consistently use the configured source folder and the build succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.