我在SwaggerHub中具有以下API定义:
swagger: '2.0'
info:
description: defaultDescription
version: '0.1'
title: defaultTitle
host: swapi.co
paths:
/api/people:
get:
produces:
- application/json
parameters:
- name: search
in: query
required: false
type: string
x-example: luke
responses:
'200':
description: Definition generated from Swagger Inspector
schema:
$ref: '#/definitions/Model0'
responseSchema:
$ref: '#/definitions/Model0'
definitions:
Results:
properties:
name:
type: string
height:
type: string
mass:
type: string
hair_color:
type: string
skin_color:
type: string
eye_color:
type: string
birth_year:
type: string
gender:
type: string
homeworld:
type: string
films:
type: array
items:
type: string
species:
type: array
items:
type: string
vehicles:
type: array
items:
type: string
starships:
type: array
items:
type: string
created:
type: string
edited:
type: string
url:
type: string
Model0:
properties:
count:
type: integer
format: int32
next:
type: object
previous:
type: object
results:
type: array
items:
$ref: '#/definitions/Results'
我无法执行此基本的GET命令来取回我要查找的数据。它只会返回以下内容:
TypeError:无法获取
我不确定这是语法问题还是空格问题,但我在第19行也遇到了错误,内容为:
不应具有其他属性 AdditionalProperty:responseSchema,描述,模式
有什么想法吗?
答案 0 :(得分:1)
https://swapi.co似乎仅支持HTTPS,因此您需要添加
schemes:
- https
根据您的API定义指定请求协议。
但是我在第19行也遇到了一个错误,内容为:“不应具有其他属性AdditionalProperty:responseSchema,description,schema”。
删除这些行:
responseSchema:
$ref: '#/definitions/Model0'
OpenAPI中没有responseSchema
关键字。