首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从TypeError发出GET请求时,“SwaggerHub :未能获取”

从TypeError发出GET请求时,“SwaggerHub :未能获取”
EN

Stack Overflow用户
提问于 2018-06-28 18:51:41
回答 1查看 613关注 0票数 1

我在SwaggerHub中有以下API定义:

代码语言:javascript
复制
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、description、schema

有什么不对吗?

EN

回答 1

Stack Overflow用户

发布于 2018-06-29 11:54:39

https://swapi.co似乎仅限于HTTPS,所以您需要添加

代码语言:javascript
复制
schemes:
  - https

来指定请求的协议。

但是我也收到了第19行的一个错误:“不应该有附加属性additionalProperty: responseSchema、description、schema”。

移除以下线条:

代码语言:javascript
复制
          responseSchema:
            $ref: '#/definitions/Model0'

responseSchema中没有OpenAPI关键字。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51089568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档