我是Swagger的新手。我使用Swagger编辑器编写了以下代码,但我收到了多个错误。我已经查看了文档和其他示例,但我无法澄清问题。
swagger: '2.0'
info:
version: "1"
title: 'Grocery Shop'
description: 'This contains the url to access all the Grocery food related information. You can also add, update or delete any food item as well based on their respective id.'
contact:
email: you@your-company.com
tags:
- name: FoodItem
description: Specifically for Food item
- name: Category
description: Specifically for the category purpose
schemes:
- https
paths:
'/findfood/{foodItemId}':
get:
tags:
- FoodItem
summary: "Find the required food"
description: "Find the food with passed food id as an argument. Make sure that passed id exist otherwise it will return an error"
operationId: findFoodWithId
produces:
- "application/json"
parameters:
- in: path
name: foodItemId
required: true
type: integer
miniumum: 1
description: The id associated with the food in the grocery shop
responses:
200:
description: "successful operation"
schema:
$ref: '#definitions/Food'
404:
description: "Food is not found
definitions:
Food:
type: "object"
properties:
foodItemId:
type: integer
format: int32
required:
- foodItemId
xml:
name: "User"
# Added by API Auto Mocking Plugin
host: "localhost:8080"
basePath: "/grocery"
我得到的错误是:
paths./findfood/{foodItemId的语义错误}声明的路径参数 " foodItemId"需要定义为路径参数 路径或操作级别跳转到第18行
paths./findfood/{foodItemId}.get.parameters[0]上的模式错误不是 一个来自 <#/定义/参数>,<#/定义/ jsonReference>跳到线上 28
分析器错误无法读取块映射条目;多线键可以 不是隐含的键跳转到第48行
答案 0 :(得分:2)
这些错误具有误导性。实际错误是:
miniumum: 1
包含一个错字 - 迷你你妈妈
$ref: '#definitions/Food'
在/
和#
之间需要definitions
:'#/definitions/Food'
description: "Food is not found
需要结束引号。