examples.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. const examples = [
  2. {
  3. key: 'json',
  4. content: `{
  5. "openapi": "3.1.0",
  6. "info": {
  7. "title": "Get weather data",
  8. "description": "Retrieves current weather data for a location.",
  9. "version": "v1.0.0"
  10. },
  11. "servers": [
  12. {
  13. "url": "https://weather.example.com"
  14. }
  15. ],
  16. "paths": {
  17. "/location": {
  18. "get": {
  19. "description": "Get temperature for a specific location",
  20. "operationId": "GetCurrentWeather",
  21. "parameters": [
  22. {
  23. "name": "location",
  24. "in": "query",
  25. "description": "The city and state to retrieve the weather for",
  26. "required": true,
  27. "schema": {
  28. "type": "string"
  29. }
  30. }
  31. ],
  32. "deprecated": false
  33. }
  34. }
  35. },
  36. "components": {
  37. "schemas": {}
  38. }
  39. }`,
  40. },
  41. {
  42. key: 'yaml',
  43. content: `# Taken from https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.0/petstore.yaml
  44. openapi: "3.0.0"
  45. info:
  46. version: 1.0.0
  47. title: Swagger Petstore
  48. license:
  49. name: MIT
  50. servers:
  51. - url: https://petstore.swagger.io/v1
  52. paths:
  53. /pets:
  54. get:
  55. summary: List all pets
  56. operationId: listPets
  57. tags:
  58. - pets
  59. parameters:
  60. - name: limit
  61. in: query
  62. description: How many items to return at one time (max 100)
  63. required: false
  64. schema:
  65. type: integer
  66. maximum: 100
  67. format: int32
  68. responses:
  69. '200':
  70. description: A paged array of pets
  71. headers:
  72. x-next:
  73. description: A link to the next page of responses
  74. schema:
  75. type: string
  76. content:
  77. application/json:
  78. schema:
  79. $ref: "#/components/schemas/Pets"
  80. default:
  81. description: unexpected error
  82. content:
  83. application/json:
  84. schema:
  85. $ref: "#/components/schemas/Error"
  86. post:
  87. summary: Create a pet
  88. operationId: createPets
  89. tags:
  90. - pets
  91. responses:
  92. '201':
  93. description: Null response
  94. default:
  95. description: unexpected error
  96. content:
  97. application/json:
  98. schema:
  99. $ref: "#/components/schemas/Error"
  100. /pets/{petId}:
  101. get:
  102. summary: Info for a specific pet
  103. operationId: showPetById
  104. tags:
  105. - pets
  106. parameters:
  107. - name: petId
  108. in: path
  109. required: true
  110. description: The id of the pet to retrieve
  111. schema:
  112. type: string
  113. responses:
  114. '200':
  115. description: Expected response to a valid request
  116. content:
  117. application/json:
  118. schema:
  119. $ref: "#/components/schemas/Pet"
  120. default:
  121. description: unexpected error
  122. content:
  123. application/json:
  124. schema:
  125. $ref: "#/components/schemas/Error"
  126. components:
  127. schemas:
  128. Pet:
  129. type: object
  130. required:
  131. - id
  132. - name
  133. properties:
  134. id:
  135. type: integer
  136. format: int64
  137. name:
  138. type: string
  139. tag:
  140. type: string
  141. Pets:
  142. type: array
  143. maxItems: 100
  144. items:
  145. $ref: "#/components/schemas/Pet"
  146. Error:
  147. type: object
  148. required:
  149. - code
  150. - message
  151. properties:
  152. code:
  153. type: integer
  154. format: int32
  155. message:
  156. type: string`,
  157. },
  158. {
  159. key: 'blankTemplate',
  160. content: `{
  161. "openapi": "3.1.0",
  162. "info": {
  163. "title": "Untitled",
  164. "description": "Your OpenAPI specification",
  165. "version": "v1.0.0"
  166. },
  167. "servers": [
  168. {
  169. "url": ""
  170. }
  171. ],
  172. "paths": {},
  173. "components": {
  174. "schemas": {}
  175. }
  176. }`,
  177. },
  178. ]
  179. export default examples