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