@@ -1,5 +1,6 @@
1{-# LANGUAGE OverloadedLists #-}
1{-# LANGUAGE OverloadedLists #-}
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE QuasiQuotes #-}
4{-# LANGUAGE QuasiQuotes #-}
4module Data.SwaggerSpec where
5module Data.SwaggerSpec where
@@ -54,7 +55,11 @@ spec = do
54 describe "Parameters Definition Object" $ parametersDefinitionExample <~> parametersDefinitionExampleJSON
55 describe "Parameters Definition Object" $ parametersDefinitionExample <~> parametersDefinitionExampleJSON
55 describe "Responses Definition Object" $ responsesDefinitionExample <~> responsesDefinitionExampleJSON
56 describe "Responses Definition Object" $ responsesDefinitionExample <~> responsesDefinitionExampleJSON
56 describe "Security Definitions Object" $ securityDefinitionsExample <~> securityDefinitionsExampleJSON
57 describe "Security Definitions Object" $ securityDefinitionsExample <~> securityDefinitionsExampleJSON
58+ describe "Swagger Object" $ do
57− describe "Swagger Object" $ swaggerExample <~> swaggerExampleJSON
59+ context "Todo Example" $ swaggerExample <~> swaggerExampleJSON
60+ context "PetStore Example" $
61+ it "decodes successfully" $ do
62+ fromJSON petstoreExampleJSON `shouldSatisfy` (\x -> case x of Success (_ :: Swagger) -> True; _ -> False)
59main :: IO ()
64main :: IO ()
60main = hspec spec
65main = hspec spec
@@ -614,3 +619,1045 @@ swaggerExampleJSON = [aesonQQ|
623+petstoreExampleJSON :: Value
624+petstoreExampleJSON = [aesonQQ|
628+ "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.",
630+ "title":"Swagger Petstore",
631+ "termsOfService":"http://swagger.io/terms/",
633+ "email":"apiteam@swagger.io"
636+ "name":"Apache 2.0",
637+ "url":"http://www.apache.org/licenses/LICENSE-2.0.html"
640+ "host":"petstore.swagger.io",
645+ "description":"Everything about your Pets",
647+ "description":"Find out more",
648+ "url":"http://swagger.io"
653+ "description":"Access to Petstore orders"
657+ "description":"Operations about user",
659+ "description":"Find out more about our store",
660+ "url":"http://swagger.io"
673+ "summary":"Add a new pet to the store",
675+ "operationId":"addPet",
688+ "description":"Pet object that needs to be added to the store",
691+ "$ref":"#/definitions/Pet"
697+ "description":"Invalid input"
713+ "summary":"Update an existing pet",
715+ "operationId":"updatePet",
728+ "description":"Pet object that needs to be added to the store",
731+ "$ref":"#/definitions/Pet"
737+ "description":"Invalid ID supplied"
740+ "description":"Pet not found"
743+ "description":"Validation exception"
756+ "/pet/findByStatus":{
761+ "summary":"Finds Pets by status",
762+ "description":"Multiple status values can be provided with comma seperated strings",
763+ "operationId":"findPetsByStatus",
772+ "description":"Status values that need to be considered for filter",
782+ "default":"available"
784+ "collectionFormat":"csv"
789+ "description":"successful operation",
793+ "$ref":"#/definitions/Pet"
798+ "description":"Invalid status value"
816+ "summary":"Finds Pets by tags",
817+ "description":"Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
818+ "operationId":"findPetsByTags",
827+ "description":"Tags to filter by",
833+ "collectionFormat":"csv"
838+ "description":"successful operation",
842+ "$ref":"#/definitions/Pet"
847+ "description":"Invalid tag value"
865+ "summary":"Find pet by ID",
866+ "description":"Returns a single pet",
867+ "operationId":"getPetById",
876+ "description":"ID of pet to return",
884+ "description":"successful operation",
886+ "$ref":"#/definitions/Pet"
890+ "description":"Invalid ID supplied"
893+ "description":"Pet not found"
908+ "summary":"Updates a pet in the store with form data",
910+ "operationId":"updatePetWithForm",
912+ "application/x-www-form-urlencoded"
922+ "description":"ID of pet that needs to be updated",
930+ "description":"Updated name of the pet",
937+ "description":"Updated status of the pet",
944+ "description":"Invalid input"
960+ "summary":"Deletes a pet",
962+ "operationId":"deletePet",
977+ "description":"Pet id to delete",
985+ "description":"Invalid pet value"
998+ "/pet/{petId}/uploadImage":{
1003+ "summary":"uploads an image",
1005+ "operationId":"uploadFile",
1007+ "multipart/form-data"
1016+ "description":"ID of pet to update",
1022+ "name":"additionalMetadata",
1024+ "description":"Additional data to pass to server",
1031+ "description":"file to upload",
1038+ "description":"successful operation",
1040+ "$ref":"#/definitions/ApiResponse"
1054+ "/store/inventory":{
1059+ "summary":"Returns pet inventories by status",
1060+ "description":"Returns a map of status codes to quantities",
1061+ "operationId":"getInventory",
1070+ "description":"successful operation",
1073+ "additionalProperties":{
1094+ "summary":"Place an order for a pet",
1096+ "operationId":"placeOrder",
1105+ "description":"order placed for purchasing the pet",
1108+ "$ref":"#/definitions/Order"
1114+ "description":"successful operation",
1116+ "$ref":"#/definitions/Order"
1120+ "description":"Invalid Order"
1125+ "/store/order/{orderId}":{
1130+ "summary":"Find purchase order by ID",
1131+ "description":"For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
1132+ "operationId":"getOrderById",
1141+ "description":"ID of pet that needs to be fetched",
1151+ "description":"successful operation",
1153+ "$ref":"#/definitions/Order"
1157+ "description":"Invalid ID supplied"
1160+ "description":"Order not found"
1168+ "summary":"Delete purchase order by ID",
1169+ "description":"For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
1170+ "operationId":"deleteOrder",
1179+ "description":"ID of the order that needs to be deleted",
1187+ "description":"Invalid ID supplied"
1190+ "description":"Order not found"
1200+ "summary":"Create user",
1201+ "description":"This can only be done by the logged in user.",
1202+ "operationId":"createUser",
1211+ "description":"Created user object",
1214+ "$ref":"#/definitions/User"
1220+ "description":"successful operation"
1225+ "/user/createWithArray":{
1230+ "summary":"Creates list of users with given input array",
1232+ "operationId":"createUsersWithArrayInput",
1241+ "description":"List of user object",
1246+ "$ref":"#/definitions/User"
1253+ "description":"successful operation"
1258+ "/user/createWithList":{
1263+ "summary":"Creates list of users with given input array",
1265+ "operationId":"createUsersWithListInput",
1274+ "description":"List of user object",
1279+ "$ref":"#/definitions/User"
1286+ "description":"successful operation"
1296+ "summary":"Logs user into the system",
1298+ "operationId":"loginUser",
1307+ "description":"The user name for login",
1314+ "description":"The password for login in clear text",
1321+ "description":"successful operation",
1329+ "description":"calls per hour allowed by the user"
1331+ "X-Expires-After":{
1333+ "format":"date-time",
1334+ "description":"date in UTC when toekn expires"
1339+ "description":"Invalid username/password supplied"
1349+ "summary":"Logs out current logged in user session",
1351+ "operationId":"logoutUser",
1361+ "description":"successful operation"
1366+ "/user/{username}":{
1371+ "summary":"Get user by user name",
1373+ "operationId":"getUserByName",
1382+ "description":"The name that needs to be fetched. Use user1 for testing. ",
1389+ "description":"successful operation",
1391+ "$ref":"#/definitions/User"
1395+ "description":"Invalid username supplied"
1398+ "description":"User not found"
1406+ "summary":"Updated user",
1407+ "description":"This can only be done by the logged in user.",
1408+ "operationId":"updateUser",
1417+ "description":"name that need to be deleted",
1424+ "description":"Updated user object",
1427+ "$ref":"#/definitions/User"
1433+ "description":"Invalid user supplied"
1436+ "description":"User not found"
1444+ "summary":"Delete user",
1445+ "description":"This can only be done by the logged in user.",
1446+ "operationId":"deleteUser",
1455+ "description":"The name that needs to be deleted",
1462+ "description":"Invalid username supplied"
1465+ "description":"User not found"
1471+ "securityDefinitions":{
1474+ "authorizationUrl":"http://petstore.swagger.io/api/oauth/dialog",
1477+ "write:pets":"modify pets in your account",
1478+ "read:pets":"read your pets"
1505+ "format":"date-time"
1509+ "description":"Order Status",
1568+ "description":"User Status"
1602+ "$ref":"#/definitions/Category"
1625+ "$ref":"#/definitions/Tag"
1630+ "description":"pet status in the store",
1659+ "description":"Find out more about Swagger",
1660+ "url":"http://swagger.io"