update elm petstore samples

This commit is contained in:
William Cheng 2018-11-24 19:12:22 +08:00
parent 7db12aa4af
commit 2146081ffb
22 changed files with 234 additions and 158 deletions

View File

@ -1,5 +1 @@
<<<<<<< HEAD
4.0.0-SNAPSHOT 4.0.0-SNAPSHOT
=======
3.3.4-SNAPSHOT
>>>>>>> origin

View File

@ -21,9 +21,9 @@ import Json.Encode as Encode
{-| Describes the result of uploading an image resource {-| Describes the result of uploading an image resource
-} -}
type alias ApiResponse = type alias ApiResponse =
{ code : Maybe Int { code : Maybe (Int)
, type_ : Maybe String , type_ : Maybe (String)
, message : Maybe String , message : Maybe (String)
} }
@ -35,10 +35,14 @@ decoder =
|> optional "message" (Decode.nullable Decode.string) Nothing |> optional "message" (Decode.nullable Decode.string) Nothing
encoder : ApiResponse -> Encode.Value encoder : ApiResponse -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) ) [ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) ) , ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) ) , ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
] ]

View File

@ -21,8 +21,8 @@ import Json.Encode as Encode
{-| A category for a pet {-| A category for a pet
-} -}
type alias Category = type alias Category =
{ id : Maybe Int { id : Maybe (Int)
, name : Maybe String , name : Maybe (String)
} }
@ -33,9 +33,13 @@ decoder =
|> optional "name" (Decode.nullable Decode.string) Nothing |> optional "name" (Decode.nullable Decode.string) Nothing
encoder : Category -> Encode.Value encoder : Category -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) ) [ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) ) , ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
] ]

View File

@ -22,12 +22,12 @@ import Json.Encode as Encode
{-| An order for a pets from the pet store {-| An order for a pets from the pet store
-} -}
type alias Order_ = type alias Order_ =
{ id : Maybe Int { id : Maybe (Int)
, petId : Maybe Int , petId : Maybe (Int)
, quantity : Maybe Int , quantity : Maybe (Int)
, shipDate : Maybe DateTime , shipDate : Maybe (DateTime)
, status : Maybe Status , status : Maybe (Status)
, complete : Maybe Bool , complete : Maybe (Bool)
} }
@ -37,6 +37,7 @@ type Status
| Delivered | Delivered
decoder : Decoder Order_ decoder : Decoder Order_
decoder = decoder =
decode Order_ decode Order_
@ -48,6 +49,7 @@ decoder =
|> optional "complete" (Decode.nullable Decode.bool) (Just False) |> optional "complete" (Decode.nullable Decode.bool) (Just False)
encoder : Order_ -> Encode.Value encoder : Order_ -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
@ -57,9 +59,11 @@ encoder model =
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encoder model.shipDate) ) , ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encoder model.shipDate) )
, ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) ) , ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) )
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) ) , ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
] ]
statusDecoder : Decoder Status statusDecoder : Decoder Status
statusDecoder = statusDecoder =
Decode.string Decode.string
@ -80,6 +84,7 @@ statusDecoder =
) )
statusEncoder : Status -> Encode.Value statusEncoder : Status -> Encode.Value
statusEncoder model = statusEncoder model =
case model of case model of
@ -91,3 +96,6 @@ statusEncoder model =
Delivered -> Delivered ->
Encode.string "delivered" Encode.string "delivered"

View File

