Swagger3文檔瘦身


3.1簡化數據模型

通過可重用定義來重構出現有重復定義的文檔

eg.當在文檔中多次出現關於person的定義時

 required:  - username  properties:  firstName:  type: string  lastName:  type: string  username:  type: string
將關於重復出現的person定義抽取出來
definitions: #添加定義項
Person:
 required:  - username  properties:  firstName:  type: string  lastName:  type: string  username:  type: string
需要用到這個定義時,用$ref屬性來引用即可
$ref:"#/definition/Person" #引用一個定義來增加另一個定義

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM