swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
777 stars 525 forks source link

Swagger parser could not read local json files.. #767

Open praveen5330 opened 6 years ago

praveen5330 commented 6 years ago

I am trying to use swagger parser in my Spring Boot application. Below are the steps I have followed.

  1. Added dependency in Pom.xml (As mentioned in https://github.com/swagger-api/swagger-parser)
  2. Copied the swagger-Josn template to "src/main/resources/json/"
  3. I tried to load the swagger_json templates in the code as below Swagger swagger = new SwaggerParser().read("/src/main/resources/json/swagger_new.json");

When this code gets executed, the parser could not read the file. I found that the "swagger" is null.

Could any one please let me the right way to read the json from a location.

Your support will be greatly appreciated.

Thanks in advance.

ymohdriz commented 6 years ago

Hi @Praveen,

Can you please validate the swagger file in editor.swagger.io

Returns null for invalid swagger file.

Thanks, Mohammed Rizwan

praveen5330 commented 6 years ago

Hello @ymohdriz

Thanks for replying, I have verified it and it validated successfully.

I do model the apis in 'editor.swagger.io' and then down load the client version of it as a json and trying to read it through "SwaggerParser".

The way i mentioned the swagger json file path while reading is correct? or any changes required in mentioning the path of json file?.

Please suggest me.

Thanks, Praveen Reddy

praveen5330 commented 6 years ago

Hello @ymohdriz

I am using the below dependencies, but it seems like below jar are incompatible. Getting java.lang.NoClassDefFoundError: io/swagger/oas/models/PathItem.

io.swagger swagger-parser-v3 2.0.0-rc1 io.swagger.core.v3 swagger-models 2.0.2

Could you please give us the required dependencies list to use the swagger parser.

Thanks, Praveen

ymohdriz commented 6 years ago

Hi @Praveen,

Please find the dependencies for swagger-parser-v3 2.0.0.-rc1 here

Thanks, Mohammed

neelee commented 4 years ago

Hi praveen I'm also Getting java.lang.NoClassDefFoundError: io/swagger/oas/models/PathItem。 Please suggest me. Thanks, Nee