Swagger JSON模式对象的确定性版本
我正在尝试使用为我的API创建自定义JSON/YAML。基本上,我想用Swagger JSON模式对象的确定性版本,swagger,swagger-2.0,swagger-editor,Swagger,Swagger 2.0,Swagger Editor,我正在尝试使用为我的API创建自定义JSON/YAML。基本上,我想用Accept和Content-Type标题描述对端点的POST请求,并以JSON的形式发布数据,如以下模板{“document”:“一些文本段落”,“documentType”:“text/plain”}所示 这是我的swagger.yml文件 swagger: '2.0' info: title: Random title description: Blah blah version: 1.2.3 host: e
Accept
和Content-Type
标题描述对端点的POST请求,并以JSON的形式发布数据,如以下模板{“document”:“一些文本段落”,“documentType”:“text/plain”}
所示
这是我的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
我做错了什么?我已经找到了这个问题的症结所在。以下是绝对有效且有效的JSON
"definitions": {
"ServiceRequest": {
"type": "object",
"description": "Payload data to be sent with request. Format: JSON",
"required": [
"documentType",
"document"
],
"properties": {
"documentType": {
"type": "string",
"default": "text/plain"
},
"document": {
"type": "string",
"default": "Your text here"
}
}
}
}
生成正确的卷曲请求。等等,什么是错误?我忘了输入
required
字段,这就是编辑器给出错误的原因