Swagger codegen generate too long string literals

不打扰是莪最后的温柔 提交于 2021-01-28 05:21:43

问题


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()
    config.setInputSpec("file:///$projectDir/$swaggerSourceFile")
    config.setOutputDir("$projectDir/$swaggerTargetFolder")
    config.setLang('spring')
    config.setAdditionalProperties([
            '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!


回答1:


Looks like this is a known issue with the spring generator in Swagger Codegen:
https://github.com/swagger-api/swagger-codegen/issues/9055

A PR for this issue is available but not yet merged (as of February 2020):
https://github.com/swagger-api/swagger-codegen/pull/8691


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



来源:https://stackoverflow.com/questions/60281401/swagger-codegen-generate-too-long-string-literals

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!