问题
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