git.iko.soy/typeable/openapi3
on 80c39df help sign in
typeable/openapi3/test/Data/SwaggerSpec.hs
1606 lines 46 kB history raw
1{-# LANGUAGE OverloadedLists #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE QuasiQuotes #-}
5module Data.SwaggerSpec where
7import Prelude ()
8import Prelude.Compat
10import Control.Lens
12import Data.Aeson
13import Data.Aeson.QQ
14import Data.HashMap.Strict (HashMap)
15import Data.Text (Text)
17import Data.Swagger
18import SpecCommon
19import Test.Hspec hiding (example)
21spec :: Spec
22spec = do
23 describe "License Object" $ licenseExample <=> licenseExampleJSON
24 describe "Contact Object" $ contactExample <=> contactExampleJSON
25 describe "Info Object" $ infoExample <=> infoExampleJSON
26 describe "Operation Object" $ operationExample <=> operationExampleJSON
27 describe "Schema Object" $ do
28 context "Primitive Sample" $ schemaPrimitiveExample <=> schemaPrimitiveExampleJSON
29 context "Simple Model" $ schemaSimpleModelExample <=> schemaSimpleModelExampleJSON
30 context "Model with Map/Dictionary Properties" $ schemaModelDictExample <=> schemaModelDictExampleJSON
31 context "Model with Example" $ schemaWithExampleExample <=> schemaWithExampleExampleJSON
32 describe "Definitions Object" $ definitionsExample <=> definitionsExampleJSON
33 describe "Parameters Definition Object" $ paramsDefinitionExample <=> paramsDefinitionExampleJSON
34 describe "Responses Definition Object" $ responsesDefinitionExample <=> responsesDefinitionExampleJSON
35 describe "Security Definitions Object" $ securityDefinitionsExample <=> securityDefinitionsExampleJSON
36 describe "Swagger Object" $ do
37 context "Todo Example" $ swaggerExample <=> swaggerExampleJSON
38 context "PetStore Example" $
39 it "decodes successfully" $ do
40 fromJSON petstoreExampleJSON `shouldSatisfy` (\x -> case x of Success (_ :: Swagger) -> True; _ -> False)
42main :: IO ()
43main = hspec spec
45-- =======================================================================
46-- Info object
47-- =======================================================================
49infoExample :: Info
50infoExample = mempty
51 & title .~ "Swagger Sample App"
52 & description ?~ "This is a sample server Petstore server."
53 & termsOfService ?~ "http://swagger.io/terms/"
54 & contact ?~ contactExample
55 & license ?~ licenseExample
56 & version .~ "1.0.1"
58infoExampleJSON :: Value
59infoExampleJSON = [aesonQQ|
61 "title": "Swagger Sample App",
62 "description": "This is a sample server Petstore server.",
63 "termsOfService": "http://swagger.io/terms/",
64 "contact": {
65 "name": "API Support",
66 "url": "http://www.swagger.io/support",
67 "email": "support@swagger.io"
68 },
69 "license": {
70 "name": "Apache 2.0",
71 "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
72 },
73 "version": "1.0.1"
75|]
77-- =======================================================================
78-- Contact object
79-- =======================================================================
81contactExample :: Contact
82contactExample = mempty
83 & name ?~ "API Support"
84 & url ?~ URL "http://www.swagger.io/support"
85 & email ?~ "support@swagger.io"
87contactExampleJSON :: Value
88contactExampleJSON = [aesonQQ|
90 "name": "API Support",
91 "url": "http://www.swagger.io/support",
92 "email": "support@swagger.io"
94|]
96-- =======================================================================
97-- License object
98-- =======================================================================
100licenseExample :: License
101licenseExample = License "Apache 2.0" (Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html"))
103licenseExampleJSON :: Value
104licenseExampleJSON = [aesonQQ|
106 "name": "Apache 2.0",
107 "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
109|]
112-- =======================================================================
113-- Operation object
114-- =======================================================================
116operationExample :: Operation
117operationExample = mempty
118 & tags .~ ["pet"]
119 & summary ?~ "Updates a pet in the store with form data"
120 & description ?~ ""
121 & operationId ?~ "updatePetWithForm"
122 & consumes ?~ MimeList ["application/x-www-form-urlencoded"]
123 & produces ?~ MimeList ["application/json", "application/xml"]
124 & parameters .~ map Inline
125 [ mempty
126 & name .~ "petId"
127 & description ?~ "ID of pet that needs to be updated"
128 & required ?~ True
129 & schema .~ ParamOther (stringSchema ParamPath)
130 , mempty
131 & name .~ "name"
132 & description ?~ "Updated name of the pet"
133 & required ?~ False
134 & schema .~ ParamOther (stringSchema ParamFormData)
135 , mempty
136 & name .~ "status"
137 & description ?~ "Updated status of the pet"
138 & required ?~ False
139 & schema .~ ParamOther (stringSchema ParamFormData)
140 ]
142 & responses .~ (mempty & responses .~
143 [ (200, Inline (mempty & description .~ "Pet updated."))
144 , (405, Inline (mempty & description .~ "Invalid input")) ])
145 & security .~ [SecurityRequirement [("petstore_auth", ["write:pets", "read:pets"])]]
146 where
147 stringSchema :: ParamLocation -> ParamOtherSchema
148 stringSchema loc = mempty
149 & in_ .~ loc
150 & type_ .~ SwaggerString
152operationExampleJSON :: Value
153operationExampleJSON = [aesonQQ|
155 "tags": [
156 "pet"
157 ],
158 "summary": "Updates a pet in the store with form data",
159 "description": "",
160 "operationId": "updatePetWithForm",
161 "consumes": [
162 "application/x-www-form-urlencoded"
163 ],
164 "produces": [
165 "application/json",
166 "application/xml"
167 ],
168 "parameters": [
169 {
170 "name": "petId",
171 "in": "path",
172 "description": "ID of pet that needs to be updated",
173 "required": true,
174 "type": "string"
175 },
176 {
177 "name": "name",
178 "in": "formData",
179 "description": "Updated name of the pet",
180 "required": false,
181 "type": "string"
182 },
183 {
184 "name": "status",
185 "in": "formData",
186 "description": "Updated status of the pet",
187 "required": false,
188 "type": "string"
189 }
190 ],
191 "responses": {
192 "200": {
193 "description": "Pet updated."
194 },
195 "405": {
196 "description": "Invalid input"
197 }
198 },
199 "security": [
200 {
201 "petstore_auth": [
202 "write:pets",
203 "read:pets"
204 ]
205 }
206 ]
208|]
210-- =======================================================================
211-- Schema object
212-- =======================================================================
214schemaPrimitiveExample :: Schema
215schemaPrimitiveExample = mempty
216 & type_ .~ SwaggerString
217 & format ?~ "email"
219schemaPrimitiveExampleJSON :: Value
220schemaPrimitiveExampleJSON = [aesonQQ|
222 "type": "string",
223 "format": "email"
225|]
227schemaSimpleModelExample :: Schema
228schemaSimpleModelExample = mempty
229 & type_ .~ SwaggerObject
230 & required .~ [ "name" ]
231 & properties .~
232 [ ("name", Inline (mempty & type_ .~ SwaggerString))
233 , ("address", Ref (Reference "Address"))
234 , ("age", Inline $ mempty
235 & minimum_ ?~ 0
236 & type_ .~ SwaggerInteger
237 & format ?~ "int32" ) ]
239schemaSimpleModelExampleJSON :: Value
240schemaSimpleModelExampleJSON = [aesonQQ|
242 "type": "object",
243 "required": [
244 "name"
245 ],
246 "properties": {
247 "name": {
248 "type": "string"
249 },
250 "address": {
251 "$ref": "#/definitions/Address"
252 },
253 "age": {
254 "type": "integer",
255 "format": "int32",
256 "minimum": 0
257 }
258 }
260|]
262schemaModelDictExample :: Schema
263schemaModelDictExample = mempty
264 & type_ .~ SwaggerObject
265 & additionalProperties ?~ (mempty & type_ .~ SwaggerString)
267schemaModelDictExampleJSON :: Value
268schemaModelDictExampleJSON = [aesonQQ|
270 "type": "object",
271 "additionalProperties": {
272 "type": "string"
273 }
275|]
277schemaWithExampleExample :: Schema
278schemaWithExampleExample = mempty
279 & type_ .~ SwaggerObject
280 & properties .~
281 [ ("id", Inline $ mempty
282 & type_ .~ SwaggerInteger
283 & format ?~ "int64" )
284 , ("name", Inline $ mempty
285 & type_ .~ SwaggerString) ]
286 & required .~ [ "name" ]
287 & example ?~ [aesonQQ|
288 {
289 "name": "Puma",
290 "id": 1
291 }
292 |]
294schemaWithExampleExampleJSON :: Value
295schemaWithExampleExampleJSON = [aesonQQ|
297 "type": "object",
298 "properties": {
299 "id": {
300 "type": "integer",
301 "format": "int64"
302 },
303 "name": {
304 "type": "string"
305 }
306 },
307 "required": [
308 "name"
309 ],
310 "example": {
311 "name": "Puma",
312 "id": 1
313 }
315|]
317-- =======================================================================
318-- Definitions object
319-- =======================================================================
321definitionsExample :: HashMap Text Schema
322definitionsExample =
323 [ ("Category", mempty
324 & type_ .~ SwaggerObject
325 & properties .~
326 [ ("id", Inline $ mempty
327 & type_ .~ SwaggerInteger
328 & format ?~ "int64")
329 , ("name", Inline (mempty & type_ .~ SwaggerString)) ] )
330 , ("Tag", mempty
331 & type_ .~ SwaggerObject
332 & properties .~
333 [ ("id", Inline $ mempty
334 & type_ .~ SwaggerInteger
335 & format ?~ "int64")
336 , ("name", Inline (mempty & type_ .~ SwaggerString)) ] ) ]
338definitionsExampleJSON :: Value
339definitionsExampleJSON = [aesonQQ|
341 "Category": {
342 "type": "object",
343 "properties": {
344 "id": {
345 "type": "integer",
346 "format": "int64"
347 },
348 "name": {
349 "type": "string"
350 }
351 }
352 },
353 "Tag": {
354 "type": "object",
355 "properties": {
356 "id": {
357 "type": "integer",
358 "format": "int64"
359 },
360 "name": {
361 "type": "string"
362 }
363 }
364 }
366|]
368-- =======================================================================
369-- Parameters Definition object
370-- =======================================================================
372paramsDefinitionExample :: HashMap Text Param
373paramsDefinitionExample =
374 [ ("skipParam", mempty
375 & name .~ "skip"
376 & description ?~ "number of items to skip"
377 & required ?~ True
378 & schema .~ ParamOther (mempty
379 & in_ .~ ParamQuery
380 & type_ .~ SwaggerInteger
381 & format ?~ "int32" ))
382 , ("limitParam", mempty
383 & name .~ "limit"
384 & description ?~ "max records to return"
385 & required ?~ True
386 & schema .~ ParamOther (mempty
387 & in_ .~ ParamQuery
388 & type_ .~ SwaggerInteger
389 & format ?~ "int32" )) ]
391paramsDefinitionExampleJSON :: Value
392paramsDefinitionExampleJSON = [aesonQQ|
394 "skipParam": {
395 "name": "skip",
396 "in": "query",
397 "description": "number of items to skip",
398 "required": true,
399 "type": "integer",
400 "format": "int32"
401 },
402 "limitParam": {
403 "name": "limit",
404 "in": "query",
405 "description": "max records to return",
406 "required": true,
407 "type": "integer",
408 "format": "int32"
409 }
411|]
413-- =======================================================================
414-- Responses Definition object
415-- =======================================================================
417responsesDefinitionExample :: HashMap Text Response
418responsesDefinitionExample =
419 [ ("NotFound", mempty & description .~ "Entity not found.")
420 , ("IllegalInput", mempty & description .~ "Illegal input for operation.") ]
422responsesDefinitionExampleJSON :: Value
423responsesDefinitionExampleJSON = [aesonQQ|
425 "NotFound": {
426 "description": "Entity not found."
427 },
428 "IllegalInput": {
429 "description": "Illegal input for operation."
430 }
432|]
434-- =======================================================================
435-- Responses Definition object
436-- =======================================================================
438securityDefinitionsExample :: HashMap Text SecurityScheme
439securityDefinitionsExample =
440 [ ("api_key", SecurityScheme
441 { _securitySchemeType = SecuritySchemeApiKey (ApiKeyParams "api_key" ApiKeyHeader)
442 , _securitySchemeDescription = Nothing })
443 , ("petstore_auth", SecurityScheme
444 { _securitySchemeType = SecuritySchemeOAuth2 (OAuth2Params
445 { _oauth2Flow = OAuth2Implicit "http://swagger.io/api/oauth/dialog"
446 , _oauth2Scopes =
447 [ ("write:pets", "modify pets in your account")
448 , ("read:pets", "read your pets") ] } )
449 , _securitySchemeDescription = Nothing }) ]
451securityDefinitionsExampleJSON :: Value
452securityDefinitionsExampleJSON = [aesonQQ|
454 "api_key": {
455 "type": "apiKey",
456 "name": "api_key",
457 "in": "header"
458 },
459 "petstore_auth": {
460 "type": "oauth2",
461 "authorizationUrl": "http://swagger.io/api/oauth/dialog",
462 "flow": "implicit",
463 "scopes": {
464 "write:pets": "modify pets in your account",
465 "read:pets": "read your pets"
466 }
467 }
469|]
471-- =======================================================================
472-- Swagger object
473-- =======================================================================
475swaggerExample :: Swagger
476swaggerExample = mempty
477 & basePath ?~ "/"
478 & schemes ?~ [Http]
479 & info .~ (mempty
480 & version .~ "1.0"
481 & title .~ "Todo API"
482 & license ?~ License "MIT" (Just (URL "http://mit.com"))
483 & description ?~ "This is a an API that tests servant-swagger support for a Todo API")
484 & paths.at "/todo/{id}" ?~ (mempty & get ?~ ((mempty :: Operation)
485 & at 200 ?~ Inline (mempty
486 & description .~ "OK"
487 & schema ?~ Inline (mempty
488 & type_ .~ SwaggerObject
489 & example ?~ [aesonQQ|
490 {
491 "created": 100,
492 "description": "get milk"
493 } |]
494 & description ?~ "This is some real Todo right here"
495 & properties .~
496 [ ("created", Inline $ mempty
497 & type_ .~ SwaggerInteger
498 & format ?~ "int32")
499 , ("description", Inline (mempty & type_ .~ SwaggerString))]))
500 & produces ?~ MimeList [ "application/json" ]
501 & parameters .~
502 [ Inline $ mempty
503 & required ?~ True
504 & name .~ "id"
505 & description ?~ "TodoId param"
506 & schema .~ ParamOther (mempty
507 & in_ .~ ParamPath
508 & type_ .~ SwaggerString ) ]
509 & tags .~ [ "todo" ] ))
511swaggerExampleJSON :: Value
512swaggerExampleJSON = [aesonQQ|
514 "swagger": "2.0",
515 "basePath": "/",
516 "schemes": [
517 "http"
518 ],
519 "info": {
520 "version": "1.0",
521 "title": "Todo API",
522 "license": {
523 "url": "http://mit.com",
524 "name": "MIT"
525 },
526 "description": "This is a an API that tests servant-swagger support for a Todo API"
527 },
528 "paths": {
529 "/todo/{id}": {
530 "get": {
531 "responses": {
532 "200": {
533 "schema": {
534 "example": {
535 "created": 100,
536 "description": "get milk"
537 },
538 "type": "object",
539 "description": "This is some real Todo right here",
540 "properties": {
541 "created": {
542 "format": "int32",
543 "type": "integer"
544 },
545 "description": {
546 "type": "string"
547 }
548 }
549 },
550 "description": "OK"
551 }
552 },
553 "produces": [
554 "application/json"
555 ],
556 "parameters": [
557 {
558 "required": true,
559 "in": "path",
560 "name": "id",
561 "type": "string",
562 "description": "TodoId param"
563 }
564 ],
565 "tags": [
566 "todo"
567 ]
568 }
569 }
570 }
572|]
574petstoreExampleJSON :: Value
575petstoreExampleJSON = [aesonQQ|
576{
577 "swagger":"2.0",
578 "info":{
579 "description":"This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
580 "version":"1.0.0",
581 "title":"Swagger Petstore",
582 "termsOfService":"http://swagger.io/terms/",
583 "contact":{
584 "email":"apiteam@swagger.io"
585 },
586 "license":{
587 "name":"Apache 2.0",
588 "url":"http://www.apache.org/licenses/LICENSE-2.0.html"
589 }
590 },
591 "host":"petstore.swagger.io",
592 "basePath":"/v2",
593 "tags":[
594 {
595 "name":"pet",
596 "description":"Everything about your Pets",
597 "externalDocs":{
598 "description":"Find out more",
599 "url":"http://swagger.io"
600 }
601 },
602 {
603 "name":"store",
604 "description":"Access to Petstore orders"
605 },
606 {
607 "name":"user",
608 "description":"Operations about user",
609 "externalDocs":{
610 "description":"Find out more about our store",
611 "url":"http://swagger.io"
612 }
613 }
614 ],
615 "schemes":[
616 "http"
617 ],
618 "paths":{
619 "/pet":{
620 "post":{
621 "tags":[
622 "pet"
623 ],
624 "summary":"Add a new pet to the store",
625 "description":"",
626 "operationId":"addPet",
627 "consumes":[
628 "application/json",
629 "application/xml"
630 ],
631 "produces":[
632 "application/xml",
633 "application/json"
634 ],
635 "parameters":[
636 {
637 "in":"body",
638 "name":"body",
639 "description":"Pet object that needs to be added to the store",
640 "required":true,
641 "schema":{
642 "$ref":"#/definitions/Pet"
643 }
644 }
645 ],
646 "responses":{
647 "405":{
648 "description":"Invalid input"
649 }
650 },
651 "security":[
652 {
653 "petstore_auth":[
654 "write:pets",
655 "read:pets"
656 ]
657 }
658 ]
659 },
660 "put":{
661 "tags":[
662 "pet"
663 ],
664 "summary":"Update an existing pet",
665 "description":"",
666 "operationId":"updatePet",
667 "consumes":[
668 "application/json",
669 "application/xml"
670 ],
671 "produces":[
672 "application/xml",
673 "application/json"
674 ],
675 "parameters":[
676 {
677 "in":"body",
678 "name":"body",
679 "description":"Pet object that needs to be added to the store",
680 "required":true,
681 "schema":{
682 "$ref":"#/definitions/Pet"
683 }
684 }
685 ],
686 "responses":{
687 "400":{
688 "description":"Invalid ID supplied"
689 },
690 "404":{
691 "description":"Pet not found"
692 },
693 "405":{
694 "description":"Validation exception"
695 }
696 },
697 "security":[
698 {
699 "petstore_auth":[
700 "write:pets",
701 "read:pets"
702 ]
703 }
704 ]
705 }
706 },
707 "/pet/findByStatus":{
708 "get":{
709 "tags":[
710 "pet"
711 ],
712 "summary":"Finds Pets by status",
713 "description":"Multiple status values can be provided with comma seperated strings",
714 "operationId":"findPetsByStatus",
715 "produces":[
716 "application/xml",
717 "application/json"
718 ],
719 "parameters":[
720 {
721 "name":"status",
722 "in":"query",
723 "description":"Status values that need to be considered for filter",
724 "required":true,
725 "type":"array",
726 "items":{
727 "type":"string",
728 "enum":[
729 "available",
730 "pending",
731 "sold"
732 ],
733 "default":"available"
734 },
735 "collectionFormat":"csv"
736 }
737 ],
738 "responses":{
739 "200":{
740 "description":"successful operation",
741 "schema":{
742 "type":"array",
743 "items":{
744 "$ref":"#/definitions/Pet"
745 }
746 }
747 },
748 "400":{
749 "description":"Invalid status value"
750 }
751 },
752 "security":[
753 {
754 "petstore_auth":[
755 "write:pets",
756 "read:pets"
757 ]
758 }
759 ]
760 }
761 },
762 "/pet/findByTags":{
763 "get":{
764 "tags":[
765 "pet"
766 ],
767 "summary":"Finds Pets by tags",
768 "description":"Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
769 "operationId":"findPetsByTags",
770 "produces":[
771 "application/xml",
772 "application/json"
773 ],
774 "parameters":[
775 {
776 "name":"tags",
777 "in":"query",
778 "description":"Tags to filter by",
779 "required":true,
780 "type":"array",
781 "items":{
782 "type":"string"
783 },
784 "collectionFormat":"csv"
785 }
786 ],
787 "responses":{
788 "200":{
789 "description":"successful operation",
790 "schema":{
791 "type":"array",
792 "items":{
793 "$ref":"#/definitions/Pet"
794 }
795 }
796 },
797 "400":{
798 "description":"Invalid tag value"
799 }
800 },
801 "security":[
802 {
803 "petstore_auth":[
804 "write:pets",
805 "read:pets"
806 ]
807 }
808 ]
809 }
810 },
811 "/pet/{petId}":{
812 "get":{
813 "tags":[
814 "pet"
815 ],
816 "summary":"Find pet by ID",
817 "description":"Returns a single pet",
818 "operationId":"getPetById",
819 "produces":[
820 "application/xml",
821 "application/json"
822 ],
823 "parameters":[
824 {
825 "name":"petId",
826 "in":"path",
827 "description":"ID of pet to return",
828 "required":true,
829 "type":"integer",
830 "format":"int64"
831 }
832 ],
833 "responses":{
834 "200":{
835 "description":"successful operation",
836 "schema":{
837 "$ref":"#/definitions/Pet"
838 }
839 },
840 "400":{
841 "description":"Invalid ID supplied"
842 },
843 "404":{
844 "description":"Pet not found"
845 }
846 },
847 "security":[
848 {
849 "api_key": []
850 }
851 ]
852 },
853 "post":{
854 "tags":[
855 "pet"
856 ],
857 "summary":"Updates a pet in the store with form data",
858 "description":"",
859 "operationId":"updatePetWithForm",
860 "consumes":[
861 "application/x-www-form-urlencoded"
862 ],
863 "produces":[
864 "application/xml",
865 "application/json"
866 ],
867 "parameters":[
868 {
869 "name":"petId",
870 "in":"path",
871 "description":"ID of pet that needs to be updated",
872 "required":true,
873 "type":"integer",
874 "format":"int64"
875 },
876 {
877 "name":"name",
878 "in":"formData",
879 "description":"Updated name of the pet",
880 "required":false,
881 "type":"string"
882 },
883 {
884 "name":"status",
885 "in":"formData",
886 "description":"Updated status of the pet",
887 "required":false,
888 "type":"string"
889 }
890 ],
891 "responses":{
892 "405":{
893 "description":"Invalid input"
894 }
895 },
896 "security":[
897 {
898 "petstore_auth":[
899 "write:pets",
900 "read:pets"
901 ]
902 }
903 ]
904 },
905 "delete":{
906 "tags":[
907 "pet"
908 ],
909 "summary":"Deletes a pet",
910 "description":"",
911 "operationId":"deletePet",
912 "produces":[
913 "application/xml",
914 "application/json"
915 ],
916 "parameters":[
917 {
918 "name":"api_key",
919 "in":"header",
920 "required":false,
921 "type":"string"
922 },
923 {
924 "name":"petId",
925 "in":"path",
926 "description":"Pet id to delete",
927 "required":true,
928 "type":"integer",
929 "format":"int64"
930 }
931 ],
932 "responses":{
933 "400":{
934 "description":"Invalid pet value"
935 }
936 },
937 "security":[
938 {
939 "petstore_auth":[
940 "write:pets",
941 "read:pets"
942 ]
943 }
944 ]
945 }
946 },
947 "/pet/{petId}/uploadImage":{
948 "post":{
949 "tags":[
950 "pet"
951 ],
952 "summary":"uploads an image",
953 "description":"",
954 "operationId":"uploadFile",
955 "consumes":[
956 "multipart/form-data"
957 ],
958 "produces":[
959 "application/json"
960 ],
961 "parameters":[
962 {
963 "name":"petId",
964 "in":"path",
965 "description":"ID of pet to update",
966 "required":true,
967 "type":"integer",
968 "format":"int64"
969 },
970 {
971 "name":"additionalMetadata",
972 "in":"formData",
973 "description":"Additional data to pass to server",
974 "required":false,
975 "type":"string"
976 },
977 {
978 "name":"file",
979 "in":"formData",
980 "description":"file to upload",
981 "required":false,
982 "type":"file"
983 }
984 ],
985 "responses":{
986 "200":{
987 "description":"successful operation",
988 "schema":{
989 "$ref":"#/definitions/ApiResponse"
990 }
991 }
992 },
993 "security":[
994 {
995 "petstore_auth":[
996 "write:pets",
997 "read:pets"
998 ]
999 }
1002 },
1003 "/store/inventory":{
1004 "get":{
1005 "tags":[
1006 "store"
1007 ],
1008 "summary":"Returns pet inventories by status",
1009 "description":"Returns a map of status codes to quantities",
1010 "operationId":"getInventory",
1011 "produces":[
1012 "application/json"
1013 ],
1014 "parameters": [],
1015 "responses":{
1016 "200":{
1017 "description":"successful operation",
1018 "schema":{
1019 "type":"object",
1020 "additionalProperties":{
1021 "type":"integer",
1022 "format":"int32"
1026 },
1027 "security":[
1028 {
1029 "api_key": []
1033 },
1034 "/store/order":{
1035 "post":{
1036 "tags":[
1037 "store"
1038 ],
1039 "summary":"Place an order for a pet",
1040 "description":"",
1041 "operationId":"placeOrder",
1042 "produces":[
1043 "application/xml",
1044 "application/json"
1045 ],
1046 "parameters":[
1047 {
1048 "in":"body",
1049 "name":"body",
1050 "description":"order placed for purchasing the pet",
1051 "required":true,
1052 "schema":{
1053 "$ref":"#/definitions/Order"
1056 ],
1057 "responses":{
1058 "200":{
1059 "description":"successful operation",
1060 "schema":{
1061 "$ref":"#/definitions/Order"
1063 },
1064 "400":{
1065 "description":"Invalid Order"
1069 },
1070 "/store/order/{orderId}":{
1071 "get":{
1072 "tags":[
1073 "store"
1074 ],
1075 "summary":"Find purchase order by ID",
1076 "description":"For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
1077 "operationId":"getOrderById",
1078 "produces":[
1079 "application/xml",
1080 "application/json"
1081 ],
1082 "parameters":[
1083 {
1084 "name":"orderId",
1085 "in":"path",
1086 "description":"ID of pet that needs to be fetched",
1087 "required":true,
1088 "type":"integer",
1089 "maximum":5.0,
1090 "minimum":1.0,
1091 "format":"int64"
1093 ],
1094 "responses":{
1095 "200":{
1096 "description":"successful operation",
1097 "schema":{
1098 "$ref":"#/definitions/Order"
1100 },
1101 "400":{
1102 "description":"Invalid ID supplied"
1103 },
1104 "404":{
1105 "description":"Order not found"
1108 },
1109 "delete":{
1110 "tags":[
1111 "store"
1112 ],
1113 "summary":"Delete purchase order by ID",
1114 "description":"For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
1115 "operationId":"deleteOrder",
1116 "produces":[
1117 "application/xml",
1118 "application/json"
1119 ],
1120 "parameters":[
1121 {
1122 "name":"orderId",
1123 "in":"path",
1124 "description":"ID of the order that needs to be deleted",
1125 "required":true,
1126 "type":"string",
1127 "minimum":1.0
1129 ],
1130 "responses":{
1131 "400":{
1132 "description":"Invalid ID supplied"
1133 },
1134 "404":{
1135 "description":"Order not found"
1139 },
1140 "/user":{
1141 "post":{
1142 "tags":[
1143 "user"
1144 ],
1145 "summary":"Create user",
1146 "description":"This can only be done by the logged in user.",
1147 "operationId":"createUser",
1148 "produces":[
1149 "application/xml",
1150 "application/json"
1151 ],
1152 "parameters":[
1153 {
1154 "in":"body",
1155 "name":"body",
1156 "description":"Created user object",
1157 "required":true,
1158 "schema":{
1159 "$ref":"#/definitions/User"
1162 ],
1163 "responses":{
1164 "default":{
1165 "description":"successful operation"
1169 },
1170 "/user/createWithArray":{
1171 "post":{
1172 "tags":[
1173 "user"
1174 ],
1175 "summary":"Creates list of users with given input array",
1176 "description":"",
1177 "operationId":"createUsersWithArrayInput",
1178 "produces":[
1179 "application/xml",
1180 "application/json"
1181 ],
1182 "parameters":[
1183 {
1184 "in":"body",
1185 "name":"body",
1186 "description":"List of user object",
1187 "required":true,
1188 "schema":{
1189 "type":"array",
1190 "items":{
1191 "$ref":"#/definitions/User"
1195 ],
1196 "responses":{
1197 "default":{
1198 "description":"successful operation"
1202 },
1203 "/user/createWithList":{
1204 "post":{
1205 "tags":[
1206 "user"
1207 ],
1208 "summary":"Creates list of users with given input array",
1209 "description":"",
1210 "operationId":"createUsersWithListInput",
1211 "produces":[
1212 "application/xml",
1213 "application/json"
1214 ],
1215 "parameters":[
1216 {
1217 "in":"body",
1218 "name":"body",
1219 "description":"List of user object",
1220 "required":true,
1221 "schema":{
1222 "type":"array",
1223 "items":{
1224 "$ref":"#/definitions/User"
1228 ],
1229 "responses":{
1230 "default":{
1231 "description":"successful operation"
1235 },
1236 "/user/login":{
1237 "get":{
1238 "tags":[
1239 "user"
1240 ],
1241 "summary":"Logs user into the system",
1242 "description":"",
1243 "operationId":"loginUser",
1244 "produces":[
1245 "application/xml",
1246 "application/json"
1247 ],
1248 "parameters":[
1249 {
1250 "name":"username",
1251 "in":"query",
1252 "description":"The user name for login",
1253 "required":true,
1254 "type":"string"
1255 },
1256 {
1257 "name":"password",
1258 "in":"query",
1259 "description":"The password for login in clear text",
1260 "required":true,
1261 "type":"string"
1263 ],
1264 "responses":{
1265 "200":{
1266 "description":"successful operation",
1267 "schema":{
1268 "type":"string"
1269 },
1270 "headers":{
1271 "X-Rate-Limit":{
1272 "type":"integer",
1273 "format":"int32",
1274 "description":"calls per hour allowed by the user"
1275 },
1276 "X-Expires-After":{
1277 "type":"string",
1278 "format":"date-time",
1279 "description":"date in UTC when toekn expires"
1282 },
1283 "400":{
1284 "description":"Invalid username/password supplied"
1288 },
1289 "/user/logout":{
1290 "get":{
1291 "tags":[
1292 "user"
1293 ],
1294 "summary":"Logs out current logged in user session",
1295 "description":"",
1296 "operationId":"logoutUser",
1297 "produces":[
1298 "application/xml",
1299 "application/json"
1300 ],
1301 "parameters": [],
1302 "responses":{
1303 "default":{
1304 "description":"successful operation"
1308 },
1309 "/user/{username}":{
1310 "get":{
1311 "tags":[
1312 "user"
1313 ],
1314 "summary":"Get user by user name",
1315 "description":"",
1316 "operationId":"getUserByName",
1317 "produces":[
1318 "application/xml",
1319 "application/json"
1320 ],
1321 "parameters":[
1322 {
1323 "name":"username",
1324 "in":"path",
1325 "description":"The name that needs to be fetched. Use user1 for testing. ",
1326 "required":true,
1327 "type":"string"
1329 ],
1330 "responses":{
1331 "200":{
1332 "description":"successful operation",
1333 "schema":{
1334 "$ref":"#/definitions/User"
1336 },
1337 "400":{
1338 "description":"Invalid username supplied"
1339 },
1340 "404":{
1341 "description":"User not found"
1344 },
1345 "put":{
1346 "tags":[
1347 "user"
1348 ],
1349 "summary":"Updated user",
1350 "description":"This can only be done by the logged in user.",
1351 "operationId":"updateUser",
1352 "produces":[
1353 "application/xml",
1354 "application/json"
1355 ],
1356 "parameters":[
1357 {
1358 "name":"username",
1359 "in":"path",
1360 "description":"name that need to be deleted",
1361 "required":true,
1362 "type":"string"
1363 },
1364 {
1365 "in":"body",
1366 "name":"body",
1367 "description":"Updated user object",
1368 "required":true,
1369 "schema":{
1370 "$ref":"#/definitions/User"
1373 ],
1374 "responses":{
1375 "400":{
1376 "description":"Invalid user supplied"
1377 },
1378 "404":{
1379 "description":"User not found"
1382 },
1383 "delete":{
1384 "tags":[
1385 "user"
1386 ],
1387 "summary":"Delete user",
1388 "description":"This can only be done by the logged in user.",
1389 "operationId":"deleteUser",
1390 "produces":[
1391 "application/xml",
1392 "application/json"
1393 ],
1394 "parameters":[
1395 {
1396 "name":"username",
1397 "in":"path",
1398 "description":"The name that needs to be deleted",
1399 "required":true,
1400 "type":"string"
1402 ],
1403 "responses":{
1404 "400":{
1405 "description":"Invalid username supplied"
1406 },
1407 "404":{
1408 "description":"User not found"
1413 },
1414 "securityDefinitions":{
1415 "petstore_auth":{
1416 "type":"oauth2",
1417 "authorizationUrl":"http://petstore.swagger.io/api/oauth/dialog",
1418 "flow":"implicit",
1419 "scopes":{
1420 "write:pets":"modify pets in your account",
1421 "read:pets":"read your pets"
1423 },
1424 "api_key":{
1425 "type":"apiKey",
1426 "name":"api_key",
1427 "in":"header"
1429 },
1430 "definitions":{
1431 "Order":{
1432 "type":"object",
1433 "properties":{
1434 "id":{
1435 "type":"integer",
1436 "format":"int64"
1437 },
1438 "petId":{
1439 "type":"integer",
1440 "format":"int64"
1441 },
1442 "quantity":{
1443 "type":"integer",
1444 "format":"int32"
1445 },
1446 "shipDate":{
1447 "type":"string",
1448 "format":"date-time"
1449 },
1450 "status":{
1451 "type":"string",
1452 "description":"Order Status",
1453 "enum":[
1454 "placed",
1455 "approved",
1456 "delivered"
1458 },
1459 "complete":{
1460 "type":"boolean",
1461 "default":false
1463 },
1464 "xml":{
1465 "name":"Order"
1467 },
1468 "Category":{
1469 "type":"object",
1470 "properties":{
1471 "id":{
1472 "type":"integer",
1473 "format":"int64"
1474 },
1475 "name":{
1476 "type":"string"
1478 },
1479 "xml":{
1480 "name":"Category"
1482 },
1483 "User":{
1484 "type":"object",
1485 "properties":{
1486 "id":{
1487 "type":"integer",
1488 "format":"int64"
1489 },
1490 "username":{
1491 "type":"string"
1492 },
1493 "firstName":{
1494 "type":"string"
1495 },
1496 "lastName":{
1497 "type":"string"
1498 },
1499 "email":{
1500 "type":"string"
1501 },
1502 "password":{
1503 "type":"string"
1504 },
1505 "phone":{
1506 "type":"string"
1507 },
1508 "userStatus":{
1509 "type":"integer",
1510 "format":"int32",
1511 "description":"User Status"
1513 },
1514 "xml":{
1515 "name":"User"
1517 },
1518 "Tag":{
1519 "type":"object",
1520 "properties":{
1521 "id":{
1522 "type":"integer",
1523 "format":"int64"
1524 },
1525 "name":{
1526 "type":"string"
1528 },
1529 "xml":{
1530 "name":"Tag"
1532 },
1533 "Pet":{
1534 "type":"object",
1535 "required":[
1536 "name",
1537 "photoUrls"
1538 ],
1539 "properties":{
1540 "id":{
1541 "type":"integer",
1542 "format":"int64"
1543 },
1544 "category":{
1545 "$ref":"#/definitions/Category"
1546 },
1547 "name":{
1548 "type":"string",
1549 "example":"doggie"
1550 },
1551 "photoUrls":{
1552 "type":"array",
1553 "xml":{
1554 "name":"photoUrl",
1555 "wrapped":true
1556 },
1557 "items":{
1558 "type":"string"
1560 },
1561 "tags":{
1562 "type":"array",
1563 "xml":{
1564 "name":"tag",
1565 "wrapped":true
1566 },
1567 "items":{
1568 "$ref":"#/definitions/Tag"
1570 },
1571 "status":{
1572 "type":"string",
1573 "description":"pet status in the store",
1574 "enum":[
1575 "available",
1576 "pending",
1577 "sold"
1580 },
1581 "xml":{
1582 "name":"Pet"
1584 },
1585 "ApiResponse":{
1586 "type":"object",
1587 "properties":{
1588 "code":{
1589 "type":"integer",
1590 "format":"int32"
1591 },
1592 "type":{
1593 "type":"string"
1594 },
1595 "message":{
1596 "type":"string"
1600 },
1601 "externalDocs":{
1602 "description":"Find out more about Swagger",
1603 "url":"http://swagger.io"