【萌狼蓝天】swagger速成

相关链接

编辑器:https://editor.swagger.io/
文档:https://openapi.apifox.cn/

基础信息设置

openapi: 3.0.3
info:
  title: 后端服务接口
  description: |-
    ## 描述
    由萌狼蓝天创建
    
    
    ## 相关介绍
    `terOfServer`:服务隐私条款
    
    ## 相关连接
    
    
    
  termsOfService: https://mllt.cc
  contact:
    email: mllt9920@qq.com
  license:
    name: Apache 2.0
    url: https://mllt.cc
  version: 1.0.0
externalDocs:
  description: 萌狼蓝天的博客园
  url: https://cnblogs.com/mllt
  
servers:
  - url: https://api.mllt.cc/api/v2024

image

一个简单的例子

openapi: 3.0.3
info:
  title: 后端服务接口
  description: |-
    ## 描述
    由萌狼蓝天创建
    
    
    ## 相关介绍
    `terOfServer`:服务隐私条款
    
    ## 相关连接
    
    
    
  termsOfService: https://mllt.cc
  contact:
    email: mllt9920@qq.com
  license:
    name: Apache 2.0
    url: https://mllt.cc
  version: 1.0.0
externalDocs:
  description: 萌狼蓝天的博客园
  url: https://cnblogs.com/mllt
  
servers:
  - url: https://api.mllt.cc/api/v2024
  
  
tags:
  - name: user
    description: 用户相关接口
    externalDocs:
      description: 接口地址
      url: https://api.mllt.cc/api/user

paths:
  /user/get:
    get:
      tags:
        - 用户列表
      summary: 所有用户
      description: 获取所有的用户信息
      responses:
        '200':
          description: 成功获取所有的用户
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
            description: 获取失败,请检查前端
        '500':
            description: 获取失败,请检查后端
        '404':
            description: 获取失败,请检查后端是否正常运行,是否存在跨域问题  
  /user/add:
    post:
      tags:
        - 用户新增
      summary: 新增用户
      description: 新增一个用户
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'
      responses:
        '200':
          description: 成功新增用户
          content:
           application/json:
            schema:
              $ref: '#/components/schemas/User'
        '400':
          description: 失败,请检查前端
        '500':
          description: 失败,请检查后端
        '404':
          description: 失败,请检查后端是否正常运行,是否存在跨域问题           
  
  
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 10
        username:
          type: string
          example: 萌狼蓝天
        firstName:
          type: string
          example: 萌狼
        lastName:
          type: string
          example: 蓝天
        email:
          type: string
          example: mllt9920@qq.com
        password:
          type: string
          example: '123456'
        phone:
          type: string
          example: '13140209920'
        userStatus:
          type: integer
          description: User Status
          format: int32
          example: 1
      xml:
        name: user
  requestBodies:
    User:
      description: User对象
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/User'
        application/xml:
          schema:
            $ref: '#/components/schemas/User'
    UserArray:
      description: List of user object
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/User'

借助工具

我个人爱用apifox

apifox支持导出openapi(swagger)-json格式的文件

