这是我在Swagger Editor在线查看的OpenAPI 3.0定义的简化版本。我试图让两个错误代码401和403的响应,它们共享相同的模式,显示不同的示例 - 但这似乎行不通,我仍然看到引用类型作为示例。
你能帮我找出定义中的问题吗?
你能帮我找出定义中的问题吗?
openapi: 3.0.0
info:
version: '1.0'
title: A service
paths:
/doSomething:
post:
requestBody:
content:
application/json:
schema:
type: string
example: A string
responses:
401:
$ref: '#/components/responses/Unauthorized'
403:
$ref: '#/components/responses/Denied'
components:
responses:
Unauthorized:
description: The endpoint cannot be reached because the request is not authorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: unauthorized
Denied:
description: The request's authorizations don't match the required ones needed to access the resource
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: permissions denied
schemas:
Error:
type: object
properties:
error:
type: string