@ -23,12 +23,12 @@ import Json.Encode as Encode
{-| A pet for sale in the pet store {-| A pet for sale in the pet store
-} -}
type alias Pet = type alias Pet =
{ id : Maybe Int { id : Maybe (Int)
, category : Maybe Category , category : Maybe (Category)
, name : String , name : String
, photoUrls : List String , photoUrls : (List String)
, tags : Maybe (List Tag) , tags : Maybe ((List Tag))
, status : Maybe Status , status : Maybe (Status)
} }
@ -38,6 +38,7 @@ type Status
| Sold | Sold
decoder : Decoder Pet decoder : Decoder Pet
decoder = decoder =
decode Pet decode Pet
@ -49,6 +50,7 @@ decoder =
|> optional "status" (Decode.nullable statusDecoder) Nothing |> optional "status" (Decode.nullable statusDecoder) Nothing
encoder : Pet -> Encode.Value encoder : Pet -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
@ -58,9 +60,11 @@ encoder model =
, ( "photoUrls", (Encode.list << List.map Encode.string) model.photoUrls ) , ( "photoUrls", (Encode.list << List.map Encode.string) model.photoUrls )
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list << List.map Tag.encoder) model.tags) ) , ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list << List.map Tag.encoder) model.tags) )
, ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) ) , ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) )
] ]
statusDecoder : Decoder Status statusDecoder : Decoder Status
statusDecoder = statusDecoder =
Decode.string Decode.string
@ -81,6 +85,7 @@ statusDecoder =
) )
statusEncoder : Status -> Encode.Value statusEncoder : Status -> Encode.Value
statusEncoder model = statusEncoder model =
case model of case model of
@ -92,3 +97,6 @@ statusEncoder model =
Sold -> Sold ->
Encode.string "sold" Encode.string "sold"

View File

@ -21,8 +21,8 @@ import Json.Encode as Encode
{-| A tag for a pet {-| A tag for a pet
-} -}
type alias Tag = type alias Tag =
{ id : Maybe Int { id : Maybe (Int)
, name : Maybe String , name : Maybe (String)
} }
@ -33,9 +33,13 @@ decoder =
|> optional "name" (Decode.nullable Decode.string) Nothing |> optional "name" (Decode.nullable Decode.string) Nothing
encoder : Tag -> Encode.Value encoder : Tag -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) ) [ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) ) , ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
] ]

View File

@ -21,14 +21,14 @@ import Json.Encode as Encode
{-| A User who is purchasing from the pet store {-| A User who is purchasing from the pet store
-} -}
type alias User = type alias User =
{ id : Maybe Int { id : Maybe (Int)
, username : Maybe String , username : Maybe (String)
, firstName : Maybe String , firstName : Maybe (String)
, lastName : Maybe String , lastName : Maybe (String)
, email : Maybe String , email : Maybe (String)
, password : Maybe String , password : Maybe (String)
, phone : Maybe String , phone : Maybe (String)
, userStatus : Maybe Int , userStatus : Maybe (Int)
} }
@ -45,6 +45,7 @@ decoder =
|> optional "userStatus" (Decode.nullable Decode.int) Nothing |> optional "userStatus" (Decode.nullable Decode.int) Nothing
encoder : User -> Encode.Value encoder : User -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
@ -56,4 +57,7 @@ encoder model =
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) ) , ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) ) , ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) ) , ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
] ]

View File

@ -12,8 +12,8 @@
module Request.Pet exposing (addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile) module Request.Pet exposing (addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
import Data.Pet as Pet exposing (Pet) import Data.Pet as Pet exposing (Pet)
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
import Dict import Dict
import Http import Http
import Json.Decode as Decode import Json.Decode as Decode

View File

@ -1,5 +1 @@
<<<<<<< HEAD
4.0.0-SNAPSHOT 4.0.0-SNAPSHOT
=======
3.3.4-SNAPSHOT
>>>>>>> origin

View File

@ -21,9 +21,9 @@ import Json.Encode as Encode
{-| Describes the result of uploading an image resource {-| Describes the result of uploading an image resource
-} -}
type alias ApiResponse = type alias ApiResponse =
{ code : Maybe Int { code : Maybe (Int)
, type_ : Maybe String , type_ : Maybe (String)
, message : Maybe String , message : Maybe (String)
} }
@ -35,10 +35,14 @@ decoder =
|> optional "message" (Decode.nullable Decode.string) Nothing |> optional "message" (Decode.nullable Decode.string) Nothing
encoder : ApiResponse -> Encode.Value encoder : ApiResponse -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) ) [ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) ) , ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) ) , ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
] ]

View File

