Giter VIP home page Giter VIP logo

springmvc2swagger's Introduction

springmvc2swagger

springmvc2swagger is a tool that can convert springMVC annotations and javadoc to Swagger documents

Plugin insstall

https://plugins.jetbrains.com/plugin/15095-springmvc2swagger

Demo

Java Sources

@RequestMapping("user")
@RestController
public class UserController {


    /**
     * Get user information based on the user ID.
     *
     * @param id t
     * @return User
     */
    @GetMapping("{id}")
    public User user(@PathVariable("id") Long id) {
        return new User();
    }


    @Data
    public static class User {

        /**
         * user id 
         */
        private Long id;

        /**
         * login name.
         */
        @NotNull
        private String username;

        /**
         * About this user.
         */
        private String about;

    }
}

Convert to SwaggerDoc

{
  "swagger" : "2.0",
  "info" : {
    "description" : "",
    "version" : "1.0.0",
    "title" : "Api Documentation"
  },
  "host" : "localhost",
  "basePath" : "/",
  "tags" : [ {
    "name" : "UserController"
  } ],
  "schemes" : [ "http", "https" ],
  "paths" : {
    "/user/{id}" : {
      "get" : {
        "tags" : [ "UserController" ],
        "summary" : "Get user information based on the user ID.",
        "operationId" : "user",
        "parameters" : [ {
          "name" : "id",
          "in" : "path",
          "description" : "t",
          "required" : true,
          "type" : "integer",
          "format" : "int64"
        } ],
        "responses" : {
          "200" : {
            "description" : "User",
            "schema" : {
              "$ref" : "#/definitions/User"
            }
          }
        },
        "security" : [ {
          "api_key" : [ ]
        } ]
      }
    }
  },
  "securityDefinitions" : {
    "api_key" : {
      "type" : "apiKey",
      "name" : "Authorization",
      "in" : "header"
    }
  },
  "definitions" : {
    "User" : {
      "required" : [ "username" ],
      "properties" : {
        "about" : {
          "type" : "string",
          "description" : "About this user."
        },
        "id" : {
          "type" : "integer",
          "format" : "int64",
          "description" : "user id"
        },
        "username" : {
          "type" : "string",
          "description" : "login name."
        }
      }
    }
  }
}

image image image image image

springboot

You can generate the file to a static directory, and then launch the springboot service to access http://localhost:80 image image image image image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.