2
我正在嘗試使用Swagger Editor爲我的API創建自定義JSON/YAML。基本上我想描述一個POST請求到Accept
和Content-Type
標題和JSON形式的POST數據,如下面的模板{"document": "Some text paragraph", "documentType": "text/plain"}
。JSON模式對象的確定版本
這是我swagger.yml文件
swagger: '2.0'
info:
title: Random title
description: Blah blah
version: 1.2.3
host: endpoint.com
schemes:
- https
securityDefinitions:
basicAuth:
type: basic
description: HTTP Basic Authentication.
basePath: /v1
paths:
'/{pipelineID}':
parameters:
- $ref: '#/parameters/pipelineID'
post:
summary: Hello world
description: World hello
security:
- basicAuth: []
consumes:
- application/json
produces:
- application/json
tags:
- TextAnnotation
parameters:
- name: body
in: body
description: JSON
required: true
schema:
- $ref: "#/definitions/json"
- name: Accept
in: header
required: true
- name: Content-Type
in: header
required: true
responses:
'200':
description: OK
'400':
description: Bad request
'401':
description: Unauthorized
'500':
description: Internal Server Error
parameters:
pipelineID:
name: pipelineID
description: Pipeline ID
in: path
type: string
required: true
definitions:
json:
- type: ServiceRequest
properties:
- "document":
- type: string
"documentType":
- type: string
揚鞭編輯的錯誤:
Swagger Error
A deterministic version of a JSON Schema object.
Jump to line 59
59行是定義開始,更具體地說,json
我在做什麼錯?
等等,這是什麼? – doub1ejack
我忘了放置'required'字段,這就是編輯給出錯誤的原因 –