설명
Link의 대상은 operationId 또는 operationRef 중 하나로 지정하세요. OpenAPI 3.0에서는 같은 작업을 가리켜도 두 필드를 함께 사용할 수 없습니다.
잠재적 영향
두 필드를 모두 선언하면 도구가 Link를 거부할 수 있습니다.
해결 방법
문서 안에서 고유한 작업 ID를 사용하려면 operationId를, 작업을 가리키는 URI 참조를 사용하려면 operationRef를 지정하세요. 나머지 필드를 제거하고 파라미터 매핑을 확인하세요.
예시
재사용 응답의 address 링크는 getUserAddress를 유지하고 uuid를 userid에 연결합니다. 작업에서 이 응답을 참조하면 호출자가 링크에 따라 후속 요청을 보낼 수 있습니다. 문서 전체를 검증할 때는 별도로 참조된 Pet과 User 스키마도 필요합니다.
변경 전
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "the user being returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
}
}
}
}
},
"/users/{userid}/address": {
"parameters": [
{
"name": "userid",
"in": "path",
"required": true,
"description": "the user identifier, as userId",
"schema": {
"type": "string"
}
}
],
"get": {
"operationId": "getUserAddress",
"responses": {
"200": {
"description": "the user's address"
}
}
}
}
},
"components": {
"responses": {
"200": {
"description": "the user being returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
},
"links": {
"address": {
"operationId": "getUserAddress",
"operationRef": "#/paths/~1users~1{userid}~1address/get",
"parameters": {
"userid": "$response.body#/uuid"
}
}
}
}
},
"schemas": {
"Pet": {
"$ref": "../models/pet.yaml"
},
"User": {
"$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
}
}
}
}
변경 후
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "the user being returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
}
}
}
}
},
"/users/{userid}/address": {
"parameters": [
{
"name": "userid",
"in": "path",
"required": true,
"description": "the user identifier, as userId",
"schema": {
"type": "string"
}
}
],
"get": {
"operationId": "getUserAddress",
"responses": {
"200": {
"description": "the user's address"
}
}
}
}
},
"components": {
"responses": {
"200": {
"description": "the user being returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
},
"links": {
"address": {
"operationId": "getUserAddress",
"parameters": {
"userid": "$response.body#/uuid"
}
}
}
}
},
"schemas": {
"Pet": {
"$ref": "../models/pet.yaml"
},
"User": {
"$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
}
}
}
}