definitionsSwagger 2.0中的全局部分和部分有什么区别components?
我遇到了一个 Swagger 定义 YAML 文件,该文件标记为swagger: '2.0'. 它有一个名为definitions下面的部分parameters。这类似于
https://swagger.io/docs/specification/2-0/basic-struct/
的“输入和输出模型”部分中描述的内容。
此外,在文件的更下方,它还包含下面的部分components。这与https://swagger.io/docs/specification/components/schemas中描述的类似,
这看起来像 OAS3。
但是,这个特定的 YAML 文件具有两个部分。我不确定是否definitions适用于 Swagger 2.0 和components是否schemas适用于 OAS 3.0。是这样吗?
和 可以definitions在components同一类型的 YAML 文件中使用吗swagger: '2.0'?或者我们应该坚持使用definitionsor 吗components?
# definitions section looks like this
definitions:
User:
properties:
id:
type: integer
name:
type: string
# Both properties are required
required:
- …Run Code Online (Sandbox Code Playgroud)