git.iko.soy/typeable/swagger2
on master help sign in
Merge pull request #55 from vertigomedia/port-parsing

Port parsing

commitad04ad27cfbabafd34202b4623b4da7888ea7882 authorNickolay Kudasov <fizruk@users.noreply.github.com> dateFri 4 Mar 2016, 11:45 (11 years ago) parentcd66be7006bdb0
3 files changed+313−305
.ghci+1 src/Data/Swagger/Internal.hs+6−7 test/Data/SwaggerSpec.hs+306−298
.ghcinew file+1
@@ -0,0 +1 @@
1+:set -itest -isrc -optP-include -optP.stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/autogen/cabal_macros.h -optP-I -optPinclude
src/Data/Swagger/Internal.hs+6−7
@@ -1088,13 +1088,12 @@ instance OVERLAPPABLE_ FromJSON (SwaggerItems Schema) where
10881088 parseJSON _ = empty
10891089
10901090instance FromJSON Host where
1091− parseJSON (String s) =
1092− case fromInteger <$> readMaybe portStr of
1093− Nothing | not (null portStr) -> fail $ "Invalid port `" ++ portStr ++ "'"
1094− mport -> pure $ Host host mport
1095− where
1096− (hostText, portText) = Text.breakOn ":" s
1097− [host, portStr] = map Text.unpack [hostText, portText]
1091+ parseJSON (String s) = case map Text.unpack $ Text.split (== ':') s of
1092+ [host] -> return $ Host host Nothing
1093+ [host, port] -> case readMaybe port of
1094+ Nothing -> fail $ "Invalid port `" ++ port ++ "'"
1095+ Just p -> return $ Host host (Just (fromInteger p))
1096+ _ -> fail $ "Invalid host `" ++ Text.unpack s ++ "'"
10981097 parseJSON _ = empty
10991098
11001099instance FromJSON MimeList where
test/Data/SwaggerSpec.hs+306−298
@@ -21,6 +21,14 @@ import Test.Hspec hiding (example)
2121
2222spec :: Spec
2323spec = do
24+ describe "host" $ do
25+ it "can decode the host port" $ do
26+ let h = Just $ Host "localhost" (Just (fromInteger 8000))
27+ swagger :: Swagger
28+ swagger = swaggerExample
29+ & host .~ h
30+ parsed :: Swagger = either error id $ eitherDecode' $ encode swagger
31+ parsed ^. host `shouldBe` h
2432 describe "License Object" $ licenseExample <=> licenseExampleJSON
2533 describe "Contact Object" $ contactExample <=> contactExampleJSON
2634 describe "Info Object" $ infoExample <=> infoExampleJSON
@@ -493,7 +501,7 @@ swaggerExample = mempty
493501 "created": 100,
494502 "description": "get milk"
495503 } |]
496− & description ?~ "This is some real Todo right here"
504+ & description ?~ "This is some real Todo right here"
497505 & properties .~
498506 [ ("created", Inline $ mempty
499507 & type_ .~ SwaggerInteger
@@ -575,130 +583,130 @@ swaggerExampleJSON = [aesonQQ|
575583
576584petstoreExampleJSON :: Value
577585petstoreExampleJSON = [aesonQQ|
578−{
586+{
579587 "swagger":"2.0",
580− "info":{
588+ "info":{
581589 "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.",
582590 "version":"1.0.0",
583591 "title":"Swagger Petstore",
584592 "termsOfService":"http://swagger.io/terms/",
585− "contact":{
593+ "contact":{
586594 "email":"apiteam@swagger.io"
587595 },
588− "license":{
596+ "license":{
589597 "name":"Apache 2.0",
590598 "url":"http://www.apache.org/licenses/LICENSE-2.0.html"
591599 }
592600 },
593601 "host":"petstore.swagger.io",
594602 "basePath":"/v2",
595− "tags":[
596− {
603+ "tags":[
604+ {
597605 "name":"pet",
598606 "description":"Everything about your Pets",
599− "externalDocs":{
607+ "externalDocs":{
600608 "description":"Find out more",
601609 "url":"http://swagger.io"
602610 }
603611 },
604− {
612+ {
605613 "name":"store",
606614 "description":"Access to Petstore orders"
607615 },
608− {
616+ {
609617 "name":"user",
610618 "description":"Operations about user",
611− "externalDocs":{
619+ "externalDocs":{
612620 "description":"Find out more about our store",
613621 "url":"http://swagger.io"
614622 }
615623 }
616624 ],
617− "schemes":[
625+ "schemes":[
618626 "http"
619627 ],
620− "paths":{
621− "/pet":{
622− "post":{
623− "tags":[
628+ "paths":{
629+ "/pet":{
630+ "post":{
631+ "tags":[
624632 "pet"
625633 ],
626634 "summary":"Add a new pet to the store",
627635 "description":"",
628636 "operationId":"addPet",
629− "consumes":[
637+ "consumes":[
630638 "application/json",
631639 "application/xml"
632640 ],
633− "produces":[
641+ "produces":[
634642 "application/xml",
635643 "application/json"
636644 ],
637− "parameters":[
638− {
645+ "parameters":[
646+ {
639647 "in":"body",
640648 "name":"body",
641649 "description":"Pet object that needs to be added to the store",
642650 "required":true,
643− "schema":{
651+ "schema":{
644652 "$ref":"#/definitions/Pet"
645653 }
646654 }
647655 ],
648− "responses":{
649− "405":{
656+ "responses":{
657+ "405":{
650658 "description":"Invalid input"
651659 }
652660 },
653− "security":[
654− {
655− "petstore_auth":[
661+ "security":[
662+ {
663+ "petstore_auth":[
656664 "write:pets",
657665 "read:pets"
658666 ]
659667 }
660668 ]
661669 },
662− "put":{
663− "tags":[
670+ "put":{
671+ "tags":[
664672 "pet"
665673 ],
666674 "summary":"Update an existing pet",
667675 "description":"",
668676 "operationId":"updatePet",
669− "consumes":[
677+ "consumes":[
670678 "application/json",
671679 "application/xml"
672680 ],
673− "produces":[
681+ "produces":[
674682 "application/xml",
675683 "application/json"
676684 ],
677− "parameters":[
678− {
685+ "parameters":[
686+ {
679687 "in":"body",
680688 "name":"body",
681689 "description":"Pet object that needs to be added to the store",
682690 "required":true,
683− "schema":{
691+ "schema":{
684692 "$ref":"#/definitions/Pet"
685693 }
686694 }
687695 ],
688− "responses":{
689− "400":{
696+ "responses":{
697+ "400":{
690698 "description":"Invalid ID supplied"
691699 },
692− "404":{
700+ "404":{
693701 "description":"Pet not found"
694702 },
695− "405":{
703+ "405":{
696704 "description":"Validation exception"
697705 }
698706 },
699− "security":[
700− {
701− "petstore_auth":[
707+ "security":[
708+ {
709+ "petstore_auth":[
702710 "write:pets",
703711 "read:pets"
704712 ]
@@ -706,28 +714,28 @@ petstoreExampleJSON = [aesonQQ|
706714 ]
707715 }
708716 },
709− "/pet/findByStatus":{
710− "get":{
711− "tags":[
717+ "/pet/findByStatus":{
718+ "get":{
719+ "tags":[
712720 "pet"
713721 ],
714722 "summary":"Finds Pets by status",
715723 "description":"Multiple status values can be provided with comma seperated strings",
716724 "operationId":"findPetsByStatus",
717− "produces":[
725+ "produces":[
718726 "application/xml",
719727 "application/json"
720728 ],
721− "parameters":[
722− {
729+ "parameters":[
730+ {
723731 "name":"status",
724732 "in":"query",
725733 "description":"Status values that need to be considered for filter",
726734 "required":true,
727735 "type":"array",
728− "items":{
736+ "items":{
729737 "type":"string",
730− "enum":[
738+ "enum":[
731739 "available",
732740 "pending",
733741 "sold"
@@ -737,23 +745,23 @@ petstoreExampleJSON = [aesonQQ|
737745 "collectionFormat":"csv"
738746 }
739747 ],
740− "responses":{
741− "200":{
748+ "responses":{
749+ "200":{
742750 "description":"successful operation",
743− "schema":{
751+ "schema":{
744752 "type":"array",
745− "items":{
753+ "items":{
746754 "$ref":"#/definitions/Pet"
747755 }
748756 }
749757 },
750− "400":{
758+ "400":{
751759 "description":"Invalid status value"
752760 }
753761 },
754− "security":[
755− {
756− "petstore_auth":[
762+ "security":[
763+ {
764+ "petstore_auth":[
757765 "write:pets",
758766 "read:pets"
759767 ]
@@ -761,48 +769,48 @@ petstoreExampleJSON = [aesonQQ|
761769 ]
762770 }
763771 },
764− "/pet/findByTags":{
765− "get":{
766− "tags":[
772+ "/pet/findByTags":{
773+ "get":{
774+ "tags":[
767775 "pet"
768776 ],
769777 "summary":"Finds Pets by tags",
770778 "description":"Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
771779 "operationId":"findPetsByTags",
772− "produces":[
780+ "produces":[
773781 "application/xml",
774782 "application/json"
775783 ],
776− "parameters":[
777− {
784+ "parameters":[
785+ {
778786 "name":"tags",
779787 "in":"query",
780788 "description":"Tags to filter by",
781789 "required":true,
782790 "type":"array",
783− "items":{
791+ "items":{
784792 "type":"string"
785793 },
786794 "collectionFormat":"csv"
787795 }
788796 ],
789− "responses":{
790− "200":{
797+ "responses":{
798+ "200":{
791799 "description":"successful operation",
792− "schema":{
800+ "schema":{
793801 "type":"array",
794− "items":{
802+ "items":{
795803 "$ref":"#/definitions/Pet"
796804 }
797805 }
798806 },
799− "400":{
807+ "400":{
800808 "description":"Invalid tag value"
801809 }
802810 },
803− "security":[
804− {
805− "petstore_auth":[
811+ "security":[
812+ {
813+ "petstore_auth":[
806814 "write:pets",
807815 "read:pets"
808816 ]
@@ -810,20 +818,20 @@ petstoreExampleJSON = [aesonQQ|
810818 ]
811819 }
812820 },
813− "/pet/{petId}":{
814− "get":{
815− "tags":[
821+ "/pet/{petId}":{
822+ "get":{
823+ "tags":[
816824 "pet"
817825 ],
818826 "summary":"Find pet by ID",
819827 "description":"Returns a single pet",
820828 "operationId":"getPetById",
821− "produces":[
829+ "produces":[
822830 "application/xml",
823831 "application/json"
824832 ],
825− "parameters":[
826− {
833+ "parameters":[
834+ {
827835 "name":"petId",
828836 "in":"path",
829837 "description":"ID of pet to return",
@@ -832,42 +840,42 @@ petstoreExampleJSON = [aesonQQ|
832840 "format":"int64"
833841 }
834842 ],
835− "responses":{
836− "200":{
843+ "responses":{
844+ "200":{
837845 "description":"successful operation",
838− "schema":{
846+ "schema":{
839847 "$ref":"#/definitions/Pet"
840848 }
841849 },
842− "400":{
850+ "400":{
843851 "description":"Invalid ID supplied"
844852 },
845− "404":{
853+ "404":{
846854 "description":"Pet not found"
847855 }
848856 },
849− "security":[
850− {
857+ "security":[
858+ {
851859 "api_key": []
852860 }
853861 ]
854862 },
855− "post":{
856− "tags":[
863+ "post":{
864+ "tags":[
857865 "pet"
858866 ],
859867 "summary":"Updates a pet in the store with form data",
860868 "description":"",
861869 "operationId":"updatePetWithForm",
862− "consumes":[
870+ "consumes":[
863871 "application/x-www-form-urlencoded"
864872 ],
865− "produces":[
873+ "produces":[
866874 "application/xml",
867875 "application/json"
868876 ],
869− "parameters":[
870− {
877+ "parameters":[
878+ {
871879 "name":"petId",
872880 "in":"path",
873881 "description":"ID of pet that needs to be updated",
@@ -875,14 +883,14 @@ petstoreExampleJSON = [aesonQQ|
875883 "type":"integer",
876884 "format":"int64"
877885 },
878− {
886+ {
879887 "name":"name",
880888 "in":"formData",
881889 "description":"Updated name of the pet",
882890 "required":false,
883891 "type":"string"
884892 },
885− {
893+ {
886894 "name":"status",
887895 "in":"formData",
888896 "description":"Updated status of the pet",
@@ -890,39 +898,39 @@ petstoreExampleJSON = [aesonQQ|
890898 "type":"string"
891899 }
892900 ],
893− "responses":{
894− "405":{
901+ "responses":{
902+ "405":{
895903 "description":"Invalid input"
896904 }
897905 },
898− "security":[
899− {
900− "petstore_auth":[
906+ "security":[
907+ {
908+ "petstore_auth":[
901909 "write:pets",
902910 "read:pets"
903911 ]
904912 }
905913 ]
906914 },
907− "delete":{
908− "tags":[
915+ "delete":{
916+ "tags":[
909917 "pet"
910918 ],
911919 "summary":"Deletes a pet",
912920 "description":"",
913921 "operationId":"deletePet",
914− "produces":[
922+ "produces":[
915923 "application/xml",
916924 "application/json"
917925 ],
918− "parameters":[
919− {
926+ "parameters":[
927+ {
920928 "name":"api_key",
921929 "in":"header",
922930 "required":false,
923931 "type":"string"
924932 },
925− {
933+ {
926934 "name":"petId",
927935 "in":"path",
928936 "description":"Pet id to delete",
@@ -931,14 +939,14 @@ petstoreExampleJSON = [aesonQQ|
931939 "format":"int64"
932940 }
933941 ],
934− "responses":{
935− "400":{
942+ "responses":{
943+ "400":{
936944 "description":"Invalid pet value"
937945 }
938946 },
939− "security":[
940− {
941− "petstore_auth":[
947+ "security":[
948+ {
949+ "petstore_auth":[
942950 "write:pets",
943951 "read:pets"
944952 ]
@@ -946,22 +954,22 @@ petstoreExampleJSON = [aesonQQ|
946954 ]
947955 }
948956 },
949− "/pet/{petId}/uploadImage":{
950− "post":{
951− "tags":[
957+ "/pet/{petId}/uploadImage":{
958+ "post":{
959+ "tags":[
952960 "pet"
953961 ],
954962 "summary":"uploads an image",
955963 "description":"",
956964 "operationId":"uploadFile",
957− "consumes":[
965+ "consumes":[
958966 "multipart/form-data"
959967 ],
960− "produces":[
968+ "produces":[
961969 "application/json"
962970 ],
963− "parameters":[
964− {
971+ "parameters":[
972+ {
965973 "name":"petId",
966974 "in":"path",
967975 "description":"ID of pet to update",
@@ -969,14 +977,14 @@ petstoreExampleJSON = [aesonQQ|
969977 "type":"integer",
970978 "format":"int64"
971979 },
972− {
980+ {
973981 "name":"additionalMetadata",
974982 "in":"formData",
975983 "description":"Additional data to pass to server",
976984 "required":false,
977985 "type":"string"
978986 },
979− {
987+ {
980988 "name":"file",
981989 "in":"formData",
982990 "description":"file to upload",
@@ -984,17 +992,17 @@ petstoreExampleJSON = [aesonQQ|
984992 "type":"file"
985993 }
986994 ],
987− "responses":{
988− "200":{
995+ "responses":{
996+ "200":{
989997 "description":"successful operation",
990− "schema":{
998+ "schema":{
991999 "$ref":"#/definitions/ApiResponse"
9921000 }
9931001 }
9941002 },
995− "security":[
996− {
997− "petstore_auth":[
1003+ "security":[
1004+ {
1005+ "petstore_auth":[
9981006 "write:pets",
9991007 "read:pets"
10001008 ]
@@ -1002,87 +1010,87 @@ petstoreExampleJSON = [aesonQQ|
10021010 ]
10031011 }
10041012 },
1005− "/store/inventory":{
1006− "get":{
1007− "tags":[
1013+ "/store/inventory":{
1014+ "get":{
1015+ "tags":[
10081016 "store"
10091017 ],
10101018 "summary":"Returns pet inventories by status",
10111019 "description":"Returns a map of status codes to quantities",
10121020 "operationId":"getInventory",
1013− "produces":[
1021+ "produces":[
10141022 "application/json"
10151023 ],
10161024 "parameters": [],
1017− "responses":{
1018− "200":{
1025+ "responses":{
1026+ "200":{
10191027 "description":"successful operation",
1020− "schema":{
1028+ "schema":{
10211029 "type":"object",
1022− "additionalProperties":{
1030+ "additionalProperties":{
10231031 "type":"integer",
10241032 "format":"int32"
10251033 }
10261034 }
10271035 }
10281036 },
1029− "security":[
1030− {
1037+ "security":[
1038+ {
10311039 "api_key": []
10321040 }
10331041 ]
10341042 }
10351043 },
1036− "/store/order":{
1037− "post":{
1038− "tags":[
1044+ "/store/order":{
1045+ "post":{
1046+ "tags":[
10391047 "store"
10401048 ],
10411049 "summary":"Place an order for a pet",
10421050 "description":"",
10431051 "operationId":"placeOrder",
1044− "produces":[
1052+ "produces":[
10451053 "application/xml",
10461054 "application/json"
10471055 ],
1048− "parameters":[
1049− {
1056+ "parameters":[
1057+ {
10501058 "in":"body",
10511059 "name":"body",
10521060 "description":"order placed for purchasing the pet",
10531061 "required":true,
1054− "schema":{
1062+ "schema":{
10551063 "$ref":"#/definitions/Order"
10561064 }
10571065 }
10581066 ],
1059− "responses":{
1060− "200":{
1067+ "responses":{
1068+ "200":{
10611069 "description":"successful operation",
1062− "schema":{
1070+ "schema":{
10631071 "$ref":"#/definitions/Order"
10641072 }
10651073 },
1066− "400":{
1074+ "400":{
10671075 "description":"Invalid Order"
10681076 }
10691077 }
10701078 }
10711079 },
1072− "/store/order/{orderId}":{
1073− "get":{
1074− "tags":[
1080+ "/store/order/{orderId}":{
1081+ "get":{
1082+ "tags":[
10751083 "store"
10761084 ],
10771085 "summary":"Find purchase order by ID",
10781086 "description":"For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
10791087 "operationId":"getOrderById",
1080− "produces":[
1088+ "produces":[
10811089 "application/xml",
10821090 "application/json"
10831091 ],
1084− "parameters":[
1085− {
1092+ "parameters":[
1093+ {
10861094 "name":"orderId",
10871095 "in":"path",
10881096 "description":"ID of pet that needs to be fetched",
@@ -1093,34 +1101,34 @@ petstoreExampleJSON = [aesonQQ|
10931101 "format":"int64"
10941102 }
10951103 ],
1096− "responses":{
1097− "200":{
1104+ "responses":{
1105+ "200":{
10981106 "description":"successful operation",
1099− "schema":{
1107+ "schema":{
11001108 "$ref":"#/definitions/Order"
11011109 }
11021110 },
1103− "400":{
1111+ "400":{
11041112 "description":"Invalid ID supplied"
11051113 },
1106− "404":{
1114+ "404":{
11071115 "description":"Order not found"
11081116 }
11091117 }
11101118 },
1111− "delete":{
1112− "tags":[
1119+ "delete":{
1120+ "tags":[
11131121 "store"
11141122 ],
11151123 "summary":"Delete purchase order by ID",
11161124 "description":"For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
11171125 "operationId":"deleteOrder",
1118− "produces":[
1126+ "produces":[
11191127 "application/xml",
11201128 "application/json"
11211129 ],
1122− "parameters":[
1123− {
1130+ "parameters":[
1131+ {
11241132 "name":"orderId",
11251133 "in":"path",
11261134 "description":"ID of the order that needs to be deleted",
@@ -1129,133 +1137,133 @@ petstoreExampleJSON = [aesonQQ|
11291137 "minimum":1.0
11301138 }
11311139 ],
1132− "responses":{
1133− "400":{
1140+ "responses":{
1141+ "400":{
11341142 "description":"Invalid ID supplied"
11351143 },
1136− "404":{
1144+ "404":{
11371145 "description":"Order not found"
11381146 }
11391147 }
11401148 }
11411149 },
1142− "/user":{
1143− "post":{
1144− "tags":[
1150+ "/user":{
1151+ "post":{
1152+ "tags":[
11451153 "user"
11461154 ],
11471155 "summary":"Create user",
11481156 "description":"This can only be done by the logged in user.",
11491157 "operationId":"createUser",
1150− "produces":[
1158+ "produces":[
11511159 "application/xml",
11521160 "application/json"
11531161 ],
1154− "parameters":[
1155− {
1162+ "parameters":[
1163+ {
11561164 "in":"body",
11571165 "name":"body",
11581166 "description":"Created user object",
11591167 "required":true,
1160− "schema":{
1168+ "schema":{
11611169 "$ref":"#/definitions/User"
11621170 }
11631171 }
11641172 ],
1165− "responses":{
1166− "default":{
1173+ "responses":{
1174+ "default":{
11671175 "description":"successful operation"
11681176 }
11691177 }
11701178 }
11711179 },
1172− "/user/createWithArray":{
1173− "post":{
1174− "tags":[
1180+ "/user/createWithArray":{
1181+ "post":{
1182+ "tags":[
11751183 "user"
11761184 ],
11771185 "summary":"Creates list of users with given input array",
11781186 "description":"",
11791187 "operationId":"createUsersWithArrayInput",
1180− "produces":[
1188+ "produces":[
11811189 "application/xml",
11821190 "application/json"
11831191 ],
1184− "parameters":[
1185− {
1192+ "parameters":[
1193+ {
11861194 "in":"body",
11871195 "name":"body",
11881196 "description":"List of user object",
11891197 "required":true,
1190− "schema":{
1198+ "schema":{
11911199 "type":"array",
1192− "items":{
1200+ "items":{
11931201 "$ref":"#/definitions/User"
11941202 }
11951203 }
11961204 }
11971205 ],
1198− "responses":{
1199− "default":{
1206+ "responses":{
1207+ "default":{
12001208 "description":"successful operation"
12011209 }
12021210 }
12031211 }
12041212 },
1205− "/user/createWithList":{
1206− "post":{
1207− "tags":[
1213+ "/user/createWithList":{
1214+ "post":{
1215+ "tags":[
12081216 "user"
12091217 ],
12101218 "summary":"Creates list of users with given input array",
12111219 "description":"",
12121220 "operationId":"createUsersWithListInput",
1213− "produces":[
1221+ "produces":[
12141222 "application/xml",
12151223 "application/json"
12161224 ],
1217− "parameters":[
1218− {
1225+ "parameters":[
1226+ {
12191227 "in":"body",
12201228 "name":"body",
12211229 "description":"List of user object",
12221230 "required":true,
1223− "schema":{
1231+ "schema":{
12241232 "type":"array",
1225− "items":{
1233+ "items":{
12261234 "$ref":"#/definitions/User"
12271235 }
12281236 }
12291237 }
12301238 ],
1231− "responses":{
1232− "default":{
1239+ "responses":{
1240+ "default":{
12331241 "description":"successful operation"
12341242 }
12351243 }
12361244 }
12371245 },
1238− "/user/login":{
1239− "get":{
1240− "tags":[
1246+ "/user/login":{
1247+ "get":{
1248+ "tags":[
12411249 "user"
12421250 ],
12431251 "summary":"Logs user into the system",
12441252 "description":"",
12451253 "operationId":"loginUser",
1246− "produces":[
1254+ "produces":[
12471255 "application/xml",
12481256 "application/json"
12491257 ],
1250− "parameters":[
1251− {
1258+ "parameters":[
1259+ {
12521260 "name":"username",
12531261 "in":"query",
12541262 "description":"The user name for login",
12551263 "required":true,
12561264 "type":"string"
12571265 },
1258− {
1266+ {
12591267 "name":"password",
12601268 "in":"query",
12611269 "description":"The password for login in clear text",
@@ -1263,65 +1271,65 @@ petstoreExampleJSON = [aesonQQ|
12631271 "type":"string"
12641272 }
12651273 ],
1266− "responses":{
1267− "200":{
1274+ "responses":{
1275+ "200":{
12681276 "description":"successful operation",
1269− "schema":{
1277+ "schema":{
12701278 "type":"string"
12711279 },
1272− "headers":{
1273− "X-Rate-Limit":{
1280+ "headers":{
1281+ "X-Rate-Limit":{
12741282 "type":"integer",
12751283 "format":"int32",
12761284 "description":"calls per hour allowed by the user"
12771285 },
1278− "X-Expires-After":{
1286+ "X-Expires-After":{
12791287 "type":"string",
12801288 "format":"date-time",
12811289 "description":"date in UTC when toekn expires"
12821290 }
12831291 }
12841292 },
1285− "400":{
1293+ "400":{
12861294 "description":"Invalid username/password supplied"
12871295 }
12881296 }
12891297 }
12901298 },
1291− "/user/logout":{
1292− "get":{
1293− "tags":[
1299+ "/user/logout":{
1300+ "get":{
1301+ "tags":[
12941302 "user"
12951303 ],
12961304 "summary":"Logs out current logged in user session",
12971305 "description":"",
12981306 "operationId":"logoutUser",
1299− "produces":[
1307+ "produces":[
13001308 "application/xml",
13011309 "application/json"
13021310 ],
13031311 "parameters": [],
1304− "responses":{
1305− "default":{
1312+ "responses":{
1313+ "default":{
13061314 "description":"successful operation"
13071315 }
13081316 }
13091317 }
13101318 },
1311− "/user/{username}":{
1312− "get":{
1313− "tags":[
1319+ "/user/{username}":{
1320+ "get":{
1321+ "tags":[
13141322 "user"
13151323 ],
13161324 "summary":"Get user by user name",
13171325 "description":"",
13181326 "operationId":"getUserByName",
1319− "produces":[
1327+ "produces":[
13201328 "application/xml",
13211329 "application/json"
13221330 ],
1323− "parameters":[
1324− {
1331+ "parameters":[
1332+ {
13251333 "name":"username",
13261334 "in":"path",
13271335 "description":"The name that needs to be fetched. Use user1 for testing. ",
@@ -1329,72 +1337,72 @@ petstoreExampleJSON = [aesonQQ|
13291337 "type":"string"
13301338 }
13311339 ],
1332− "responses":{
1333− "200":{
1340+ "responses":{
1341+ "200":{
13341342 "description":"successful operation",
1335− "schema":{
1343+ "schema":{
13361344 "$ref":"#/definitions/User"
13371345 }
13381346 },
1339− "400":{
1347+ "400":{
13401348 "description":"Invalid username supplied"
13411349 },
1342− "404":{
1350+ "404":{
13431351 "description":"User not found"
13441352 }
13451353 }
13461354 },
1347− "put":{
1348− "tags":[
1355+ "put":{
1356+ "tags":[
13491357 "user"
13501358 ],
13511359 "summary":"Updated user",
13521360 "description":"This can only be done by the logged in user.",
13531361 "operationId":"updateUser",
1354− "produces":[
1362+ "produces":[
13551363 "application/xml",
13561364 "application/json"
13571365 ],
1358− "parameters":[
1359− {
1366+ "parameters":[
1367+ {
13601368 "name":"username",
13611369 "in":"path",
13621370 "description":"name that need to be deleted",
13631371 "required":true,
13641372 "type":"string"
13651373 },
1366− {
1374+ {
13671375 "in":"body",
13681376 "name":"body",
13691377 "description":"Updated user object",
13701378 "required":true,
1371− "schema":{
1379+ "schema":{
13721380 "$ref":"#/definitions/User"
13731381 }
13741382 }
13751383 ],
1376− "responses":{
1377− "400":{
1384+ "responses":{
1385+ "400":{
13781386 "description":"Invalid user supplied"
13791387 },
1380− "404":{
1388+ "404":{
13811389 "description":"User not found"
13821390 }
13831391 }
13841392 },
1385− "delete":{
1386− "tags":[
1393+ "delete":{
1394+ "tags":[
13871395 "user"
13881396 ],
13891397 "summary":"Delete user",
13901398 "description":"This can only be done by the logged in user.",
13911399 "operationId":"deleteUser",
1392− "produces":[
1400+ "produces":[
13931401 "application/xml",
13941402 "application/json"
13951403 ],
1396− "parameters":[
1397− {
1404+ "parameters":[
1405+ {
13981406 "name":"username",
13991407 "in":"path",
14001408 "description":"The name that needs to be deleted",
@@ -1402,205 +1410,205 @@ petstoreExampleJSON = [aesonQQ|
14021410 "type":"string"
14031411 }
14041412 ],
1405− "responses":{
1406− "400":{
1413+ "responses":{
1414+ "400":{
14071415 "description":"Invalid username supplied"
14081416 },
1409− "404":{
1417+ "404":{
14101418 "description":"User not found"
14111419 }
14121420 }
14131421 }
14141422 }
14151423 },
1416− "securityDefinitions":{
1417− "petstore_auth":{
1424+ "securityDefinitions":{
1425+ "petstore_auth":{
14181426 "type":"oauth2",
14191427 "authorizationUrl":"http://petstore.swagger.io/api/oauth/dialog",
14201428 "flow":"implicit",
1421− "scopes":{
1429+ "scopes":{
14221430 "write:pets":"modify pets in your account",
14231431 "read:pets":"read your pets"
14241432 }
14251433 },
1426− "api_key":{
1434+ "api_key":{
14271435 "type":"apiKey",
14281436 "name":"api_key",
14291437 "in":"header"
14301438 }
14311439 },
1432− "definitions":{
1433− "Order":{
1440+ "definitions":{
1441+ "Order":{
14341442 "type":"object",
1435− "properties":{
1436− "id":{
1443+ "properties":{
1444+ "id":{
14371445 "type":"integer",
14381446 "format":"int64"
14391447 },
1440− "petId":{
1448+ "petId":{
14411449 "type":"integer",
14421450 "format":"int64"
14431451 },
1444− "quantity":{
1452+ "quantity":{
14451453 "type":"integer",
14461454 "format":"int32"
14471455 },
1448− "shipDate":{
1456+ "shipDate":{
14491457 "type":"string",
14501458 "format":"date-time"
14511459 },
1452− "status":{
1460+ "status":{
14531461 "type":"string",
14541462 "description":"Order Status",
1455− "enum":[
1463+ "enum":[
14561464 "placed",
14571465 "approved",
14581466 "delivered"
14591467 ]
14601468 },
1461− "complete":{
1469+ "complete":{
14621470 "type":"boolean",
14631471 "default":false
14641472 }
14651473 },
1466− "xml":{
1474+ "xml":{
14671475 "name":"Order"
14681476 }
14691477 },
1470− "Category":{
1478+ "Category":{
14711479 "type":"object",
1472− "properties":{
1473− "id":{
1480+ "properties":{
1481+ "id":{
14741482 "type":"integer",
14751483 "format":"int64"
14761484 },
1477− "name":{
1485+ "name":{
14781486 "type":"string"
14791487 }
14801488 },
1481− "xml":{
1489+ "xml":{
14821490 "name":"Category"
14831491 }
14841492 },
1485− "User":{
1493+ "User":{
14861494 "type":"object",
1487− "properties":{
1488− "id":{
1495+ "properties":{
1496+ "id":{
14891497 "type":"integer",
14901498 "format":"int64"
14911499 },
1492− "username":{
1500+ "username":{
14931501 "type":"string"
14941502 },
1495− "firstName":{
1503+ "firstName":{
14961504 "type":"string"
14971505 },
1498− "lastName":{
1506+ "lastName":{
14991507 "type":"string"
15001508 },
1501− "email":{
1509+ "email":{
15021510 "type":"string"
15031511 },
1504− "password":{
1512+ "password":{
15051513 "type":"string"
15061514 },
1507− "phone":{
1515+ "phone":{
15081516 "type":"string"
15091517 },
1510− "userStatus":{
1518+ "userStatus":{
15111519 "type":"integer",
15121520 "format":"int32",
15131521 "description":"User Status"
15141522 }
15151523 },
1516− "xml":{
1524+ "xml":{
15171525 "name":"User"
15181526 }
15191527 },
1520− "Tag":{
1528+ "Tag":{
15211529 "type":"object",
1522− "properties":{
1523− "id":{
1530+ "properties":{
1531+ "id":{
15241532 "type":"integer",
15251533 "format":"int64"
15261534 },
1527− "name":{
1535+ "name":{
15281536 "type":"string"
15291537 }
15301538 },
1531− "xml":{
1539+ "xml":{
15321540 "name":"Tag"
15331541 }
15341542 },
1535− "Pet":{
1543+ "Pet":{
15361544 "type":"object",
1537− "required":[
1545+ "required":[
15381546 "name",
15391547 "photoUrls"
15401548 ],
1541− "properties":{
1542− "id":{
1549+ "properties":{
1550+ "id":{
15431551 "type":"integer",
15441552 "format":"int64"
15451553 },
1546− "category":{
1554+ "category":{
15471555 "$ref":"#/definitions/Category"
15481556 },
1549− "name":{
1557+ "name":{
15501558 "type":"string",
15511559 "example":"doggie"
15521560 },
1553− "photoUrls":{
1561+ "photoUrls":{
15541562 "type":"array",
1555− "xml":{
1563+ "xml":{
15561564 "name":"photoUrl",
15571565 "wrapped":true
15581566 },
1559− "items":{
1567+ "items":{
15601568 "type":"string"
15611569 }
15621570 },
1563− "tags":{
1571+ "tags":{
15641572 "type":"array",
1565− "xml":{
1573+ "xml":{
15661574 "name":"tag",
15671575 "wrapped":true
15681576 },
1569− "items":{
1577+ "items":{
15701578 "$ref":"#/definitions/Tag"
15711579 }
15721580 },
1573− "status":{
1581+ "status":{
15741582 "type":"string",
15751583 "description":"pet status in the store",
1576− "enum":[
1584+ "enum":[
15771585 "available",
15781586 "pending",
15791587 "sold"
15801588 ]
15811589 }
15821590 },
1583− "xml":{
1591+ "xml":{
15841592 "name":"Pet"
15851593 }
15861594 },
1587− "ApiResponse":{
1595+ "ApiResponse":{
15881596 "type":"object",
1589− "properties":{
1590− "code":{
1597+ "properties":{
1598+ "code":{
15911599 "type":"integer",
15921600 "format":"int32"
15931601 },
1594− "type":{
1602+ "type":{
15951603 "type":"string"
15961604 },
1597− "message":{
1605+ "message":{
15981606 "type":"string"
15991607 }
16001608 }
16011609 }
16021610 },
1603− "externalDocs":{
1611+ "externalDocs":{
16041612 "description":"Find out more about Swagger",
16051613 "url":"http://swagger.io"
16061614 }