cancel
Showing results for 
Search instead for 
Did you mean: 

Generating a server code Unrecognized token 'openapi': was expecting ('true', 'false' or 'null')

SOLVED
New Contributor

Generating a server code Unrecognized token 'openapi': was expecting ('true', 'false' or 'null')

When i try generate a server code with an YAML in OpenAPI version I got the message below and i am using the command too below:

 

Command:

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i "C:\Users\migno\Google Drive\Trabalho\RumoALL\Translogic\documentacao_arquitetura\Sinistros.yaml" -l spring -DapiPackage=com.rumolog.translogic.sinistros.api -DmodelPackage=com.rumolog.translogic.sinistros.model -o gerado/server/translogic/sinistros

 

 

Message:

 

[main] INFO io.swagger.parser.Swagger20Parser - reading from C:/Users/migno/Google Drive/Trabalho/RumoALL/Translogic/documentacao_arquitetura/Sinistros.yaml
[main] INFO io.swagger.parser.Swagger20Parser - reading from C:/Users/migno/Google Drive/Trabalho/RumoALL/Translogic/documentacao_arquitetura/Sinistros.yaml
[main] ERROR io.swagger.parser.SwaggerCompatConverter - failed to read resource listing
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'openapi': was expecting ('true', 'false' or 'null')
at [Source: (String)"openapi: 3.0.0
info:
title: Translogic Sinistros
description: Tem como objetivo visualizar os sinistros ocorridos, aceitar, recusar, alterar e criar.
version: 0.0.1
contact:
name: Bruno Mignoni
email: bmignoni@grupomult.com.br
externalDocs:
description: Tem como objetivo visualizar os sinistros ocorridos, aceitar, recusar, alterar e criar.
url: https://rumolog.atlassian.net/wiki/spaces/PT/pages/628097328/UC08+-+SRO+Sinistros
tags:
- name: sinistros
description: Informa"[truncated 4022 chars]; line: 1, column: 8]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1804)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:703)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._reportInvalidToken(ReaderBasedJsonParser.java:2853)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1899)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:757)
at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4042)
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2551)
at io.swagger.parser.SwaggerCompatConverter.readResourceListing(SwaggerCompatConverter.java:210)
at io.swagger.parser.SwaggerCompatConverter.read(SwaggerCompatConverter.java:123)
at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:79)
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] WARN io.swagger.codegen.ignore.CodegenIgnoreProcessor - Output directory does not exist, or is inaccessible. No file (.swagger-codegen-ignore) will be evaluated.
Exception in thread "main" java.lang.RuntimeException: missing swagger input or config!
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:739)
at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
New Contributor

Re: Generating a server code Unrecognized token 'openapi': was expecting ('true', 'false' or 'null')

I clone the branch below and executed the maven command "mvn" in base directory.

After that, I executed the same command to generate and "swagger-codegen" worked fine

 

https://github.com/swagger-api/swagger-codegen/tree/3.0.0

2 REPLIES 2
Highlighted
New Contributor

Re: Generating a server code Unrecognized token 'openapi': was expecting ('true', 'false' or 'null')

I clone the branch below and executed the maven command "mvn" in base directory.

After that, I executed the same command to generate and "swagger-codegen" worked fine

 

https://github.com/swagger-api/swagger-codegen/tree/3.0.0

Moderator

Re: Generating a server code Unrecognized token 'openapi': was expecting ('true', 'false' or 'null')

Hi mignoni,

 

Swagger Codegen 2.x, which you initially used, only supports OpenAPI 2.0 definitions ("swagger": "2.0") and does not support OpenAPI 3.0. To generate code for OpenAPI 3.0 definitions, you need Swagger Codegen 3.x, which, as you've correctly noted, lives in the "3.0.0" branch of the swagger-codegen repository.

 

Just FYI, you can download the compiled CLI JAR from Maven Central:

http://central.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/

Here's a direct link to the latest version (3.0.8 as of this writing):
http://central.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.8/swagger-codegen-cli-...


Helen Kosova
SmartBear Technical Writer
________________________
Vote up helpful replies.
Accept this reply if you think it's the best solution to your question.
New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video