這個問題在這里已經有了答案: Swagger/OpenAPI - 使用 $ref 傳遞可重用的定義引數 (2 個答案) 如何在 OpenAPI 中定義全域引數? (4 個答案) 昨天關門了。
在 openapi 3.0.0 yaml 檔案中,是否可以參考每次呼叫中使用的公共請求標頭串列,而不是在每次呼叫中一次又一次地指定它們?
/some-path:
get:
summary: "sample1"
operationId: doWork
description: 'description of do work'
parameters:
...
- in: header
name: Authorization
schema:
type: string
required: true
- in: header
name: Consumer-Key
schema:
type: string
required: true
- in: header
name: Correlation-Id
schema:
type: string
format: uuid
required: true
/some-other-path:
get:
summary: "sample2"
operationId: doOtherWork
description: 'description of do other work'
parameters:
...
- in: header
name: Authorization
schema:
type: string
required: true
- in: header
name: Consumer-Key
schema:
type: string
required: true
- in: header
name: Correlation-Id
schema:
type: string
format: uuid
required: true
我試過復制它......而且它有效......但它很難看。
uj5u.com熱心網友回復:
這可能不是您想要的答案。對于 3.0.3 版,我們執行如下操作:
openapi: 3.0.3
paths:
/some-path:
get:
summary: "sample1"
operationId: doWork
description: 'description of do work'
parameters:
...
- in: header
name: Authorization
schema:
type: string
required: true
- in: header
name: Consumer-Key
schema:
type: string
required: true
- $ref: '#/components/parameters/__common__correlationId_header'
components:
parameters:
__common__correlationId_header:
in: header
name: Correlation-Id
description: common correlation id.
required: true
schema:
type: string
format: uuid
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/534497.html
標籤:弹簧靴yaml昂首阔步开放APIopenapi 生成器