可以用在线工具转为yaml格式(例如:https://json2yaml.com/)
但是转换后可能会因为有一些地方有问题
比如说没设置字段type的,为null的时候,就会出问题

如果想用工具来写的话,我个人认为应该尽可能的去完整、规范的填写

看一看转后的效果

openapi: 3.0.0
info:
  title: server-system
  description: ''
  version: 1.0.0
tags:
- name: 用户相关
- name: 资讯相关
paths:
  "/users":
    get:
      summary: 用户_查询_全部
      x-apifox-folder: 用户相关
      x-apifox-status: developing
      deprecated: false
      description: 查询全部用户
      tags:
      - 用户相关
      parameters: []
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    userId:
                      type: integer
                    userNickname:
                      type: string
                    userAccount:
                      type: string
                    userPassword:
                      type: string
                    userRegTime:
                      type: string
                    userLastLoginTime:
                      type: string
                    userStatus:
                      type: integer
                    userIdentity:
                      type: string
                    remarks:
                      type: string
                  required:
                  - userId
                  - userNickname
                  - userAccount
                  - userPassword
                  - userRegTime
                  - userLastLoginTime
                  - userStatus
                  - userIdentity
                  - remarks
                  x-apifox-orders:
                  - userId
                  - userNickname
                  - userAccount
                  - userPassword
                  - userRegTime
                  - userLastLoginTime
                  - userStatus
                  - userIdentity
                  - remarks
                  x-apifox-ignore-properties: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-144831280-run
      security: []
    post:
      summary: 用户_新增
      x-apifox-folder: 用户相关
      x-apifox-status: developing
      deprecated: false
      description: ''
      tags:
      - 用户相关
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                userNickname:
                  type: string
                  description: 用户昵称
                userAccount:
                  type: string
                  description: 用户账号
                userPassword:
                  type: string
                  description: 用户密码
                userIdentity:
                  type: string
                  description: 用户身份
                remarks:
                  type: string
                  description: 备注
              required:
              - userNickname
              - userAccount
              - userPassword
              - remarks
              - userIdentity
              x-apifox-orders:
              - userNickname
              - userAccount
              - userPassword
              - userIdentity
              - remarks
              x-apifox-ignore-properties: []
            example:
              userNickname: JohnDoe
              userAccount: johndoe123
              userPassword: password123
              userIdentity: 测试员
              remarks: 测试用户
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-144847680-run
      security: []
    put:
      summary: 用户_更新
      x-apifox-folder: 用户相关
      x-apifox-status: developing
      deprecated: false
      description: ''
      tags:
      - 用户相关
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                userNickname:
                  type: string
                  description: 用户昵称
                userPassword:
                  type: string
                  description: 用户密码
                userIdentity:
                  type: string
                  description: 用户身份
                remarks:
                  type: string
                  description: 备注
                userStatus:
                  type: string
                  description: 用户状态
                userId:
                  type: string
                  description: 用户ID
                userLoginTime:
                  type: string
              required:
              - userId
              x-apifox-orders:
              - userNickname
              - userPassword
              - userIdentity
              - remarks
              - userStatus
              - userId
              - userLoginTime
              x-apifox-ignore-properties: []
            example:
              userNickname: JohnDoe
              userAccount: johndoe123
              userPassword: password123
              userIdentity: 测试员
              remarks: 测试用户
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-144895492-run
      security: []
  "/users/6":
    get:
      summary: 用户_查询_根据ID
      x-apifox-folder: 用户相关
      x-apifox-status: developing
      deprecated: false
      description: ''
      tags:
      - 用户相关
      parameters: []
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-144872718-run
      security: []
  "/users/4":
    delete:
      summary: 用户_删除_根据ID
      x-apifox-folder: 用户相关
      x-apifox-status: developing
      deprecated: false
      description: ''
      tags:
      - 用户相关
      parameters: []
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-144891769-run
      security: []
  "/users/login":
    post:
      summary: 用户_登录
      x-apifox-folder: 用户相关
      x-apifox-status: developing
      deprecated: false
      description: ''
      tags:
      - 用户相关
      parameters:
      - name: userAccount
        in: query
        description: ''
        required: false
        example: wenjun
        schema:
          type: string
      - name: userPassword
        in: query
        description: ''
        required: false
        example: '123456'
        schema:
          type: string
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-144929527-run
      security: []
  "/informationTable/all":
    get:
      summary: 资讯_查询_全部
      x-apifox-folder: 资讯相关
      x-apifox-status: developing
      deprecated: false
      description: ''
      tags:
      - 资讯相关
      parameters: []
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-145428475-run
      security: []
  "/informationTable/add":
    post:
      summary: 资讯_新增
      x-apifox-folder: 资讯相关
      x-apifox-status: developing
      deprecated: false
      description: ''
      tags:
      - 资讯相关
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                content:
                  type: string
                type:
                  type: string
                attachments:
                  type: string
                creator:
                  type: string
              x-apifox-orders:
              - title
              - content
              - type
              - attachments
              - creator
              required:
              - title
              - content
              - creator
              - attachments
              - type
              x-apifox-ignore-properties: []
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-145430645-run
      security: []
  "/informationTable/get/1":
    get:
      summary: 资讯_查询_根据ID
      x-apifox-folder: 资讯相关
      x-apifox-status: developing
      deprecated: false
      description: ''
      tags:
      - 资讯相关
      parameters: []
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-145430948-run
      security: []
  "/informationTable/update":
    put:
      summary: 资讯_更新_根据ID
      x-apifox-folder: 资讯相关
      x-apifox-status: developing
      deprecated: false
      description: ''
      tags:
      - 资讯相关
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                content:
                  type: string
                type:
                  type: string
                attachments:
                  type: string
                creator:
                  type: string
                id:
                  type: string
              x-apifox-orders:
              - title
              - content
              - type
              - attachments
              - creator
              - id
              required:
              - title
              - content
              - creator
              - attachments
              - type
              - id
              x-apifox-ignore-properties: []
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-145430958-run
      security: []
  "/informationTable/delete/2":
    delete:
      summary: 资讯_删除
      x-apifox-folder: 资讯相关
      x-apifox-status: developing
      deprecated: false
      description: 删除成功code1,当data为1时是有数据成功删除,当data为0时表示数据库根本没这条数据
      tags:
      - 资讯相关
      parameters: []
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-145431877-run
      security: []
  "/informationTable/statistics":
    get:
      summary: 资讯_数据统计
      x-apifox-folder: 资讯相关
      x-apifox-status: developing
      deprecated: false
      description: ''
      tags:
      - 资讯相关
      parameters: []
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apifox-ignore-properties: []
                x-apifox-orders: []
      x-run-in-apifox: https://apifox.com/web/project/3965777/apis/api-145432712-run
      security: []
components:
  schemas: {}
  securitySchemes: {}
servers:
- url: http://test-cn.your-api-server.com
  description: 测试环境
- url: http://localhost:8080
  description: 开发环境
- url: http://prod-cn.your-api-server.com
  description: 正式环境

image

image

个人认为还是可以的。(只是里面似乎夹带了一点apifox的私货啊,算了影响不大)

  • 7
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
4S店客户管理小程序-毕业设计,基于微信小程序+SSM+MySql开发,源码+数据库+论文答辩+毕业论文+视频演示 社会的发展和科学技术的进步,互联网技术越来越受欢迎。手机也逐渐受到广大人民群众的喜爱,也逐渐进入了每个用户的使用。手机具有便利性,速度快,效率高,成本低等优点。 因此,构建符合自己要求的操作系统是非常有意义的。 本文从管理员、用户的功能要求出发,4S店客户管理系统中的功能模块主要是实现管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理,用户客户端:首页、车展、新闻头条、我的。门店客户端:首页、车展、新闻头条、我的经过认真细致的研究,精心准备和规划,最后测试成功,系统可以正常使用。分析功能调整与4S店客户管理系统实现的实际需求相结合,讨论了微信开发者技术与后台结合java语言和MySQL数据库开发4S店客户管理系统的使用。 关键字:4S店客户管理系统小程序 微信开发者 Java技术 MySQL数据库 软件的功能: 1、开发实现4S店客户管理系统的整个系统程序; 2、管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理等。 3、用户客户端:首页、车展、新闻头条、我的 4、门店客户端:首页、车展、新闻头条、我的等相应操作; 5、基础数据管理:实现系统基本信息的添加、修改及删除等操作,并且根据需求进行交流信息的查看及回复相应操作。
现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本微信小程序医院挂号预约系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此微信小程序医院挂号预约系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的MySQL数据库进行程序开发。微信小程序医院挂号预约系统有管理员,用户两个角色。管理员功能有个人中心,用户管理,医生信息管理,医院信息管理,科室信息管理,预约信息管理,预约取消管理,留言板,系统管理。微信小程序用户可以注册登录,查看医院信息,查看医生信息,查看公告资讯,在科室信息里面进行预约,也可以取消预约。微信小程序医院挂号预约系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

萌狼蓝天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值