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

Remove /t characters from swagger.yaml #166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pulse0ne
Copy link

/t (tab) characters cause problems in some versions of swagger-codegen-cli

/t (tab) characters cause problems in some versions of swagger-codegen-cli
Copy link
Member

@issmith1 issmith1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, Tyler!
What language/implementation/version of codegen causes what err?

What is your business connection with NASA's UTM? afaik I have not met you.

Irene at NASA

@pulse0ne
Copy link
Author

pulse0ne commented Jan 31, 2020

Hey Irene,
I was generating Java (spring, specifically) with swagger-codegen-cli v2.3.1. My config looks like this:

{
  "library": "spring-boot",
  "java8": "true",
  "dateLibrary": "java8",
  "modelPackage": "gov.nasa.utm.utmcommons.model",
  "useBeanValidation": "true"
}

The company I work for is exploring FIMS/UTM development. Thank you for your time!

Edited to add the error:

java -Dmodels -DmodelDocs=false -DapiDocs=false -jar swagger-codegen-cli.jar generate -v -l spring -c ./scripts/config.json -i ./utm-apis/fimsauthz-api/swagger.yaml -o ./utm-models

[main] INFO io.swagger.codegen.config.CodegenConfigurator - 
VERBOSE MODE: ON. Additional debug options are injected
 - [debugSwagger] prints the swagger specification as interpreted by the codegen
 - [debugModels] prints models passed to the template engine
 - [debugOperations] prints operations passed to the template engine
 - [debugSupportingFiles] prints additional data passed to the template engine
[main] INFO io.swagger.parser.Swagger20Parser - reading from ./utm-apis/fimsauthz-api/swagger.yaml
[main] INFO io.swagger.parser.Swagger20Parser - reading from ./utm-apis/fimsauthz-api/swagger.yaml
[main] ERROR io.swagger.parser.SwaggerCompatConverter - failed to read resource listing
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'swagger': was expecting ('true', 'false' or 'null')
 at [Source: ./utm-apis/fimsauthz-api/swagger.yaml; line: 1, column: 9]
        at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidToken(UTF8StreamJsonParser.java:3528)
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2686)
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:878)
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:772)
        at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3850)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3799)
        at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2447)
        at io.swagger.parser.SwaggerCompatConverter.readResourceListing(SwaggerCompatConverter.java:189)
        at io.swagger.parser.SwaggerCompatConverter.read(SwaggerCompatConverter.java:116)
        at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:75)
        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)
[main] INFO io.swagger.codegen.ignore.CodegenIgnoreProcessor - No .swagger-codegen-ignore file found.
Exception in thread "main" java.lang.RuntimeException: missing swagger input or config!
        at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:731)
        at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
        at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)

The error doesn't tell you much, but I tested with a more recent version of the 2.x swagger-codegen-cli (v2.4.9) and it specifically called out the \t(TAB) characters as the cause of the parse error:

[main] INFO io.swagger.codegen.config.CodegenConfigurator - 
VERBOSE MODE: ON. Additional debug options are injected
 - [debugSwagger] prints the swagger specification as interpreted by the codegen
 - [debugModels] prints models passed to the template engine
 - [debugOperations] prints operations passed to the template engine
 - [debugSupportingFiles] prints additional data passed to the template engine
[main] INFO io.swagger.parser.Swagger20Parser - reading from ./utm-apis/fimsauthz-api/swagger.yaml
[main] WARN 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:524)
        at org.yaml.snakeyaml.Yaml.load(Yaml.java:437)
        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: while scanning for the next token
found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)
 in 'string', line 85, column 13:
                           # See https://github.com/OAI ... 
                ^

....remainder elided...

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

Successfully merging this pull request may close these issues.

2 participants