【发布时间】:2018-11-26 06:49:16
【问题描述】:
我想在 OpenAPI 3.0 API 定义中将以下 JSON 表示为 schema:
{
get-question: {
question-id:string
}
}
到目前为止,我已经写了:
components:
schemas:
#schema of a question-id
QuestionID: #{question-id: string}
properties:
question-id:
type: string
required:
- question-id
#schema of a get-question request which contains a question id
GetQuestion: #{get-question: {question-id:string}}
properties:
get-questions:
type: $ref:'#/components/schemas/QuestionID'
required:
- get-questions
但我在 Swagger 编辑器中收到这些错误:
Schema error at components.schemas['GetQuestion']
should have required property '$ref'
missingProperty: $ref
Jump to line 79
Schema error at components.schemas['GetQuestion']
should match exactly one schema in oneOf
Jump to line 79
Schema error at components.schemas['GetQuestion'].properties['get-questions']
should have required property '$ref'
missingProperty: $ref
Jump to line 81
Schema error at components.schemas['GetQuestion'].properties['get-questions']
should match exactly one schema in oneOf
Jump to line 81
Schema error at components.schemas['GetQuestion'].properties['get-questions'].type
should be equal to one of the allowed values
allowedValues: array, boolean, integer, number, object, string
Jump to line 82
$ref 的正确语法是什么?
【问题讨论】:
标签: openapi