Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.33 KB | None | 0 0
  1. swagger: '2.0'
  2. schemes:
  3. - http
  4. - https
  5. host: petstore.swagger.io
  6. basePath: /v2
  7. info:
  8. description: |
  9. This is a sample server Petstore server.
  10. You can find out more about Swagger at
  11. [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).
  12. For this sample, you can use the api key `special-key` to test the authorization filters.
  13. # Introduction
  14. This API is documented in **OpenAPI format** and is based on
  15. [Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.
  16. It was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo)
  17. tool and [ReDoc](https://github.com/Rebilly/ReDoc) documentation. In addition to standard
  18. OpenAPI syntax we use a few [vendor extensions](https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md).
  19. # OpenAPI Specification
  20. This API is documented in **OpenAPI format** and is based on
  21. [Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.
  22. It was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo)
  23. tool and [ReDoc](https://github.com/Rebilly/ReDoc) documentation. In addition to standard
  24. OpenAPI syntax we use a few [vendor extensions](https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md).
  25. # Cross-Origin Resource Sharing
  26. This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/).
  27. And that allows cross-domain communication from the browser.
  28. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.
  29. # Authentication
  30. Petstore offers two forms of authentication:
  31. - API Key
  32. - OAuth2
  33.  
  34. OAuth2 - an open protocol to allow secure authorization in a simple
  35. and standard method from web, mobile and desktop applications.
  36. <!-- ReDoc-Inject: <security-definitions> -->
  37. version: 1.0.0
  38. title: Swagger Petstore
  39. termsOfService: 'http://swagger.io/terms/'
  40. contact:
  41. email: apiteam@swagger.io
  42. url: https://github.com/Rebilly/ReDoc
  43. x-logo:
  44. url: 'https://rebilly.github.io/ReDoc/petstore-logo.png'
  45. altText: Petstore logo
  46. license:
  47. name: Apache 2.0
  48. url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
  49. externalDocs:
  50. description: Find out how to create Github repo for your OpenAPI spec.
  51. url: 'https://github.com/Rebilly/generator-openapi-repo'
  52. tags:
  53. - name: pet
  54. description: Everything about your Pets
  55. - name: store
  56. description: Access to Petstore orders
  57. - name: user
  58. description: Operations about user
  59. x-tagGroups:
  60. - name: General
  61. tags:
  62. - pet
  63. - store
  64. - name: User Management
  65. tags:
  66. - user
  67. securityDefinitions:
  68. petstore_auth:
  69. description: |
  70. Get access to data while protecting your account credentials.
  71. OAuth2 is also a safer and more secure way to give you access.
  72. type: oauth2
  73. authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
  74. flow: implicit
  75. scopes:
  76. 'write:pets': modify pets in your account
  77. 'read:pets': read your pets
  78. api_key:
  79. description: |
  80. For this sample, you can use the api key `special-key` to test the authorization filters.
  81. type: apiKey
  82. name: api_key
  83. in: header
  84. x-servers:
  85. - url: //petstore.swagger.io/v2
  86. description: Default server
  87. - url: //petstore.swagger.io/sandbox
  88. description: Sandbox server
  89. paths:
  90. /pet:
  91. post:
  92. tags:
  93. - pet
  94. summary: Add a new pet to the store
  95. description: Add new pet to the store inventory.
  96. lang: JavaScript
  97. source: console.log('Hello World');
  98. operationId: addPet
  99. consumes:
  100. - application/json
  101. - application/xml
  102. produces:
  103. - application/xml
  104. - application/json
  105. parameters:
  106. - in: body
  107. name: body
  108. description: Pet object that needs to be added to the store
  109. required: true
  110. schema:
  111. $ref: '#/definitions/Pet'
  112. responses:
  113. '405':
  114. description: Invalid input
  115. security:
  116. - petstore_auth:
  117. - 'write:pets'
  118. - 'read:pets'
  119. x-code-samples:
  120. - lang: 'C#'
  121. source: |
  122. PetStore.v1.Pet pet = new PetStore.v1.Pet();
  123. pet.setApiKey("your api key");
  124. pet.petType = PetStore.v1.Pet.TYPE_DOG;
  125. pet.name = "Rex";
  126. // set other fields
  127. PetStoreResponse response = pet.create();
  128. if (response.statusCode == HttpStatusCode.Created)
  129. {
  130. // Successfully created
  131. }
  132. else
  133. {
  134. // Something wrong -- check response for errors
  135. Console.WriteLine(response.getRawResponse());
  136. }
  137. - lang: PHP
  138. source: "$form = new \\PetStore\\Entities\\Pet();\n$form->setPetType(\"Dog\");\n$form->setName(\"Rex\");\n// set other fields\ntry {\n $pet = $client->pets()->create($form);\n} catch (UnprocessableEntityException $e) {\n var_dump($e->getErrors());\n}\n"
  139. put:
  140. tags:
  141. - pet
  142. summary: Update an existing pet
  143. description: ''
  144. operationId: updatePet
  145. consumes:
  146. - application/json
  147. - application/xml
  148. produces:
  149. - application/xml
  150. - application/json
  151. parameters:
  152. - in: body
  153. name: body
  154. description: Pet object that needs to be added to the store
  155. required: true
  156. schema:
  157. $ref: '#/definitions/Pet'
  158. responses:
  159. '400':
  160. description: Invalid ID supplied
  161. '404':
  162. description: Pet not found
  163. '405':
  164. description: Validation exception
  165. security:
  166. - petstore_auth:
  167. - 'write:pets'
  168. - 'read:pets'
  169. x-code-samples:
  170. - lang: PHP
  171. source: "$form = new \\PetStore\\Entities\\Pet();\n$form->setPetId(1);\n$form->setPetType(\"Dog\");\n$form->setName(\"Rex\");\n// set other fields\ntry {\n $pet = $client->pets()->update($form);\n} catch (UnprocessableEntityException $e) {\n var_dump($e->getErrors());\n}\n"
  172. '/pet/{petId}':
  173. get:
  174. tags:
  175. - pet
  176. summary: Find pet by ID
  177. description: Returns a single pet
  178. operationId: getPetById
  179. produces:
  180. - application/xml
  181. - application/json
  182. parameters:
  183. - name: petId
  184. in: path
  185. description: ID of pet to return
  186. required: true
  187. type: integer
  188. format: int64
  189. responses:
  190. '200':
  191. description: successful operation
  192. schema:
  193. $ref: '#/definitions/Pet'
  194. '400':
  195. description: Invalid ID supplied
  196. '404':
  197. description: Pet not found
  198. security:
  199. - api_key: []
  200. post:
  201. tags:
  202. - pet
  203. summary: Updates a pet in the store with form data
  204. description: ''
  205. operationId: updatePetWithForm
  206. consumes:
  207. - application/x-www-form-urlencoded
  208. produces:
  209. - application/xml
  210. - application/json
  211. parameters:
  212. - name: petId
  213. in: path
  214. description: ID of pet that needs to be updated
  215. required: true
  216. type: integer
  217. format: int64
  218. - name: name
  219. in: formData
  220. description: Updated name of the pet
  221. required: false
  222. type: string
  223. - name: status
  224. in: formData
  225. description: Updated status of the pet
  226. required: false
  227. type: string
  228. responses:
  229. '405':
  230. description: Invalid input
  231. security:
  232. - petstore_auth:
  233. - 'write:pets'
  234. - 'read:pets'
  235. delete:
  236. tags:
  237. - pet
  238. summary: Deletes a pet
  239. description: ''
  240. operationId: deletePet
  241. produces:
  242. - application/xml
  243. - application/json
  244. parameters:
  245. - name: api_key
  246. in: header
  247. required: false
  248. type: string
  249. x-example: Bearer <TOKEN>
  250. - name: petId
  251. in: path
  252. description: Pet id to delete
  253. required: true
  254. type: integer
  255. format: int64
  256. responses:
  257. '400':
  258. description: Invalid pet value
  259. security:
  260. - petstore_auth:
  261. - 'write:pets'
  262. - 'read:pets'
  263. '/pet/{petId}/uploadImage':
  264. post:
  265. tags:
  266. - pet
  267. summary: uploads an image
  268. description: ''
  269. operationId: uploadFile
  270. consumes:
  271. - multipart/form-data
  272. produces:
  273. - application/json
  274. parameters:
  275. - name: petId
  276. in: path
  277. description: ID of pet to update
  278. required: true
  279. type: integer
  280. format: int64
  281. - name: additionalMetadata
  282. in: formData
  283. description: Additional data to pass to server
  284. required: false
  285. type: string
  286. - name: file
  287. in: formData
  288. description: file to upload
  289. required: false
  290. type: file
  291. responses:
  292. '200':
  293. description: successful operation
  294. schema:
  295. $ref: '#/definitions/ApiResponse'
  296. security:
  297. - petstore_auth:
  298. - 'write:pets'
  299. - 'read:pets'
  300. /pet/findByStatus:
  301. get:
  302. tags:
  303. - pet
  304. summary: Finds Pets by status
  305. description: Multiple status values can be provided with comma separated strings
  306. operationId: findPetsByStatus
  307. produces:
  308. - application/xml
  309. - application/json
  310. parameters:
  311. - name: status
  312. in: query
  313. description: Status values that need to be considered for filter
  314. required: true
  315. type: array
  316. items:
  317. type: string
  318. enum:
  319. - available
  320. - pending
  321. - sold
  322. default: available
  323. collectionFormat: csv
  324. responses:
  325. '200':
  326. description: successful operation
  327. schema:
  328. type: array
  329. items:
  330. $ref: '#/definitions/Pet'
  331. '400':
  332. description: Invalid status value
  333. security:
  334. - petstore_auth:
  335. - 'write:pets'
  336. - 'read:pets'
  337. /pet/findByTags:
  338. get:
  339. tags:
  340. - pet
  341. summary: Finds Pets by tags
  342. description: 'Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.'
  343. operationId: findPetsByTags
  344. deprecated: true
  345. produces:
  346. - application/xml
  347. - application/json
  348. parameters:
  349. - name: tags
  350. in: query
  351. description: Tags to filter by
  352. required: true
  353. type: array
  354. items:
  355. type: string
  356. collectionFormat: csv
  357. responses:
  358. '200':
  359. description: successful operation
  360. schema:
  361. type: array
  362. items:
  363. $ref: '#/definitions/Pet'
  364. '400':
  365. description: Invalid tag value
  366. security:
  367. - petstore_auth:
  368. - 'write:pets'
  369. - 'read:pets'
  370. /store/inventory:
  371. get:
  372. tags:
  373. - store
  374. summary: Returns pet inventories by status
  375. description: Returns a map of status codes to quantities
  376. operationId: getInventory
  377. produces:
  378. - application/json
  379. parameters: []
  380. responses:
  381. '200':
  382. description: successful operation
  383. schema:
  384. type: object
  385. additionalProperties:
  386. type: integer
  387. format: int32
  388. security:
  389. - api_key: []
  390. /store/order:
  391. post:
  392. tags:
  393. - store
  394. summary: Place an order for a pet
  395. description: ''
  396. operationId: placeOrder
  397. produces:
  398. - application/xml
  399. - application/json
  400. parameters:
  401. - in: body
  402. name: body
  403. description: order placed for purchasing the pet
  404. required: true
  405. schema:
  406. $ref: '#/definitions/Order'
  407. responses:
  408. '200':
  409. description: successful operation
  410. schema:
  411. $ref: '#/definitions/Order'
  412. '400':
  413. description: Invalid Order
  414. '/store/order/{orderId}':
  415. get:
  416. tags:
  417. - store
  418. summary: Find purchase order by ID
  419. description: 'For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions'
  420. operationId: getOrderById
  421. produces:
  422. - application/xml
  423. - application/json
  424. parameters:
  425. - name: orderId
  426. in: path
  427. description: ID of pet that needs to be fetched
  428. required: true
  429. type: integer
  430. maximum: 5
  431. minimum: 1
  432. format: int64
  433. responses:
  434. '200':
  435. description: successful operation
  436. schema:
  437. $ref: '#/definitions/Order'
  438. '400':
  439. description: Invalid ID supplied
  440. '404':
  441. description: Order not found
  442. delete:
  443. tags:
  444. - store
  445. summary: Delete purchase order by ID
  446. description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
  447. operationId: deleteOrder
  448. produces:
  449. - application/xml
  450. - application/json
  451. parameters:
  452. - name: orderId
  453. in: path
  454. description: ID of the order that needs to be deleted
  455. required: true
  456. type: string
  457. minimum: 1
  458. responses:
  459. '400':
  460. description: Invalid ID supplied
  461. '404':
  462. description: Order not found
  463. /user:
  464. post:
  465. tags:
  466. - user
  467. summary: Create user
  468. description: This can only be done by the logged in user.
  469. operationId: createUser
  470. produces:
  471. - application/xml
  472. - application/json
  473. parameters:
  474. - in: body
  475. name: body
  476. description: Created user object
  477. required: true
  478. schema:
  479. $ref: '#/definitions/User'
  480. responses:
  481. default:
  482. description: successful operation
  483. '/user/{username}':
  484. get:
  485. tags:
  486. - user
  487. summary: Get user by user name
  488. description: ''
  489. operationId: getUserByName
  490. produces:
  491. - application/xml
  492. - application/json
  493. parameters:
  494. - name: username
  495. in: path
  496. description: 'The name that needs to be fetched. Use user1 for testing. '
  497. required: true
  498. type: string
  499. responses:
  500. '200':
  501. description: successful operation
  502. schema:
  503. $ref: '#/definitions/User'
  504. '400':
  505. description: Invalid username supplied
  506. '404':
  507. description: User not found
  508. put:
  509. tags:
  510. - user
  511. summary: Updated user
  512. description: This can only be done by the logged in user.
  513. operationId: updateUser
  514. produces:
  515. - application/xml
  516. - application/json
  517. parameters:
  518. - name: username
  519. in: path
  520. description: name that need to be deleted
  521. required: true
  522. type: string
  523. - in: body
  524. name: body
  525. description: Updated user object
  526. required: true
  527. schema:
  528. $ref: '#/definitions/User'
  529. responses:
  530. '400':
  531. description: Invalid user supplied
  532. '404':
  533. description: User not found
  534. delete:
  535. tags:
  536. - user
  537. summary: Delete user
  538. description: This can only be done by the logged in user.
  539. operationId: deleteUser
  540. produces:
  541. - application/xml
  542. - application/json
  543. parameters:
  544. - name: username
  545. in: path
  546. description: The name that needs to be deleted
  547. required: true
  548. type: string
  549. responses:
  550. '400':
  551. description: Invalid username supplied
  552. '404':
  553. description: User not found
  554. /user/createWithArray:
  555. post:
  556. tags:
  557. - user
  558. summary: Creates list of users with given input array
  559. description: ''
  560. operationId: createUsersWithArrayInput
  561. produces:
  562. - application/xml
  563. - application/json
  564. parameters:
  565. - in: body
  566. name: body
  567. description: List of user object
  568. required: true
  569. schema:
  570. type: array
  571. items:
  572. $ref: '#/definitions/User'
  573. responses:
  574. default:
  575. description: successful operation
  576. /user/createWithList:
  577. post:
  578. tags:
  579. - user
  580. summary: Creates list of users with given input array
  581. description: ''
  582. operationId: createUsersWithListInput
  583. produces:
  584. - application/xml
  585. - application/json
  586. parameters:
  587. - in: body
  588. name: body
  589. description: List of user object
  590. required: true
  591. schema:
  592. type: array
  593. items:
  594. $ref: '#/definitions/User'
  595. responses:
  596. default:
  597. description: successful operation
  598. /user/login:
  599. get:
  600. tags:
  601. - user
  602. summary: Logs user into the system
  603. description: ''
  604. operationId: loginUser
  605. produces:
  606. - application/xml
  607. - application/json
  608. parameters:
  609. - name: username
  610. in: query
  611. description: The user name for login
  612. required: true
  613. type: string
  614. - name: password
  615. in: query
  616. description: The password for login in clear text
  617. required: true
  618. type: string
  619. responses:
  620. '200':
  621. description: successful operation
  622. schema:
  623. type: string
  624. examples:
  625. application/json: OK
  626. application/xml: <message> OK </message>
  627. text/plain: OK
  628. headers:
  629. X-Rate-Limit:
  630. type: integer
  631. format: int32
  632. description: calls per hour allowed by the user
  633. X-Expires-After:
  634. type: string
  635. format: date-time
  636. description: date in UTC when toekn expires
  637. '400':
  638. description: Invalid username/password supplied
  639. /user/logout:
  640. get:
  641. tags:
  642. - user
  643. summary: Logs out current logged in user session
  644. description: ''
  645. operationId: logoutUser
  646. produces:
  647. - application/xml
  648. - application/json
  649. parameters: []
  650. responses:
  651. default:
  652. description: successful operation
  653. definitions:
  654. ApiResponse:
  655. type: object
  656. properties:
  657. code:
  658. type: integer
  659. format: int32
  660. type:
  661. type: string
  662. message:
  663. type: string
  664. Cat:
  665. description: A representation of a cat
  666. allOf:
  667. - $ref: '#/definitions/Pet'
  668. - type: object
  669. properties:
  670. huntingSkill:
  671. type: string
  672. description: The measured skill for hunting
  673. default: lazy
  674. enum:
  675. - clueless
  676. - lazy
  677. - adventurous
  678. - aggressive
  679. required:
  680. - huntingSkill
  681. Category:
  682. type: object
  683. properties:
  684. id:
  685. description: Category ID
  686. allOf:
  687. - $ref: '#/definitions/Id'
  688. name:
  689. description: Category name
  690. type: string
  691. minLength: 1
  692. sub:
  693. description: Test Sub Category
  694. type: object
  695. properties:
  696. prop1:
  697. type: string
  698. description: Dumb Property
  699. xml:
  700. name: Category
  701. Dog:
  702. description: A representation of a dog
  703. allOf:
  704. - $ref: '#/definitions/Pet'
  705. - type: object
  706. properties:
  707. packSize:
  708. type: integer
  709. format: int32
  710. description: The size of the pack the dog is from
  711. default: 1
  712. minimum: 1
  713. required:
  714. - packSize
  715. HoneyBee:
  716. description: A representation of a honey bee
  717. allOf:
  718. - $ref: '#/definitions/Pet'
  719. - type: object
  720. properties:
  721. honeyPerDay:
  722. type: number
  723. description: Average amount of honey produced per day in ounces
  724. example: 3.14
  725. required:
  726. - honeyPerDay
  727. Id:
  728. type: integer
  729. format: int64
  730. Order:
  731. type: object
  732. properties:
  733. id:
  734. description: Order ID
  735. allOf:
  736. - $ref: '#/definitions/Id'
  737. petId:
  738. description: Pet ID
  739. allOf:
  740. - $ref: '#/definitions/Id'
  741. quantity:
  742. type: integer
  743. format: int32
  744. minimum: 1
  745. default: 1
  746. shipDate:
  747. description: Estimated ship date
  748. type: string
  749. format: date-time
  750. status:
  751. type: string
  752. description: Order Status
  753. enum:
  754. - placed
  755. - approved
  756. - delivered
  757. complete:
  758. description: Indicates whenever order was completed or not
  759. type: boolean
  760. default: false
  761. xml:
  762. name: Order
  763. Pet:
  764. type: object
  765. required:
  766. - name
  767. - photoUrls
  768. discriminator: petType
  769. properties:
  770. id:
  771. description: Pet ID
  772. allOf:
  773. - $ref: '#/definitions/Id'
  774. category:
  775. description: Categories this pet belongs to
  776. allOf:
  777. - $ref: '#/definitions/Category'
  778. name:
  779. description: The name given to a pet
  780. type: string
  781. example: Guru
  782. photoUrls:
  783. description: The list of URL to a cute photos featuring pet
  784. type: array
  785. xml:
  786. name: photoUrl
  787. wrapped: true
  788. items:
  789. type: string
  790. format: url
  791. tags:
  792. description: Tags attached to the pet
  793. type: array
  794. xml:
  795. name: tag
  796. wrapped: true
  797. items:
  798. $ref: '#/definitions/Tag'
  799. status:
  800. type: string
  801. description: Pet status in the store
  802. enum:
  803. - available
  804. - pending
  805. - sold
  806. petType:
  807. description: Type of a pet
  808. type: string
  809. xml:
  810. name: Pet
  811. Tag:
  812. type: object
  813. properties:
  814. id:
  815. description: Tag ID
  816. allOf:
  817. - $ref: '#/definitions/Id'
  818. name:
  819. description: Tag name
  820. type: string
  821. minLength: 1
  822. xml:
  823. name: Tag
  824. User:
  825. type: object
  826. properties:
  827. id:
  828. description: User ID
  829. $ref: '#/definitions/Id'
  830. username:
  831. description: User supplied username
  832. type: string
  833. minLength: 4
  834. example: John78
  835. firstName:
  836. description: User first name
  837. type: string
  838. minLength: 1
  839. example: John
  840. lastName:
  841. description: User last name
  842. type: string
  843. minLength: 1
  844. example: Smith
  845. email:
  846. description: User email address
  847. type: string
  848. format: email
  849. example: john.smith@example.com
  850. password:
  851. type: string
  852. description: 'User password, MUST contain a mix of upper and lower case letters, as well as digits'
  853. format: password
  854. minLength: 8
  855. pattern: '(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])'
  856. example: drowssaP123
  857. phone:
  858. description: User phone number in international format
  859. type: string
  860. pattern: "^\\+(?:[0-9]-?){6,14}[0-9]$"
  861. example: +1-202-555-0192
  862. x-nullable: true
  863. userStatus:
  864. description: User status
  865. type: integer
  866. format: int32
  867. xml:
  868. name: User
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement