I am learning to use swagger code gen to generate a bunch of csharp files from swagger.json file.
In the CSharpClientCodeGen.class , I noticed there are variables for apiPackage and modelPackage that generates the Api and Model cs files in them. I would like to create a new package similar to apiPackage and modelPackage.
I tried adding in the following code
public class csharpcodegen extends CSharpClientCodeGen
{
protected String newPackage="IO.Swagger.New";
}
And then built the client code, but I dont see the new package folder in there.
Not sure how to do this. It would be great if you can point me to resources on how to do this.
Thanks
If you want to customize the package name, you can pass a config file (e.g. config.json) to the swagger-codegen. Here is a full list of configuration option available for C# code generator:
swagger-codegen|master⚡ ⇒ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l csharp
CONFIG OPTIONS
packageName
C# package name (convention: Camel.Case), default: IO.Swagger
packageVersion
C# package version, default: 1.0.0
For example, to generate C# SDK, prepare the config file as follows
{
"packageName": "Com.RestUnited",
}
Then run the following command:
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i /var/tmp/swagger_spec.yaml \
-l csharp \
-o /var/tmp/csharp/test/ \
-c /var/tmp/csharp.json
To request for new option on customizing the C# SDK, please submit via the Github page