Forum Discussion

oleksa's avatar
New Contributor
6 years ago

ApiClient ApiException Configuration namespaces do not match to packageName option



I'm trying to generate csharp client form petstore json OpenAPI with packageName parameter specified

However the problem is that not all generated files has packageName value from config.





are generated with default IO.Swagger.Client namespace. This is not correct I suppose

and Api\*.cs and Model\*.cs source code files are generated with custom namespace (This is correct)


I use curl command like below to generate client source code (it has to be executed using bash)


curl -H "Content-type: application/json" -X POST -d '{"options": {"packageName": "pet_store"},"swaggerUrl": ""}'

Then I download archive using url from output (


The problem is that ApiClient.cs ApiException.cs and Configuration.cs files are generated with default IO.Swagger.Client namespace however I expect that namespace value have to be set to pet_store according to parameterization.


I replace namespace manually in the generated files however it would be nice to have namespace generated as it was parameterized.

When offline swagger-codegen is used with config file it generates namepace in the same way

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i -l csharp-dotnet2 -o D:\temp\cw -c D:\temp\cw\config.json


{ "packageName" : "petT_store" } 


Is there any other option to set namespace for all generated files?



2 Replies

  • oleksa's avatar
    New Contributor

    sorry, there is clientPackage option available

    Please excuse me for inconvenience



  • Check your case again. Seems like it was fixed. I had the same issue, but I've resolved it using the config file with the offline generator a few days ago.

    java -jar swagger-codegen-cli.jar generate -i <url>swagger/docs/1.0 -l csharp -o <resultFolderPath> -c <configFolderPath>swagger-codegen-config.json

    Config file:

      "packageName": "Name.Of.Package"