go-swagger在windows系统上使用yaml生成server代码

1.环境配置

下载这个

https://github.com/go-swagger/go-swagger/releases/download/v0.29.0/swagger_windows_amd64.exe

2.解压出来以后 放到 Go的安装根目录 $GOROOT/bin
3.写yaml文件 规则参考这个
https://www.it610.com/article...
4.swagger generate server -f pkg/swagger/swagger.yaml -t ./pkg -A servername

swagger: "2.0"
info:
  description: Model Factory Service
  version: 1.0.0
  title: mf-server
host: gateway.mlss.mf
basePath: /
schemes:
  - http
consumes:
  - application/json
  - application/octet-stream
  - text/plain; charset=utf-8
produces:
  - application/json
  - application/octet-stream
  - text/plain; charset=utf-8
paths:
  /mf/v1/services:
    get:
      summary: 服务列表接口。
      description: (v1.20.0) Get Services list.
      tags:
        - modelDeploy
      operationId: listServices.
      parameters:
        - name: page
          in: query
          description: 分页参数,页码.
          required: false
          type: integer
          format: int
        - name: size
          in: query
          description: 分页参数,每页行数。
          required: false
          type: integer
          format: int
        - name: service_name
          in: query
          required: false
          type: string
          description: 模型服务名称。
        - name: service_global_id
          in: query
          required: false
          type: string
          description: 模型服务全局ID
        - name: department_id
          in: query
          required: false
          type: integer
          description: 模型归属用户组的部门ID。
        - name: department_name
          in: query
          required: false
          type: string
          description: 模型归属用户组的部门名称。
        - name: group_name
          in: query
          required: false
          type: string
          description: 模型用户组名称。
        - name: group_id
          in: query
          required: false
          type: number
          format: int64
          description: 模型用户组id。
        - name: model_name
          in: query
          required: false
          type: string
          description: 模型服务关联的模型名称。
        - name: version
          in: query
          required: false
          type: string
          description: 模型服务关联的模型版本号。
        - name: idc
          in: query
          required: false
          type: string
          description: 模型服务容器实例的IDC。
        - name: dcn
          in: query
          required: false
          type: string
          description: 模型服务容器实例的DCN。
        - name: query_str
          in: query
          required: false
          type: string
          description: MLSS内部使用,模糊查询参数
        - name: cluster
          in: query
          required: false
          type: string
          description: MLSS内部使用,集群参数
        - name: namespace
          in: query
          required: false
          type: string
          description: MLSS内部使用,命名空间参数
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/ServicesGetResponse'
        401:
          description: Unauthorized
          schema:
            $ref: '#/definitions/Error'
        404:
          description: The Models cannot be found
          schema:
            $ref: '#/definitions/Error'

5.就能生成代码了

你可能感兴趣的:(swaggergo)