Happy Business Starts Here

Highlighted
Zuora Support Moderator

Issue with generated C# libraries for swagger-codegen 2.3.0 and later

If you use swagger-codegen to generate a C# library from our Swagger spec, you may receive the following errors when compiling the generated library:

 

'FilterRuleParameterValues.ToJson()': no suitable method found to override

 

The name 'BaseValidate' does not exist in the current context

 

These errors occur with version 2.3.0 and later of swagger-codegen, and occur for classes that extend Dictionary (such as the FilterRuleParameterValues class).

 

You can avoid the errors by using an earlier version of swagger-codegen.

 

 

Alternative Workaround

 

The errors are caused by swagger-codegen incorrectly interpreting Swagger models that contain additionalProperties blocks. See this GitHub issue for more details.

 

Instead of using an earlier version of swagger-codegen, you can avoid the errors by modifying a local copy of the Swagger spec before running swagger-codegen. You will need to remove all additionalProperties blocks.

 

For instance, replace:

 

  FilterRuleParameterValues:
    additionalProperties:
      description: 'The following reserved key words should not be used as a parameter
        name: `AttachmentList`, `RecipientList`, `RecipientType`, `Exceptions`, `OCP_OBJECT_TYPE`,
        `OCP_OBJECT_ID`, `OCP_TRIGGER_BY`. `Include.Attachment` is a special boolean
        parameter. By specifying this parameter, you can tell a notification whose
        event type is based on Invoice to include attachments while sending emails.

        '
      type: string
    description: 'The parameter values used to configure the filter rule.

      '
    title: filterRuleParams
    type: object

 

by:

 

  FilterRuleParameterValues:
    description: 'The parameter values used to configure the filter rule.

      '
    title: filterRuleParams
    type: object

 

This workaround may affect the functionality of the generated library. Please let us know if you have any questions or concerns.