I have written an API definition in the OpenAPI 3.0 format (https://swagger.io/docs/specification/basic-structure/). Now I'm trying to generate Java Spring objects as I was previously doing with a Swagger 2.0 definition and its associated Maven plugin.
So far, I have a basic API definition that begins with:
openapi: 3.0.0
info:
title: Demo API
description: This is a basic REST API implementing the [Open API Specification](https://en.wikipedia.org/wiki/OpenAPI_Specification).
version: 0.0.1
In my pom.xml
file I have added:
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-cli</artifactId>
<version>3.3.3</version>
</dependency>
But when executing mvn install
, I get this error:
com.fasterxml.jackson.core.JsonParseException: Unrecognized
token 'openapi': was expecting ('true', 'false' or 'null')
at [Source: definition\DEFINITION.yml; line: 1, column: 9]
Does anyone know where the problem is?
After a lot for hit and try I found that issue was with my Swagger file. In that url
was not a correct URL. It was something like /api
(url without host domain).
OpenAPI generator could have given a better error message. Anyways placing some valid url, allowed me to generate the code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With