Advertisement
Guest User

Untitled

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