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

[JAVA] Bug generating SnakeException: Exception safe-checking yaml content but only with yaml input file. #9268

Closed
hectoralicea opened this issue Mar 14, 2019 · 6 comments

Comments

@hectoralicea
Copy link

Description

Getting SnakeException: Exception safe-checking yaml content when I run swagger-codegen generate on a particular yaml input file. It works with the equivalent converted json input file. It also generates the same code between the two formats.

[main] ERROR io.swagger.parser.util.DeserializationUtils - Error snake-parsing yaml content
io.swagger.parser.util.DeserializationUtils$SnakeException: Exception safe-checking yaml content  (maxDepth 2000)
	at io.swagger.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:300)
	at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:450)
	at org.yaml.snakeyaml.Yaml.load(Yaml.java:369)
	at io.swagger.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:137)
	at io.swagger.parser.Swagger20Parser.deserializeYaml(Swagger20Parser.java:83)
	at io.swagger.parser.Swagger20Parser.convertToSwagger(Swagger20Parser.java:125)
	at io.swagger.parser.Swagger20Parser.read(Swagger20Parser.java:109)
	at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:69)
	at io.swagger.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:431)
	at io.swagger.codegen.cmd.Generate.run(Generate.java:283)
	at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.IllegalAccessError: tried to access field org.yaml.snakeyaml.constructor.BaseConstructor.composer from class io.swagger.parser.util.DeserializationUtils$CustomSnakeYamlConstructor
	at io.swagger.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:279)
	... 10 more
Swagger-codegen version

swagger-codegen version
2.4.2

Swagger declaration file content or url

(swagger file is proprietary. Please DM me for a gist URL.)

Command line used for generation

Following is what I use to create the java generated code.

swagger-codegen generate \
  -i major-sub-agent.yaml \
  --api-package   org.rc.ecyd.major.person.api \
  --model-package org.rc.ecyd.major.person.model \
  --group-id      org.rc.ecyd.major.person \
  --artifact-id   major-sub-agent \
  --artifact-version 0.0.1-SNAPSHOT \
  -l spring \
  -o ../major-sub-agent
Steps to reproduce

get the yaml file from my gist, and run the above command.

Related issues/PRs

None that I know of.

Suggest a fix/enhancement

Handle the exception correctly.

@hectoralicea hectoralicea changed the title [JAVA] Bug generating SnakeException: Exception safe-checking yaml content but only with yaml input file. [JAVA] Bug generating SnakeException: Exception safe-checking yaml content but only with yaml input file. Mar 14, 2019
@bangdh
Copy link

bangdh commented Mar 19, 2019

I have the same problem

@mapad
Copy link

mapad commented Mar 20, 2019

I have the same problem with the yaml example file https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/yaml/petstore-expanded.yaml
This is broken in swagger-codegen v2.4.2, but it works with v2.3.1

@frantuma
Copy link
Member

#9243 fixes the reported error in latest 2.4.3-SNAPSHOT (available on sonatype snapshots repo and upcoming release). Closing ticket, please reopen if this doesn't solve your issue

@hectoralicea
Copy link
Author

will this fix #9243 also be fixed in the 3.x code branch? I believe this issue occurred in the 3.x version as well.

@frantuma
Copy link
Member

yes, by #9237

@kumarroshan
Copy link

I have upgraded dependencies as below from 2.4.2 to 2.4.4 .
io.swagger:swagger-codegen:2.4.4
io.swagger:swagger-codegen-cli:2.4.4

But , I am still getting above stacktrace errorlog.

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

No branches or pull requests

5 participants