@ -21,8 +21,8 @@ import Json.Encode as Encode
{-| A category for a pet {-| A category for a pet
-} -}
type alias Category = type alias Category =
{ id : Maybe Int { id : Maybe (Int)
, name : Maybe String , name : Maybe (String)
} }
@ -33,9 +33,13 @@ decoder =
|> optional "name" (Decode.nullable Decode.string) Nothing |> optional "name" (Decode.nullable Decode.string) Nothing
encoder : Category -> Encode.Value encoder : Category -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) ) [ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) ) , ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
] ]

View File

@ -22,12 +22,12 @@ import Json.Encode as Encode
{-| An order for a pets from the pet store {-| An order for a pets from the pet store
-} -}
type alias Order_ = type alias Order_ =
{ id : Maybe Int { id : Maybe (Int)
, petId : Maybe Int , petId : Maybe (Int)
, quantity : Maybe Int , quantity : Maybe (Int)
, shipDate : Maybe DateTime , shipDate : Maybe (DateTime)
, status : Maybe Status , status : Maybe (Status)
, complete : Maybe Bool , complete : Maybe (Bool)
} }
@ -37,6 +37,7 @@ type Status
| Delivered | Delivered
decoder : Decoder Order_ decoder : Decoder Order_
decoder = decoder =
Decode.succeed Order_ Decode.succeed Order_
@ -48,6 +49,7 @@ decoder =
|> optional "complete" (Decode.nullable Decode.bool) (Just False) |> optional "complete" (Decode.nullable Decode.bool) (Just False)
encoder : Order_ -> Encode.Value encoder : Order_ -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
@ -57,9 +59,11 @@ encoder model =
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encoder model.shipDate) ) , ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encoder model.shipDate) )
, ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) ) , ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) )
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) ) , ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
] ]
statusDecoder : Decoder Status statusDecoder : Decoder Status
statusDecoder = statusDecoder =
Decode.string Decode.string
@ -80,6 +84,7 @@ statusDecoder =
) )
statusEncoder : Status -> Encode.Value statusEncoder : Status -> Encode.Value
statusEncoder model = statusEncoder model =
case model of case model of
@ -91,3 +96,6 @@ statusEncoder model =
Delivered -> Delivered ->
Encode.string "delivered" Encode.string "delivered"

View File

@ -23,12 +23,12 @@ import Json.Encode as Encode
{-| A pet for sale in the pet store {-| A pet for sale in the pet store
-} -}
type alias Pet = type alias Pet =
{ id : Maybe Int { id : Maybe (Int)
, category : Maybe Category , category : Maybe (Category)
, name : String , name : String
, photoUrls : List String , photoUrls : (List String)
, tags : Maybe (List Tag) , tags : Maybe ((List Tag))
, status : Maybe Status , status : Maybe (Status)
} }
@ -38,6 +38,7 @@ type Status
| Sold | Sold
decoder : Decoder Pet decoder : Decoder Pet
decoder = decoder =
Decode.succeed Pet Decode.succeed Pet
@ -49,18 +50,21 @@ decoder =
|> optional "status" (Decode.nullable statusDecoder) Nothing |> optional "status" (Decode.nullable statusDecoder) Nothing
encoder : Pet -> Encode.Value encoder : Pet -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) ) [ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encoder model.category) ) , ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encoder model.category) )
, ( "name", Encode.string model.name ) , ( "name", Encode.string model.name )
, ( "photoUrls", Encode.list Encode.string model.photoUrls ) , ( "photoUrls", (Encode.list Encode.string) model.photoUrls )
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list Tag.encoder) model.tags) ) , ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list Tag.encoder) model.tags) )
, ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) ) , ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) )
] ]
statusDecoder : Decoder Status statusDecoder : Decoder Status
statusDecoder = statusDecoder =
Decode.string Decode.string
@ -81,6 +85,7 @@ statusDecoder =
) )
statusEncoder : Status -> Encode.Value statusEncoder : Status -> Encode.Value
statusEncoder model = statusEncoder model =
case model of case model of
@ -92,3 +97,6 @@ statusEncoder model =
Sold -> Sold ->
Encode.string "sold" Encode.string "sold"

View File

