Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several clients break due to model 'break' #3846

Closed
karussell opened this issue Sep 22, 2016 · 7 comments
Closed

Several clients break due to model 'break' #3846

karussell opened this issue Sep 22, 2016 · 7 comments

Comments

@karussell
Copy link
Contributor

Description

For two clients Sinatra&Dart I get a problem that model 'break' is not allowed, but e.g. Java, .Net or Python just renames break to ModelBreak. E.g.

Exception in thread "main" java.lang.RuntimeException: Could not process model 'Break'.Please make sure that your schema is correct!
        at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:297)
        at io.swagger.codegen.cmd.Generate.run(Generate.java:223)
        at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)
Caused by: java.lang.RuntimeException: Break (reserved word) cannot be used as a model name
        at io.swagger.codegen.languages.SinatraServerCodegen.toModelName(SinatraServerCodegen.java:185)

Exception in thread "main" java.lang.RuntimeException: Could not process model 'Vehicle'.Please make sure that your schema is correct!
        at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:297)
        at io.swagger.codegen.cmd.Generate.run(Generate.java:223)
        at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)
Caused by: java.lang.RuntimeException: Break (reserved word) cannot be used as a model name
        at io.swagger.codegen.languages.DartClientCodegen.toModelName(DartClientCodegen.java:212)
        at io.swagger.codegen.languages.DartClientCodegen.getSwaggerType(DartClientCodegen.java:267)
Swagger-codegen version

swagger-codegen-cli-2.2.1.jar

Swagger declaration file content or url

https://graphhopper.com/api/1/vrp/swagger.json

Command line used for generation

https://github.com/graphhopper/directions-api-clients-route-optimization/blob/master/create.sh

Steps to reproduce
git clone https://github.com/graphhopper/directions-api-clients-route-optimization
cd directions-api-clients-route-optimization
./create.sh
@wing328
Copy link
Contributor

wing328 commented Sep 23, 2016

@karussell thanks for reporting the issue.

Would you have time to apply the same fix to Sinatra and Dart generator:

// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + underscore(dropDots("model_" + name)));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}

@karussell
Copy link
Contributor Author

Sorry, lack of time and skills in this language area :/

@wing328
Copy link
Contributor

wing328 commented Oct 18, 2016

Fixed via #4023. Please pull the latest master to give it a try.

@wing328 wing328 closed this as completed Oct 18, 2016
@karussell
Copy link
Contributor Author

Thanks a lot!

For dart it works but for sinatra I get an exception although it says 'renamed to ModelBreak':

java -jar swagger-codegen-cli-master.jar generate -i https://graphhopper.com/api/1/vrp/swagger.json -l sinatra -o ./sinatra
[main] INFO io.swagger.parser.Swagger20Parser - reading from https://graphhopper.com/api/1/vrp/swagger.json
[main] WARN io.swagger.codegen.languages.SinatraServerCodegen - Break (reserved word) cannot be used as model filename. Renamed to ModelBreak
Exception in thread "main" java.lang.RuntimeException: Could not process model 'Break'.Please make sure that your schema is correct!
        at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:298)
        at io.swagger.codegen.cmd.Generate.run(Generate.java:223)
        at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:41)
Caused by: java.lang.RuntimeException: Break (reserved word) cannot be used as a model name
        at io.swagger.codegen.languages.SinatraServerCodegen.toModelFilename(SinatraServerCodegen.java:198)
        at io.swagger.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1214)
        at io.swagger.codegen.DefaultGenerator.processModels(DefaultGenerator.java:887)
        at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:291)
        ... 2 more

@wing328
Copy link
Contributor

wing328 commented Oct 18, 2016

@karussell sorry I forgot to commit the remaining change. #4024 should fix it (will merge it after passing the CI tests)

@wing328
Copy link
Contributor

wing328 commented Oct 18, 2016

#4024 merged into master. Please kindly give it another try.

Sorry for the inconvenience caused.

@karussell
Copy link
Contributor Author

I highly appreciate your work&time! (btw: no need to sorry :)!)
This works now and have added two new languages for our API clients - nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants