Forum Discussion

Bhushan-Chandra's avatar
Bhushan-Chandra
Occasional Contributor
7 months ago

How to generate primitive types instead of wrapper classes.

How to generate primitive types instead of wrapper classes. "type: boolean" is generating wrapper class variable instead of primitive type.

  • christyhernand's avatar
    christyhernand
    Occasional Visitor

    Hello Bhushan-Chandra ,


    I'd be glad to provide a comprehensive response on generating primitive types instead of wrapper classes in Swagger Codegen, combining the best aspects of previous responses and addressing potential issues.
    Utilize the primitive option within the x-codegen-java extension.
    Use the model_behavior option with the value primitive within the x-swagger-code-gen extension.
    Consult the official Swagger Codegen documentation for your target language to determine if it supports a similar language-specific option for generating primitive types.
    f language-specific options aren't available or don't work as expected, consider modifying the code generation templates. However, this approach requires more technical expertise and caution: Locate the template file responsible for generating model classes in your chosen language. Identify the logic for type conversion and modify it to produce primitive types instead of wrapper classes for specified properties.

    Best Regards,
    NYStateofHealth