swagger 简介

开发文档链接(里面有各种参数的介绍)

OpenAPI Specification - Version 3.0.3 | Swagger

在线编辑(直接在线编辑到它不报错不然空格之类的容易错,他有一个离线的版本但是那个东西不知道为啥我跑不起来报一个swagger-router找不到的错,所以我没办法就用在线编辑,编辑完了下下来就是可以用的)

Swagger Editor

简单编辑后我的yaml内容

openapi: 3.0.3
info:
  title: Swagger Petstore - OpenAPI 3.0
  description: |-
    This is a sample Pet Store Server based on the OpenAPI 3.0 specification.  You can find out more about
    Swagger at [https://swagger.io](https://swagger.io). In the third iteration of the pet store, we've switched to the design first approach!
    You can now help us improve the API whether it's by making changes to the definition itself or to the code.
    That way, with time, we can improve the API in general, and expose some of the new features in OAS3.

    _If you're looking for the Swagger 2.0/OAS 2.0 version of Petstore, then click [here](https://editor.swagger.io/?url=https://petstore.swagger.io/v2/swagger.yaml). Alternatively, you can load via the `Edit > Load Petstore OAS 2.0` menu option!_

    Some useful links:
    - [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)
    - [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
  termsOfService: http://swagger.io/terms/
  contact:
    email: apiteam@swagger.io
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.11
externalDocs:
  description: Find out more about Swagger
  url: http://swagger.io
servers:
- url: http://localhost:8080/docs
tags:
- name: myapi
  description: my own api
paths:
  /00/002/003/004:
    get:
      tags:
      - myapi
      summary: Get user by user name
      description: ""
      operationId: getmyresponse
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
            application/xml:
              schema:
                $ref: '#/components/schemas/ApiResponse'
        "400":
          description: Invalid username supplied
        "404":
          description: User not found
      x-swagger-router-controller: Myapi
components:
  schemas:
    ApiResponse:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ApiResponse_id'
      example:
        id:
          a.id: ppp
    ApiResponse_id:
      type: object
      properties:
        a.id:
          type: string
          example: ppp
      example:
        a.id: ppp

下载下来

我用的node所以下的nodeserver

npm i下依赖 npm start报错发现有一个这个

有一个方法名字有点怪,而且我没有参数就换成了get(之前是post)

方法名字也改了(记得全局搜然后都改掉)

最后不报错了但是路径不是很对要改server的url(改成控制台node start启动时你自己的url)

效果如下:

直接去访问:

response可以在这里修改:

记得要重启server然后效果如下:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值