using-refs.json 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. {
  2. "openapi": "3.0.0",
  3. "info": {
  4. "title": "Example of using references in swagger-php",
  5. "version": "1.0.0"
  6. },
  7. "paths": {
  8. "/products/{product_id}": {
  9. "get": {
  10. "tags": [
  11. "Products"
  12. ],
  13. "operationId": "UsingRefs\\ProductController::getProduct",
  14. "responses": {
  15. "default": {
  16. "description": "successful operation",
  17. "content": {
  18. "application/json": {
  19. "schema": {
  20. "$ref": "#/components/responses/product"
  21. }
  22. }
  23. }
  24. }
  25. }
  26. },
  27. "patch": {
  28. "tags": [
  29. "Products"
  30. ],
  31. "operationId": "UsingRefs\\ProductController::updateProduct",
  32. "parameters": [
  33. {
  34. "$ref": "#/components/requestBodies/product_in_body"
  35. }
  36. ],
  37. "responses": {
  38. "default": {
  39. "description": "successful operation",
  40. "content": {
  41. "application/json": {
  42. "schema": {
  43. "$ref": "#/components/responses/product"
  44. }
  45. }
  46. }
  47. }
  48. }
  49. },
  50. "parameters": [
  51. {
  52. "$ref": "#/components/parameters/product_id_in_path_required"
  53. }
  54. ]
  55. },
  56. "/products": {
  57. "post": {
  58. "tags": [
  59. "Products"
  60. ],
  61. "operationId": "UsingRefs\\ProductController::addProduct",
  62. "parameters": [
  63. {
  64. "$ref": "#/components/requestBodies/product_in_body"
  65. }
  66. ],
  67. "responses": {
  68. "default": {
  69. "description": "successful operation",
  70. "content": {
  71. "application/json": {
  72. "schema": {
  73. "$ref": "#/components/responses/product"
  74. }
  75. }
  76. }
  77. }
  78. }
  79. }
  80. }
  81. },
  82. "components": {
  83. "schemas": {
  84. "Product": {
  85. "title": "Product model",
  86. "description": "Product model",
  87. "properties": {
  88. "id": {
  89. "description": "The unique identifier of a product in our catalog.",
  90. "type": "integer",
  91. "format": "int64",
  92. "example": 1
  93. },
  94. "status": {
  95. "$ref": "#/components/schemas/product_status"
  96. }
  97. },
  98. "type": "object"
  99. },
  100. "product_status": {
  101. "description": "The status of a product",
  102. "type": "string",
  103. "default": "available",
  104. "enum": [
  105. "available",
  106. "discontinued"
  107. ]
  108. }
  109. },
  110. "responses": {
  111. "product": {
  112. "description": "All information about a product",
  113. "content": {
  114. "application/json": {
  115. "schema": {
  116. "$ref": "#/components/schemas/Product"
  117. }
  118. }
  119. }
  120. },
  121. "todo": {
  122. "description": "This API call has no documentated response (yet)"
  123. }
  124. },
  125. "parameters": {
  126. "product_id_in_path_required": {
  127. "name": "product_id",
  128. "in": "path",
  129. "description": "The ID of the product",
  130. "required": true,
  131. "schema": {
  132. "type": "integer",
  133. "format": "int64"
  134. }
  135. }
  136. },
  137. "requestBodies": {
  138. "product_in_body": {
  139. "description": "product_request",
  140. "required": true,
  141. "content": {
  142. "application/json": {
  143. "schema": {
  144. "$ref": "#/components/schemas/Product"
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }