Swagger-codegen: [csharp] Allow additional-properties to set Assembly Info

Created on 18 Jun 2016  路  6Comments  路  Source: swagger-api/swagger-codegen

Description

These lines of code, https://github.com/swagger-api/swagger-codegen/blob/v2.1.6/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java#L142-L146 , sets the values of:

  • packageTitle
  • packageProductName
  • packageDescription
  • packageCompany
  • packageCopyright

This means they have the same values for every CSharp client generated.

We want to be able to set these values via additional-properties on command line generation.

Swagger-codegen version

https://github.com/swagger-api/swagger-codegen/tree/v2.1.6

Related issues

https://github.com/swagger-api/swagger-codegen/issues/1797

Suggest a Fix

For each of the following:

  • packageTitle
  • packageProductName
  • packageDescription
  • packageCompany
  • packageCopyright

Add a check to see if a value has been specified in the additional-properties, e.g.:

if (!additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
            additionalProperties.put("packageTitle", this.packageTitle);
}
C-Sharp General help wanted

All 6 comments

@RowanJKWalker Thanks for providing this feedback.

One clarification:

CodegenConstants.PACKAGE_NAME is the namespace while packageTitle is the assembly's title which would display in DLL properties, these aren't the same thing. From AssemblyTitleAttribute Class:

Specifies a description for an assembly.

While there's no steadfast rule that these _can't_ be the same, it would be restrictive to make them the same.

This should be a relatively simply fix, so I'll start on it today.

@RowanJKWalker actually, since this is a pretty simple fix, would you like to provide a PR?

My recommendation is to add the constants to CodegenConstants, then add the properties and their defaults to AbstractCSharpCodegen and pull/set values in processOpts like others:

// {{packageVersion}}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
    setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
} else {
    additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
}

Cool, will do. Thanks!

Here is my Pull Request for this issue

Closing this issue as Pull Request has now been merged into master.

@RowanJKWalker thanks again for the contribution.

Was this page helpful?
0 / 5 - 0 ratings