“TypeError: Failed to fetch” when making a GET request from SwaggerHub


“TypeError: Failed to fetch” when making a GET request from SwaggerHub



I have the following API definition in SwaggerHub:


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'



I cannot make this basic GET command to bring back the data I'm seeking. It only returns this:



TypeError: Failed to fetch



I'm unsure if it's a syntax issue, or possibly spacing, but I'm also getting an error for line 19 that reads:



should NOT have additional properties
additionalProperty: responseSchema, description, schema



Any ideas what is wrong?





What tool do you use to make the API calls? Swagger Editor/Swagger UI?
– Helen
Jun 28 at 19:10





I'm using both through SwaggerHub. It's a split display.
– K. Davis
Jun 29 at 11:35





1 Answer
1



https://swapi.co seems to be HTTPS-only, so you need to add


schemes:
- https



to you API definition to specify the protocol for requests.






but I'm also getting an error for line 19 that reads: "should NOT have additional properties additionalProperty: responseSchema, description, schema".



Remove these lines:


responseSchema:
$ref: '#/definitions/Model0'



There's no responseSchema keyword in OpenAPI.


responseSchema






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Possible Unhandled Promise Rejection (id: 0): ReferenceError: user is not defined ReferenceError: user is not defined