forked from loafle/openapi-generator-original
Fix NPE in Elm path parameter (#4116)
* fix NPE in elm path parameter * replace paramName with baseName * install elm format in circleci * switch to /usr/bin/env
This commit is contained in:
parent
ceb021cc54
commit
3141e483ef
@ -21,6 +21,9 @@ elif [ "$NODE_INDEX" = "2" ]; then
|
|||||||
echo "Running node $NODE_INDEX to test ensure-up-to-date"
|
echo "Running node $NODE_INDEX to test ensure-up-to-date"
|
||||||
java -version
|
java -version
|
||||||
|
|
||||||
|
# install elm-format
|
||||||
|
npm install -g elm-format
|
||||||
|
|
||||||
./bin/utils/ensure-up-to-date
|
./bin/utils/ensure-up-to-date
|
||||||
fi
|
fi
|
||||||
#elif [ "$NODE_INDEX" = "3" ]; then
|
#elif [ "$NODE_INDEX" = "3" ]; then
|
||||||
|
@ -26,7 +26,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# auto format elm code using elm-format
|
# auto format elm code using elm-format
|
||||||
export ELM_POST_PROCESS_FILE="/usr/local/bin/elm-format --elm-version=0.18 --yes"
|
export ELM_POST_PROCESS_FILE="/usr/bin/env elm-format --elm-version=0.18 --yes"
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
@ -26,7 +26,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# auto format elm code using elm-format
|
# auto format elm code using elm-format
|
||||||
export ELM_POST_PROCESS_FILE="/usr/local/bin/elm-format --elm-version=0.19 --yes"
|
export ELM_POST_PROCESS_FILE="/usr/bin/env elm-format --elm-version=0.19 --yes"
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
@ -68,7 +68,7 @@ declare -a scripts=(
|
|||||||
"./bin/dart-petstore.sh"
|
"./bin/dart-petstore.sh"
|
||||||
"./bin/dart2-petstore.sh"
|
"./bin/dart2-petstore.sh"
|
||||||
"./bin/java-play-framework-petstore-server-all.sh"
|
"./bin/java-play-framework-petstore-server-all.sh"
|
||||||
#"./bin/elm-petstore-all.sh"
|
"./bin/elm-petstore-all.sh"
|
||||||
"./bin/meta-codegen.sh"
|
"./bin/meta-codegen.sh"
|
||||||
# OTHERS
|
# OTHERS
|
||||||
"./bin/utils/export_docs_generators.sh"
|
"./bin/utils/export_docs_generators.sh"
|
||||||
|
@ -437,18 +437,18 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
final Set<String> dependencies = new HashSet<>();
|
final Set<String> dependencies = new HashSet<>();
|
||||||
|
|
||||||
for (CodegenOperation op : ops) {
|
for (CodegenOperation op : ops) {
|
||||||
if (ElmVersion.ELM_018.equals(elmVersion)) {
|
if (ElmVersion.ELM_018.equals(elmVersion)) { // elm 0.18
|
||||||
String path = op.path;
|
String path = op.path;
|
||||||
for (CodegenParameter param : op.pathParams) {
|
for (CodegenParameter param : op.pathParams) {
|
||||||
final String var = paramToString("params", param, false, null);
|
final String var = paramToString("params", param, false, null);
|
||||||
path = path.replace("{" + param.paramName + "}", "\" ++ " + var + " ++ \"");
|
path = path.replace("{" + param.baseName + "}", "\" ++ " + var + " ++ \"");
|
||||||
}
|
}
|
||||||
op.path = ("\"" + path + "\"").replaceAll(" \\+\\+ \"\"", "");
|
op.path = ("\"" + path + "\"").replaceAll(" \\+\\+ \"\"", "");
|
||||||
} else {
|
} else { // elm 0.19 or later
|
||||||
final List<Object> pathParams = Arrays.asList(op.path.substring(1).split("/")).stream()
|
final List<Object> pathParams = Arrays.asList(op.path.substring(1).split("/")).stream()
|
||||||
.map(str -> {
|
.map(str -> {
|
||||||
if (str.startsWith("{") && str.endsWith("}")) {
|
if (str.startsWith("{") && str.endsWith("}")) {
|
||||||
return op.pathParams.stream().filter(p -> str.equals("{" + p.paramName + "}")).findFirst().orElse(null);
|
return op.pathParams.stream().filter(p -> str.equals("{" + p.baseName + "}")).findFirst().orElse(null);
|
||||||
} else {
|
} else {
|
||||||
return "\"" + str + "\"";
|
return "\"" + str + "\"";
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
4.1.3-SNAPSHOT
|
4.2.0-SNAPSHOT
|
@ -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,22 +35,15 @@ decoder =
|
|||||||
|> optional "message" (Decode.nullable Decode.string) Nothing
|
|> optional "message" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : ApiResponse -> Encode.Value
|
encode : ApiResponse -> Encode.Value
|
||||||
encode model =
|
encode 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) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : ApiResponse -> String
|
toString : ApiResponse -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,21 +33,14 @@ decoder =
|
|||||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : Category -> Encode.Value
|
encode : Category -> Encode.Value
|
||||||
encode model =
|
encode 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) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : Category -> String
|
toString : Category -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,7 +37,6 @@ type Status
|
|||||||
| Delivered
|
| Delivered
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
decoder : Decoder Order_
|
decoder : Decoder Order_
|
||||||
decoder =
|
decoder =
|
||||||
decode Order_
|
decode Order_
|
||||||
@ -49,7 +48,6 @@ decoder =
|
|||||||
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : Order_ -> Encode.Value
|
encode : Order_ -> Encode.Value
|
||||||
encode model =
|
encode model =
|
||||||
Encode.object
|
Encode.object
|
||||||
@ -59,18 +57,14 @@ encode model =
|
|||||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : Order_ -> String
|
toString : Order_ -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
statusDecoder : Decoder Status
|
statusDecoder : Decoder Status
|
||||||
statusDecoder =
|
statusDecoder =
|
||||||
Decode.string
|
Decode.string
|
||||||
@ -91,7 +85,6 @@ statusDecoder =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encodeStatus : Status -> Encode.Value
|
encodeStatus : Status -> Encode.Value
|
||||||
encodeStatus model =
|
encodeStatus model =
|
||||||
case model of
|
case model of
|
||||||
@ -103,7 +96,3 @@ encodeStatus model =
|
|||||||
|
|
||||||
Delivered ->
|
Delivered ->
|
||||||
Encode.string "delivered"
|
Encode.string "delivered"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,7 +38,6 @@ type Status
|
|||||||
| Sold
|
| Sold
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
decoder : Decoder Pet
|
decoder : Decoder Pet
|
||||||
decoder =
|
decoder =
|
||||||
decode Pet
|
decode Pet
|
||||||
@ -50,7 +49,6 @@ decoder =
|
|||||||
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : Pet -> Encode.Value
|
encode : Pet -> Encode.Value
|
||||||
encode model =
|
encode model =
|
||||||
Encode.object
|
Encode.object
|
||||||
@ -60,18 +58,14 @@ encode 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.encode) model.tags) )
|
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list << List.map Tag.encode) model.tags) )
|
||||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : Pet -> String
|
toString : Pet -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
statusDecoder : Decoder Status
|
statusDecoder : Decoder Status
|
||||||
statusDecoder =
|
statusDecoder =
|
||||||
Decode.string
|
Decode.string
|
||||||
@ -92,7 +86,6 @@ statusDecoder =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encodeStatus : Status -> Encode.Value
|
encodeStatus : Status -> Encode.Value
|
||||||
encodeStatus model =
|
encodeStatus model =
|
||||||
case model of
|
case model of
|
||||||
@ -104,7 +97,3 @@ encodeStatus model =
|
|||||||
|
|
||||||
Sold ->
|
Sold ->
|
||||||
Encode.string "sold"
|
Encode.string "sold"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,21 +33,14 @@ decoder =
|
|||||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : Tag -> Encode.Value
|
encode : Tag -> Encode.Value
|
||||||
encode model =
|
encode 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) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : Tag -> String
|
toString : Tag -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,7 +45,6 @@ decoder =
|
|||||||
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : User -> Encode.Value
|
encode : User -> Encode.Value
|
||||||
encode model =
|
encode model =
|
||||||
Encode.object
|
Encode.object
|
||||||
@ -57,15 +56,9 @@ encode 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) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : User -> String
|
toString : User -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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.Pet as Pet exposing (Pet)
|
|
||||||
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||||
|
import Data.Pet as Pet exposing (Pet)
|
||||||
import Dict
|
import Dict
|
||||||
import Http
|
import Http
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
|
@ -1 +1 @@
|
|||||||
4.1.3-SNAPSHOT
|
4.2.0-SNAPSHOT
|
@ -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,22 +35,15 @@ decoder =
|
|||||||
|> optional "message" (Decode.nullable Decode.string) Nothing
|
|> optional "message" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : ApiResponse -> Encode.Value
|
encode : ApiResponse -> Encode.Value
|
||||||
encode model =
|
encode 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) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : ApiResponse -> String
|
toString : ApiResponse -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,21 +33,14 @@ decoder =
|
|||||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : Category -> Encode.Value
|
encode : Category -> Encode.Value
|
||||||
encode model =
|
encode 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) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : Category -> String
|
toString : Category -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,7 +37,6 @@ type Status
|
|||||||
| Delivered
|
| Delivered
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
decoder : Decoder Order_
|
decoder : Decoder Order_
|
||||||
decoder =
|
decoder =
|
||||||
Decode.succeed Order_
|
Decode.succeed Order_
|
||||||
@ -49,7 +48,6 @@ decoder =
|
|||||||
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : Order_ -> Encode.Value
|
encode : Order_ -> Encode.Value
|
||||||
encode model =
|
encode model =
|
||||||
Encode.object
|
Encode.object
|
||||||
@ -59,18 +57,14 @@ encode model =
|
|||||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : Order_ -> String
|
toString : Order_ -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
statusDecoder : Decoder Status
|
statusDecoder : Decoder Status
|
||||||
statusDecoder =
|
statusDecoder =
|
||||||
Decode.string
|
Decode.string
|
||||||
@ -91,7 +85,6 @@ statusDecoder =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encodeStatus : Status -> Encode.Value
|
encodeStatus : Status -> Encode.Value
|
||||||
encodeStatus model =
|
encodeStatus model =
|
||||||
case model of
|
case model of
|
||||||
@ -103,7 +96,3 @@ encodeStatus model =
|
|||||||
|
|
||||||
Delivered ->
|
Delivered ->
|
||||||
Encode.string "delivered"
|
Encode.string "delivered"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,7 +38,6 @@ type Status
|
|||||||
| Sold
|
| Sold
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
decoder : Decoder Pet
|
decoder : Decoder Pet
|
||||||
decoder =
|
decoder =
|
||||||
Decode.succeed Pet
|
Decode.succeed Pet
|
||||||
@ -50,28 +49,23 @@ decoder =
|
|||||||
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : Pet -> Encode.Value
|
encode : Pet -> Encode.Value
|
||||||
encode model =
|
encode 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.encode model.category) )
|
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encode 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.encode) model.tags) )
|
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list Tag.encode) model.tags) )
|
||||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : Pet -> String
|
toString : Pet -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
statusDecoder : Decoder Status
|
statusDecoder : Decoder Status
|
||||||
statusDecoder =
|
statusDecoder =
|
||||||
Decode.string
|
Decode.string
|
||||||
@ -92,7 +86,6 @@ statusDecoder =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encodeStatus : Status -> Encode.Value
|
encodeStatus : Status -> Encode.Value
|
||||||
encodeStatus model =
|
encodeStatus model =
|
||||||
case model of
|
case model of
|
||||||
@ -104,7 +97,3 @@ encodeStatus model =
|
|||||||
|
|
||||||
Sold ->
|
Sold ->
|
||||||
Encode.string "sold"
|
Encode.string "sold"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,21 +33,14 @@ decoder =
|
|||||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : Tag -> Encode.Value
|
encode : Tag -> Encode.Value
|
||||||
encode model =
|
encode 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) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : Tag -> String
|
toString : Tag -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,7 +45,6 @@ decoder =
|
|||||||
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
encode : User -> Encode.Value
|
encode : User -> Encode.Value
|
||||||
encode model =
|
encode model =
|
||||||
Encode.object
|
Encode.object
|
||||||
@ -57,15 +56,9 @@ encode 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) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toString : User -> String
|
toString : User -> String
|
||||||
toString =
|
toString =
|
||||||
Encode.encode 0 << encode
|
Encode.encode 0 << encode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Request.Pet exposing (addPet, deletePet, findPetsByStatus, Status(..), findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
module Request.Pet exposing (Status(..), addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
||||||
|
|
||||||
import Data.Pet as Pet exposing (Pet)
|
|
||||||
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||||
|
import Data.Pet as Pet exposing (Pet)
|
||||||
import Dict
|
import Dict
|
||||||
import Http
|
import Http
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
@ -25,6 +25,7 @@ type Status
|
|||||||
| Pending
|
| Pending
|
||||||
| Sold
|
| Sold
|
||||||
|
|
||||||
|
|
||||||
stringifyStatus : Status -> String
|
stringifyStatus : Status -> String
|
||||||
stringifyStatus value =
|
stringifyStatus value =
|
||||||
case value of
|
case value of
|
||||||
@ -38,9 +39,6 @@ stringifyStatus value =
|
|||||||
"sold"
|
"sold"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
basePath : String
|
basePath : String
|
||||||
basePath =
|
basePath =
|
||||||
"http://petstore.swagger.io/v2"
|
"http://petstore.swagger.io/v2"
|
||||||
@ -48,19 +46,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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet"]
|
Url.crossOrigin basePath
|
||||||
|
[ "pet" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| Pet.encode params.body
|
, body = Http.jsonBody <| Pet.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -70,22 +65,20 @@ addPet params =
|
|||||||
|
|
||||||
|
|
||||||
deletePet :
|
deletePet :
|
||||||
{ apiKey : Maybe (String)
|
{ apiKey : Maybe String
|
||||||
} ->
|
}
|
||||||
|
->
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
, petId : Int
|
, petId : Int
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
deletePet headers params =
|
deletePet headers params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "DELETE"
|
{ method = "DELETE"
|
||||||
, headers = List.filterMap identity [Maybe.map (Http.header "api_key" << identity) headers.apiKey]
|
, headers = List.filterMap identity [ Maybe.map (Http.header "api_key" << identity) headers.apiKey ]
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", String.fromInt params.petId]
|
Url.crossOrigin basePath
|
||||||
|
[ "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
|
||||||
@ -98,10 +91,6 @@ deletePet headers params =
|
|||||||
-}
|
-}
|
||||||
findPetsByStatus :
|
findPetsByStatus :
|
||||||
{ onSend : Result Http.Error (List Pet) -> msg
|
{ onSend : Result Http.Error (List Pet) -> msg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
, status : List Status
|
, status : List Status
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
@ -109,9 +98,10 @@ findPetsByStatus params =
|
|||||||
Http.request
|
Http.request
|
||||||
{ method = "GET"
|
{ method = "GET"
|
||||||
, headers = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", "findByStatus"]
|
Url.crossOrigin basePath
|
||||||
(List.filterMap identity [(Just << Url.string "status" << String.join "," << List.map stringifyStatus) params.status])
|
[ "pet", "findByStatus" ]
|
||||||
|
(List.filterMap identity [ (Just << Url.string "status" << String.join "," << List.map stringifyStatus) 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
|
||||||
@ -123,10 +113,6 @@ 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
|
||||||
@ -134,9 +120,10 @@ findPetsByTags params =
|
|||||||
Http.request
|
Http.request
|
||||||
{ method = "GET"
|
{ method = "GET"
|
||||||
, headers = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", "findByTags"]
|
Url.crossOrigin basePath
|
||||||
(List.filterMap identity [(Just << Url.string "tags" << String.join "," << List.map identity) params.tags])
|
[ "pet", "findByTags" ]
|
||||||
|
(List.filterMap identity [ (Just << Url.string "tags" << String.join "," << List.map identity) 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
|
||||||
@ -148,19 +135,16 @@ 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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", String.fromInt params.petId]
|
Url.crossOrigin basePath
|
||||||
|
[ "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
|
||||||
@ -171,19 +155,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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet"]
|
Url.crossOrigin basePath
|
||||||
|
[ "pet" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| Pet.encode params.body
|
, body = Http.jsonBody <| Pet.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -194,19 +175,16 @@ 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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", String.fromInt params.petId]
|
Url.crossOrigin basePath
|
||||||
|
[ "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
|
||||||
@ -217,19 +195,16 @@ 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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", String.fromInt params.petId, "uploadImage"]
|
Url.crossOrigin basePath
|
||||||
|
[ "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
|
||||||
|
@ -19,8 +19,6 @@ import Json.Decode as Decode
|
|||||||
import Url.Builder as Url
|
import Url.Builder as Url
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
basePath : String
|
basePath : String
|
||||||
basePath =
|
basePath =
|
||||||
"http://petstore.swagger.io/v2"
|
"http://petstore.swagger.io/v2"
|
||||||
@ -30,19 +28,16 @@ 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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["store", "order", identity params.orderId]
|
Url.crossOrigin basePath
|
||||||
|
[ "store", "order", identity params.orderId ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -55,19 +50,15 @@ 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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["store", "inventory"]
|
Url.crossOrigin basePath
|
||||||
|
[ "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)
|
||||||
@ -80,19 +71,16 @@ 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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["store", "order", String.fromInt params.orderId]
|
Url.crossOrigin basePath
|
||||||
|
[ "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
|
||||||
@ -103,19 +91,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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["store", "order"]
|
Url.crossOrigin basePath
|
||||||
|
[ "store", "order" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| Order_.encode params.body
|
, body = Http.jsonBody <| Order_.encode params.body
|
||||||
, expect = Http.expectJson params.onSend Order_.decoder
|
, expect = Http.expectJson params.onSend Order_.decoder
|
||||||
|
@ -19,8 +19,6 @@ import Json.Decode as Decode
|
|||||||
import Url.Builder as Url
|
import Url.Builder as Url
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
basePath : String
|
basePath : String
|
||||||
basePath =
|
basePath =
|
||||||
"http://petstore.swagger.io/v2"
|
"http://petstore.swagger.io/v2"
|
||||||
@ -30,19 +28,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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user"]
|
Url.crossOrigin basePath
|
||||||
|
[ "user" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| User.encode params.body
|
, body = Http.jsonBody <| User.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -53,19 +48,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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", "createWithArray"]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", "createWithArray" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| User.encode params.body
|
, body = Http.jsonBody <| User.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -76,19 +68,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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", "createWithList"]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", "createWithList" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| User.encode params.body
|
, body = Http.jsonBody <| User.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -101,19 +90,16 @@ 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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", identity params.username]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", identity params.username ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -124,19 +110,16 @@ 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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", identity params.username]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", identity 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
|
||||||
@ -147,20 +130,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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", "login"]
|
Url.crossOrigin basePath
|
||||||
(List.filterMap identity [(Just << Url.string "username" << identity) params.username, (Just << Url.string "password" << identity) params.password])
|
[ "user", "login" ]
|
||||||
|
(List.filterMap identity [ (Just << Url.string "username" << identity) params.username, (Just << Url.string "password" << identity) 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
|
||||||
@ -170,19 +151,15 @@ 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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", "logout"]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", "logout" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -195,19 +172,17 @@ logoutUser params =
|
|||||||
-}
|
-}
|
||||||
updateUser :
|
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 = List.filterMap identity []
|
, headers = List.filterMap identity []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", identity params.username]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", identity params.username ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| User.encode params.body
|
, body = Http.jsonBody <| User.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
|
Loading…
x
Reference in New Issue
Block a user