add swag && proto examples
This commit is contained in:
120
go/swag_example/docs/swagger.yaml
Normal file
120
go/swag_example/docs/swagger.yaml
Normal file
@@ -0,0 +1,120 @@
|
||||
basePath: /v2
|
||||
definitions:
|
||||
main.APIError:
|
||||
properties:
|
||||
createdAt:
|
||||
type: string
|
||||
errorCode:
|
||||
type: integer
|
||||
errorMessage:
|
||||
type: string
|
||||
type: object
|
||||
main.Object:
|
||||
properties:
|
||||
id:
|
||||
description: 这是一个ID
|
||||
type: integer
|
||||
name:
|
||||
description: 这是对象的名字
|
||||
type: string
|
||||
type: object
|
||||
host: petstore.swagger.io:8080
|
||||
info:
|
||||
contact:
|
||||
email: support@swagger.io
|
||||
name: API Support
|
||||
url: http://www.swagger.io/support
|
||||
description: This is a sample server Petstore server.
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
termsOfService: http://swagger.io/terms/
|
||||
title: Swagger Example API
|
||||
version: "1.0"
|
||||
paths:
|
||||
/v2/object:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: blabla...
|
||||
parameters:
|
||||
- description: Some ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
schema:
|
||||
$ref: '#/definitions/main.Object'
|
||||
"400":
|
||||
description: We need ID!!
|
||||
schema:
|
||||
$ref: '#/definitions/main.APIError'
|
||||
"404":
|
||||
description: Can not find ID
|
||||
schema:
|
||||
$ref: '#/definitions/main.APIError'
|
||||
summary: get an object
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: blabla...
|
||||
parameters:
|
||||
- description: Add Object
|
||||
in: body
|
||||
name: object
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/main.Object'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
schema:
|
||||
$ref: '#/definitions/main.Object'
|
||||
"400":
|
||||
description: We need ID!!
|
||||
schema:
|
||||
$ref: '#/definitions/main.APIError'
|
||||
"404":
|
||||
description: Can not find ID
|
||||
schema:
|
||||
$ref: '#/definitions/main.APIError'
|
||||
summary: create an object.
|
||||
/v2/object/{id}:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: get struct array by ID
|
||||
parameters:
|
||||
- description: Offset
|
||||
in: query
|
||||
name: offset
|
||||
required: true
|
||||
type: integer
|
||||
- description: Offset
|
||||
in: query
|
||||
name: limit
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
schema:
|
||||
type: string
|
||||
"400":
|
||||
description: We need ID!!
|
||||
schema:
|
||||
$ref: '#/definitions/main.APIError'
|
||||
"404":
|
||||
description: Can not find ID
|
||||
schema:
|
||||
$ref: '#/definitions/main.APIError'
|
||||
swagger: "2.0"
|
||||
Reference in New Issue
Block a user