swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.97k stars 6.04k forks source link

Could not generate model Category #7677

Open mhoffman78 opened 6 years ago

mhoffman78 commented 6 years ago
Description

Trying to run a Service First approach to generate YAML from a simple POJO. Please see the attached stacktrace

Swagger-codegen version

3.0.0-rc

Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
webron commented 6 years ago

There's no attached anything...

mhoffman78 commented 6 years ago

swagger-error

webron commented 6 years ago

You really need to provide more details, like the process you've taken and your API definition in order for us to try and reproduce and solved it.

mhoffman78 commented 6 years ago

I am trying to execute the following code from Gradle - I am not sure if I am missing a config file? It looks to be throwing the error on DefaultGenerator's generateModels() via the generate() method.

`import io.swagger.codegen.config.CodegenConfigurator import io.swagger.codegen.DefaultGenerator

def swaggerInput = "${rootDir}/petstore.json" def securityDefinition = "${rootDir}/securityDefinition.json" def swaggerOutputDir = file('build/swagger') task generateApi { inputs.file(swaggerInput) outputs.dir(swaggerOutputDir) doLast { def config = new CodegenConfigurator() config.setInputSpec(swaggerInput) config.setOutputDir("${project.buildDir.path}") config.setLang('java') config.setTemplateDir("${rootDir}") config.setAdditionalProperties([ 'interfaceOnly' : 'true', 'apiPackage' : 'io.swagger.petstore.client.api', 'dateLibrary' : 'java8', 'sourceFolder' : 'src/generated/java' ]) //config.setAuth(securityDefinition); config.setImportMappings([ 'Dog': 'io.swagger.petstore.client.model.Dog' ]) println 'Here1' println config.getAuth() def test = new DefaultGenerator(); println 'Here2' println config.getTemplateDir() test.opts(config.toClientOptInput()); println 'Here3' test.generate(); } }`