共计 1965 个字符,预计需要花费 5 分钟才能阅读完成。
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. 就能生成代码了
正文完