Home » Java » java – Swagger codegen generate too long string literals-Exceptionshub

java – Swagger codegen generate too long string literals-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment


I need to generate classes based on provided swagger file. Unfortunately I have no influence on content of this file.

My config in gladle looks like:

task generateApi {
doLast {
    def config = new CodegenConfigurator()
            'interfaceOnly'       : true,
            'apiPackage'          : 'somepackage',
            'modelPackage'        : 'somepackage.domain',
            'sourceFolder'        : '',
            'java8'               : true,
            'dateLibrary'         : 'java8',
            'skipDefaultInterface': true
    new DefaultGenerator().opts(config.toClientOptInput()).generate()

Exception which I`m getting is : “error: constant string too long”

Problem is that even I set ‘skipDefaultInterface’, swagger will generates it. In default interface it generates default response entity body which is json file which is 70k char long string.

Please help!

How to&Answers:

Looks like this is a known issue with the spring generator in Swagger Codegen:

A PR for this issue is available but not yet merged (as of February 2020):

Try using openapi-generator v. 4.2.2 or later which is supposed to include a similar fix.