Search code examples
javajsonmavenswagger-codegen

swagger codegen how to create .json


I recently joined a team that are creating RESTful API. I'm a beginner to this field. My task is to create the SDK of the project. I have to use swagger-codegen for it. I am following instructions in swagger-codegen

There they are using http://petstore.swagger.io/v2/swagger.json file to build the sdk. But in my project there is no .json file available. When i build the project using mvn clean package all i get is .war files.

So what i want to know is, do i need to create .json file to build a SDK, if so how do i build it? or can i do it in any other way?

sorry for my lack of knowledge on the subject.


Solution

  • You will need to document your REST API in OpenAPI/Swagger spec 2.0 (yaml/json file) to begin with.

    You can also use plug-ins like C# Swashbuckle to automatically generate OpenAPI/Swagger spec from your RESTful backend.

    After you obtain the spec (yaml/json file), then you can use Swagger Codegen (free, open source) to generate API clients, server stubs and API documentations.

    FYI. OpenAPI 3.0 (RC) can be found in https://github.com/OAI/OpenAPI-Specification/blob/3.0.0-rc0/versions/3.0.md