Swagger Verication说,尽管它确实存在,但doken却不存在
我正在使用Swagger-cli
进行以下命令:
swagger-cli validate src/swagger/swagger.yml
我正在遇到错误:
Token "Multiclassing" does not exist.
有问题的文件是:
/src/swagger/schemas/schemas/combined.yml:
Multiclassing:
$ref: './multiclassing.yml'
OptionSet:
$ref: './common.yml#/option-set-model'
Option:
$ref: './common.yml#/option-model'
/src/swagger/schemas/multiclassing.yml
description: |
`Multiclassing`
type: object
properties:
prerequisites:
description: List of prerequisites that must be met.
type: array
items:
$ref: "./combined.yml#/Prerequisite"
prerequisite_options:
description: List of choices of prerequisites to meet for.
type: array
items:
$ref: "./combined.yml#/Choice"
proficiencies:
description: "List of proficiencies available when multiclassing."
type: array
items:
$ref: "./combined.yml#/APIReference"
proficiency_choices:
description: List of choices of proficiencies that are given when multiclassing.
type: array
items:
$ref: "./combined.yml#/Choice"
/src/swagger/schemas/schemas/classes.yml
class-model:
description: |
`Class`
allOf:
- $ref: './combined.yml#/APIReference'
- type: object
properties:
hit_die:
description: 'Hit die of the class. (ex: 12 == 1d12).'
type: number
class_levels:
description: URL of the level resource for the class.
type: string
multi_classing:
$ref: './combined.yml#/Multiclassing'
spellcasting:
$ref: './combined.yml#/Spellcasting'
spells:
description: URL of the spell resource list for the class.
type: string
starting_equipment:
description: List of equipment and their quantities all players of the class start with.
type: array
items:
type: object
properties:
quantity:
type: number
equipment:
$ref: './combined.yml#/APIReference'
starting_equipment_options:
description: List of choices of starting equipment.
type: array
items:
$ref: './combined.yml#/Choice'
proficiency_choices:
description: List of choices of starting proficiencies.
type: array
items:
$ref: './combined.yml#/Choice'
proficiencies:
description: List of starting proficiencies for all new characters of this class.
type: array
items:
$ref: './combined.yml#/APIReference'
saving_throws:
description: Saving throws the class is proficient in.
type: array
items:
$ref: './combined.yml#/APIReference'
subclasses:
description: List of all possible subclasses this class can specialize in.
type: array
items:
$ref: './combined.yml#/APIReference'
/src/swaggers/paths/classes.classes.yml
class-multi-classing-path:
get:
summary: Get multiclassing resource for a class.
tags:
- Class
parameters:
- $ref: '../parameters/combined.yml#/class-index'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '../schemas/combined.yml#/Multiclassing'
example:
prerequisites:
- ability_score:
index: str
name: STR
url: '/api/ability-scores/str'
minimum_score: 13
proficiencies:
- index: shields
name: Shields
url: '/api/proficiencies/shields'
- index: simple-weapons
name: Simple Weapons
url: '/api/proficiencies/simple-weapons'
- index: martial-weapons
name: Martial Weapons
url: '/api/proficiencies/martial-weapons'
proficiency_choices: []
我双重和三倍检查了导致两个类文件中多层的路径,它们似乎是正确的。我重现了文件路径,以便其他人可以验证摘要中使用的路径是否正确。甚至陌生的人是,我只在更新与多类无关的Swagger文档的部分之后才开始看到这个问题。
有人知道我如何解决这个问题吗?
更新:我进行了一些调试,更加困惑。
上下文的另一个文件: /src/swagger/schemas/comman.yml
option-model:
description: |
`Option`
oneOf:
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
item:
$ref: './combined.yml#/APIReference'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
action_name:
description: 'The name of the action.'
type: string
count:
description: 'The number of times this action can be repeated if chosen.'
type: number
type:
description: 'For attack options that can be melee, ranged, abilities, or thrown.'
type: string
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
items:
type: array
items:
$ref: './combined.yml#/Option'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
choice:
$ref: './combined.yml#/Choice'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
string:
description: 'The string.'
type: string
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
desc:
description: 'A description of the ideal.'
type: string
alignments:
description: 'A list of alignments of those who might follow the ideal.'
type: array
items:
$ref: './combined.yml#/APIReference'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
count:
description: 'Count'
type: number
of:
$ref: './combined.yml#/APIReference'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
ability_score:
$ref: './combined.yml#/APIReference'
minimum_score:
description: 'The minimum score required to satisfy the prerequisite.'
type: number
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
ability_score:
$ref: './combined.yml#/APIReference'
bonus:
description: 'The bonus being applied to the ability score'
type: number
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
name:
description: 'Name of the breath'
type: string
dc:
$ref: './combined.yml#/DC'
damage:
description: 'Damage dealt by the breath attack, if any.'
type: array
items:
$ref: './combined.yml#/Damage'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
damage_type:
$ref: './combined.yml#/APIReference'
damage_dice:
description: 'Damage expressed in dice (e.g. "13d6").'
type: string
notes:
description: 'Information regarding the damage.'
type: string
option-set-model:
description: |
`Option Set`
oneOf:
- type: object
properties:
option_set_type:
description: 'Type of option set; determines other attributes.'
type: string
options_array:
description: 'Array of options to choose from.'
type: array
items:
$ref: './combined.yml#/Option'
- type: object
properties:
option_set_type:
description: 'Type of option set; determines other attributes.'
type: string
equipment_category:
$ref: './combined.yml#/APIReference'
- type: object
properties:
option_set_type:
description: 'Type of option set; determines other attributes.'
type: string
resource_list:
description: 'A reference (by URL) to a collection in the database.'
type: string
choice-model:
description: |
`Choice`
type: object
properties:
desc:
description: 'Description of the choice to be made.'
type: string
choose:
description: 'Number of items to pick from the list.'
type: number
type:
description: 'Type of the resources to choose from.'
type: string
from:
$ref: './combined.yml#/OptionSet'
最后,我在 poceph> opeach> opeach> chosece-model 上设置了一个名为的属性 。如果参考文献指向
optionset
或选项
我在验证时会出现错误。如果我使用任何其他类型,则可以验证罚款。据我所知,这仍然与多类无关。
I'm running the following command with swagger-cli
:
swagger-cli validate src/swagger/swagger.yml
And I'm getting the error:
Token "Multiclassing" does not exist.
The files in question are:
/src/swagger/schemas/combined.yml:
Multiclassing:
$ref: './multiclassing.yml'
OptionSet:
$ref: './common.yml#/option-set-model'
Option:
$ref: './common.yml#/option-model'
/src/swagger/schemas/multiclassing.yml
description: |
`Multiclassing`
type: object
properties:
prerequisites:
description: List of prerequisites that must be met.
type: array
items:
$ref: "./combined.yml#/Prerequisite"
prerequisite_options:
description: List of choices of prerequisites to meet for.
type: array
items:
$ref: "./combined.yml#/Choice"
proficiencies:
description: "List of proficiencies available when multiclassing."
type: array
items:
$ref: "./combined.yml#/APIReference"
proficiency_choices:
description: List of choices of proficiencies that are given when multiclassing.
type: array
items:
$ref: "./combined.yml#/Choice"
/src/swagger/schemas/classes.yml
class-model:
description: |
`Class`
allOf:
- $ref: './combined.yml#/APIReference'
- type: object
properties:
hit_die:
description: 'Hit die of the class. (ex: 12 == 1d12).'
type: number
class_levels:
description: URL of the level resource for the class.
type: string
multi_classing:
$ref: './combined.yml#/Multiclassing'
spellcasting:
$ref: './combined.yml#/Spellcasting'
spells:
description: URL of the spell resource list for the class.
type: string
starting_equipment:
description: List of equipment and their quantities all players of the class start with.
type: array
items:
type: object
properties:
quantity:
type: number
equipment:
$ref: './combined.yml#/APIReference'
starting_equipment_options:
description: List of choices of starting equipment.
type: array
items:
$ref: './combined.yml#/Choice'
proficiency_choices:
description: List of choices of starting proficiencies.
type: array
items:
$ref: './combined.yml#/Choice'
proficiencies:
description: List of starting proficiencies for all new characters of this class.
type: array
items:
$ref: './combined.yml#/APIReference'
saving_throws:
description: Saving throws the class is proficient in.
type: array
items:
$ref: './combined.yml#/APIReference'
subclasses:
description: List of all possible subclasses this class can specialize in.
type: array
items:
$ref: './combined.yml#/APIReference'
/src/swagger/paths/classes.yml
class-multi-classing-path:
get:
summary: Get multiclassing resource for a class.
tags:
- Class
parameters:
- $ref: '../parameters/combined.yml#/class-index'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '../schemas/combined.yml#/Multiclassing'
example:
prerequisites:
- ability_score:
index: str
name: STR
url: '/api/ability-scores/str'
minimum_score: 13
proficiencies:
- index: shields
name: Shields
url: '/api/proficiencies/shields'
- index: simple-weapons
name: Simple Weapons
url: '/api/proficiencies/simple-weapons'
- index: martial-weapons
name: Martial Weapons
url: '/api/proficiencies/martial-weapons'
proficiency_choices: []
I double and triple checked the paths that leads to Multiclassing in the 2 classes files and they seem to be correct. I reproduced the file paths so others can verify that the paths used in the snippets are correct. What's even stranger is that I only started seeing this issue after updating parts of the swagger docs that are completely unrelated to multiclassing.
Does anyone know how I can resolve this issue?
Update: I did some debugging and am even more confused.
Another file for context:
/src/swagger/schemas/comman.yml
option-model:
description: |
`Option`
oneOf:
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
item:
$ref: './combined.yml#/APIReference'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
action_name:
description: 'The name of the action.'
type: string
count:
description: 'The number of times this action can be repeated if chosen.'
type: number
type:
description: 'For attack options that can be melee, ranged, abilities, or thrown.'
type: string
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
items:
type: array
items:
$ref: './combined.yml#/Option'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
choice:
$ref: './combined.yml#/Choice'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
string:
description: 'The string.'
type: string
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
desc:
description: 'A description of the ideal.'
type: string
alignments:
description: 'A list of alignments of those who might follow the ideal.'
type: array
items:
$ref: './combined.yml#/APIReference'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
count:
description: 'Count'
type: number
of:
$ref: './combined.yml#/APIReference'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
ability_score:
$ref: './combined.yml#/APIReference'
minimum_score:
description: 'The minimum score required to satisfy the prerequisite.'
type: number
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
ability_score:
$ref: './combined.yml#/APIReference'
bonus:
description: 'The bonus being applied to the ability score'
type: number
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
name:
description: 'Name of the breath'
type: string
dc:
$ref: './combined.yml#/DC'
damage:
description: 'Damage dealt by the breath attack, if any.'
type: array
items:
$ref: './combined.yml#/Damage'
- type: object
properties:
option_type:
description: 'Type of option; determines other attributes.'
type: string
damage_type:
$ref: './combined.yml#/APIReference'
damage_dice:
description: 'Damage expressed in dice (e.g. "13d6").'
type: string
notes:
description: 'Information regarding the damage.'
type: string
option-set-model:
description: |
`Option Set`
oneOf:
- type: object
properties:
option_set_type:
description: 'Type of option set; determines other attributes.'
type: string
options_array:
description: 'Array of options to choose from.'
type: array
items:
$ref: './combined.yml#/Option'
- type: object
properties:
option_set_type:
description: 'Type of option set; determines other attributes.'
type: string
equipment_category:
$ref: './combined.yml#/APIReference'
- type: object
properties:
option_set_type:
description: 'Type of option set; determines other attributes.'
type: string
resource_list:
description: 'A reference (by URL) to a collection in the database.'
type: string
choice-model:
description: |
`Choice`
type: object
properties:
desc:
description: 'Description of the choice to be made.'
type: string
choose:
description: 'Number of items to pick from the list.'
type: number
type:
description: 'Type of the resources to choose from.'
type: string
from:
$ref: './combined.yml#/OptionSet'
Notice at the end that I set a property called from
on choice-model
that uses a ref. If the ref points to OptionSet
or Option
I get the error when I validate. If I use any other type it validates fine. As far as I can tell, this still has nothing to do with multiclassing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我在帖子中添加的内容中添加的内容,我找到了答案。事实证明,Swagger不支持循环引用。
源自
在选择参考中optionset
option option 又引用opeact> opeach> opeact
和option
再次。当我删除循环引用时,我停止遇到错误。综上所述,这与多类都无关。我想故事的寓意是
Swagger-Cli
有时会含义。Based on what I added in the update to my post, I found the answer. I turns out swagger doesn't support circular references. The
from
in choice referencesOptionSet
, which referencesOption
, which in turn references bothChoice
andOption
again. When I removed the circular reference I stopped getting the error.With all of that said, none of this has to do with multiclassing. I suppose the moral of the story is that
swagger-cli
lies sometimes.