我正在创建一个简单的get / post api,当我使用post方法时我得到“找不到ERROR服务器或发生错误”,即使我从POSTMAN或chrome运行它(我已经安装了CORS Toggle扩展) )
我的服务器正在运行:http://localhost:10010
我的规格:
swagger: "2.0"
info:
version: "0.0.1"
title: Todo API
# during dev, should point to your local machine
host: localhost:10010
# basePath prefixes all resource paths
basePath: /
#
schemes:
# tip: remove http to make production-grade
- http
- https
# format of bodies a client can send (Content-Type)
consumes:
- application/json
# format of the responses to the client (Accepts)
produces:
- application/json
paths:
/todo:
get:
description: "this endpoint returns list of todo events"
operationId: "GetAtodo"
parameters:
- name: "todo_id"
in: "query"
description: "ID of todo to return"
required: true
type: "integer"
format: "int64"
responses:
200:
description: "an array of all the present todos"
schema:
items:
$ref: "#/definitions/Todo"
post:
description: "add a new todo event"
operationId: "AddTodo"
produces:
- "application/json"
parameters:
- in: "body"
name: "todo"
description: "todo to be added"
required: true
schema:
$ref: "#/definitions/Todo"
responses:
200:
description: "successful todo addition"
405:
description: "Invalid input"
404:
description: "Todo server not found"
/swagger:
x-swagger-pipe: swagger_raw
# complex objects have schema definitions
definitions:
Todo:
type: "object"
properties:
todo_id:
type: "integer"
description: "id of the todo event"
todo:
type: "string"
description: "The todo item"