@ -21,8 +21,8 @@ import Json.Encode as Encode
{-| A tag for a pet {-| A tag for a pet
-} -}
type alias Tag = type alias Tag =
{ id : Maybe Int { id : Maybe (Int)
, name : Maybe String , name : Maybe (String)
} }
@ -33,9 +33,13 @@ decoder =
|> optional "name" (Decode.nullable Decode.string) Nothing |> optional "name" (Decode.nullable Decode.string) Nothing
encoder : Tag -> Encode.Value encoder : Tag -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) ) [ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) ) , ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
] ]

View File

@ -21,14 +21,14 @@ import Json.Encode as Encode
{-| A User who is purchasing from the pet store {-| A User who is purchasing from the pet store
-} -}
type alias User = type alias User =
{ id : Maybe Int { id : Maybe (Int)
, username : Maybe String , username : Maybe (String)
, firstName : Maybe String , firstName : Maybe (String)
, lastName : Maybe String , lastName : Maybe (String)
, email : Maybe String , email : Maybe (String)
, password : Maybe String , password : Maybe (String)
, phone : Maybe String , phone : Maybe (String)
, userStatus : Maybe Int , userStatus : Maybe (Int)
} }
@ -45,6 +45,7 @@ decoder =
|> optional "userStatus" (Decode.nullable Decode.int) Nothing |> optional "userStatus" (Decode.nullable Decode.int) Nothing
encoder : User -> Encode.Value encoder : User -> Encode.Value
encoder model = encoder model =
Encode.object Encode.object
@ -56,4 +57,7 @@ encoder model =
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) ) , ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) ) , ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) ) , ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
] ]

View File

@ -12,8 +12,8 @@
module Request.Pet exposing (addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile) module Request.Pet exposing (addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
import Data.Pet as Pet exposing (Pet) import Data.Pet as Pet exposing (Pet)
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
import Dict import Dict
import Http import Http
import Json.Decode as Decode import Json.Decode as Decode
@ -28,15 +28,16 @@ basePath =
addPet : addPet :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
, body : Pet , body : Pet
} }
-> Cmd msg -> Cmd msg
addPet params = addPet params =
Http.request Http.request
{ method = "POST" { method = "POST"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["pet"]
[ "pet" ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.jsonBody <| Pet.encoder params.body , body = Http.jsonBody <| Pet.encoder params.body
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend
@ -47,16 +48,17 @@ addPet params =
deletePet : deletePet :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
, petId : Int , petId : Int
} }
-> Cmd msg -> Cmd msg
deletePet params = deletePet params =
Http.request Http.request
{ method = "DELETE" { method = "DELETE"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["pet", String.fromInt params.petId]
[ "pet", String.fromInt params.petId ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend
@ -69,6 +71,8 @@ deletePet params =
-} -}
findPetsByStatus : findPetsByStatus :
{ onSend : Result Http.Error (List Pet) -> msg { onSend : Result Http.Error (List Pet) -> msg
, status : List String , status : List String
} }
-> Cmd msg -> Cmd msg
@ -76,10 +80,9 @@ findPetsByStatus params =
Http.request Http.request
{ method = "GET" { method = "GET"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["pet", "findByStatus"]
[ "pet", "findByStatus" ] (List.filterMap identity [Just (Url.string "status" <| String.join "," params.status)])
(List.filterMap identity [ Just (Url.string "status" <| String.join "," params.status) ])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder) , expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
, timeout = Just 30000 , timeout = Just 30000
@ -91,6 +94,8 @@ findPetsByStatus params =
-} -}
findPetsByTags : findPetsByTags :
{ onSend : Result Http.Error (List Pet) -> msg { onSend : Result Http.Error (List Pet) -> msg
, tags : List String , tags : List String
} }
-> Cmd msg -> Cmd msg
@ -98,10 +103,9 @@ findPetsByTags params =
Http.request Http.request
{ method = "GET" { method = "GET"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["pet", "findByTags"]
[ "pet", "findByTags" ] (List.filterMap identity [Just (Url.string "tags" <| String.join "," params.tags)])
(List.filterMap identity [ Just (Url.string "tags" <| String.join "," params.tags) ])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder) , expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
, timeout = Just 30000 , timeout = Just 30000
@ -113,16 +117,17 @@ findPetsByTags params =
-} -}
getPetById : getPetById :
{ onSend : Result Http.Error Pet -> msg { onSend : Result Http.Error Pet -> msg
, petId : Int , petId : Int
} }
-> Cmd msg -> Cmd msg
getPetById params = getPetById params =
Http.request Http.request
{ method = "GET" { method = "GET"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["pet", String.fromInt params.petId]
[ "pet", String.fromInt params.petId ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectJson params.onSend Pet.decoder , expect = Http.expectJson params.onSend Pet.decoder
@ -134,15 +139,16 @@ getPetById params =
updatePet : updatePet :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
, body : Pet , body : Pet
} }
-> Cmd msg -> Cmd msg
updatePet params = updatePet params =
Http.request Http.request
{ method = "PUT" { method = "PUT"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["pet"]
[ "pet" ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.jsonBody <| Pet.encoder params.body , body = Http.jsonBody <| Pet.encoder params.body
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend
@ -153,16 +159,17 @@ updatePet params =
updatePetWithForm : updatePetWithForm :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
, petId : Int , petId : Int
} }
-> Cmd msg -> Cmd msg
updatePetWithForm params = updatePetWithForm params =
Http.request Http.request
{ method = "POST" { method = "POST"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["pet", String.fromInt params.petId]
[ "pet", String.fromInt params.petId ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend
@ -173,16 +180,17 @@ updatePetWithForm params =
uploadFile : uploadFile :
{ onSend : Result Http.Error ApiResponse -> msg { onSend : Result Http.Error ApiResponse -> msg
, petId : Int , petId : Int
} }
-> Cmd msg -> Cmd msg
uploadFile params = uploadFile params =
Http.request Http.request
{ method = "POST" { method = "POST"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["pet", String.fromInt params.petId, "uploadImage"]
[ "pet", String.fromInt params.petId, "uploadImage" ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectJson params.onSend ApiResponse.decoder , expect = Http.expectJson params.onSend ApiResponse.decoder

View File

@ -28,16 +28,17 @@ basePath =
-} -}
deleteOrder : deleteOrder :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
, orderId : String , orderId : String
} }
-> Cmd msg -> Cmd msg
deleteOrder params = deleteOrder params =
Http.request Http.request
{ method = "DELETE" { method = "DELETE"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["store", "order", params.orderId]
[ "store", "order", params.orderId ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend
@ -50,15 +51,17 @@ deleteOrder params =
-} -}
getInventory : getInventory :
{ onSend : Result Http.Error (Dict.Dict String Int) -> msg { onSend : Result Http.Error (Dict.Dict String Int) -> msg
} }
-> Cmd msg -> Cmd msg
getInventory params = getInventory params =
Http.request Http.request
{ method = "GET" { method = "GET"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["store", "inventory"]
[ "store", "inventory" ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectJson params.onSend (Decode.dict Decode.int) , expect = Http.expectJson params.onSend (Decode.dict Decode.int)
@ -71,16 +74,17 @@ getInventory params =
-} -}
getOrderById : getOrderById :
{ onSend : Result Http.Error Order_ -> msg { onSend : Result Http.Error Order_ -> msg
, orderId : Int , orderId : Int
} }
-> Cmd msg -> Cmd msg
getOrderById params = getOrderById params =
Http.request Http.request
{ method = "GET" { method = "GET"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["store", "order", String.fromInt params.orderId]
[ "store", "order", String.fromInt params.orderId ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectJson params.onSend Order_.decoder , expect = Http.expectJson params.onSend Order_.decoder
@ -92,15 +96,16 @@ getOrderById params =
placeOrder : placeOrder :
{ onSend : Result Http.Error Order_ -> msg { onSend : Result Http.Error Order_ -> msg
, body : Order_ , body : Order_
} }
-> Cmd msg -> Cmd msg
placeOrder params = placeOrder params =
Http.request Http.request
{ method = "POST" { method = "POST"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["store", "order"]
[ "store", "order" ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.jsonBody <| Order_.encoder params.body , body = Http.jsonBody <| Order_.encoder params.body
, expect = Http.expectJson params.onSend Order_.decoder , expect = Http.expectJson params.onSend Order_.decoder

View File

@ -29,15 +29,16 @@ basePath =
createUser : createUser :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
, body : User , body : User
} }
-> Cmd msg -> Cmd msg
createUser params = createUser params =
Http.request Http.request
{ method = "POST" { method = "POST"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["user"]
[ "user" ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.jsonBody <| User.encoder params.body , body = Http.jsonBody <| User.encoder params.body
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend
@ -49,15 +50,16 @@ createUser params =
createUsersWithArrayInput : createUsersWithArrayInput :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
, body : User , body : User
} }
-> Cmd msg -> Cmd msg
createUsersWithArrayInput params = createUsersWithArrayInput params =
Http.request Http.request
{ method = "POST" { method = "POST"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["user", "createWithArray"]
[ "user", "createWithArray" ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.jsonBody <| User.encoder params.body , body = Http.jsonBody <| User.encoder params.body
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend
@ -69,15 +71,16 @@ createUsersWithArrayInput params =
createUsersWithListInput : createUsersWithListInput :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
, body : User , body : User
} }
-> Cmd msg -> Cmd msg
createUsersWithListInput params = createUsersWithListInput params =
Http.request Http.request
{ method = "POST" { method = "POST"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["user", "createWithList"]
[ "user", "createWithList" ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.jsonBody <| User.encoder params.body , body = Http.jsonBody <| User.encoder params.body
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend
@ -90,16 +93,17 @@ createUsersWithListInput params =
-} -}
deleteUser : deleteUser :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
, username : String , username : String
} }
-> Cmd msg -> Cmd msg
deleteUser params = deleteUser params =
Http.request Http.request
{ method = "DELETE" { method = "DELETE"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["user", params.username]
[ "user", params.username ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend
@ -110,16 +114,17 @@ deleteUser params =
getUserByName : getUserByName :
{ onSend : Result Http.Error User -> msg { onSend : Result Http.Error User -> msg
, username : String , username : String
} }
-> Cmd msg -> Cmd msg
getUserByName params = getUserByName params =
Http.request Http.request
{ method = "GET" { method = "GET"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["user", params.username]
[ "user", params.username ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectJson params.onSend User.decoder , expect = Http.expectJson params.onSend User.decoder
@ -130,18 +135,18 @@ getUserByName params =
loginUser : loginUser :
{ onSend : Result Http.Error String -> msg { onSend : Result Http.Error String -> msg
, username : String
, password : String
, username : String , password : String
} }
-> Cmd msg -> Cmd msg
loginUser params = loginUser params =
Http.request Http.request
{ method = "GET" { method = "GET"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["user", "login"]
[ "user", "login" ] (List.filterMap identity [Just (Url.string "username" <| params.username), Just (Url.string "password" <| params.password)])
(List.filterMap identity [ Just (Url.string "username" <| params.username), Just (Url.string "password" <| params.password) ])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectJson params.onSend Decode.string , expect = Http.expectJson params.onSend Decode.string
, timeout = Just 30000 , timeout = Just 30000
@ -151,15 +156,17 @@ loginUser params =
logoutUser : logoutUser :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
} }
-> Cmd msg -> Cmd msg
logoutUser params = logoutUser params =
Http.request Http.request
{ method = "GET" { method = "GET"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["user", "logout"]
[ "user", "logout" ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.emptyBody , body = Http.emptyBody
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend
@ -174,15 +181,15 @@ updateUser :
{ onSend : Result Http.Error () -> msg { onSend : Result Http.Error () -> msg
, body : User , body : User
, username : String , username : String
} }
-> Cmd msg -> Cmd msg
updateUser params = updateUser params =
Http.request Http.request
{ method = "PUT" { method = "PUT"
, headers = [] , headers = []
, url = , url = Url.crossOrigin basePath
Url.crossOrigin basePath ["user", params.username]
[ "user", params.username ]
(List.filterMap identity []) (List.filterMap identity [])
, body = Http.jsonBody <| User.encoder params.body , body = Http.jsonBody <| User.encoder params.body
, expect = Http.expectWhatever params.onSend , expect = Http.expectWhatever params.onSend