forked from loafle/openapi-generator-original
[elm] Add support for oneOf (#4434)
And add additional test for composable types.
This commit is contained in:
parent
60958b78d9
commit
3cd0e13a46
5
bin/openapi3/elm-all.sh
Executable file
5
bin/openapi3/elm-all.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
./bin/openapi3/elm-petstore.sh
|
||||
./bin/openapi3/elm-composition.sh
|
||||
|
35
bin/openapi3/elm-composition.sh
Executable file
35
bin/openapi3/elm-composition.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# auto format elm code using elm-format
|
||||
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.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/3_0/composition.yaml -g elm -t modules/openapi-generator/src/main/resources/elm -o samples/openapi3/client/composition/elm --enable-post-process-file $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -373,7 +373,13 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
elmImports.add(elmImport);
|
||||
}
|
||||
}
|
||||
if (cm.discriminator != null) {
|
||||
if (cm.oneOf != null) {
|
||||
for (String variant : cm.oneOf) {
|
||||
final ElmImport elmImport = createImport(variant);
|
||||
elmImports.add(elmImport);
|
||||
}
|
||||
}
|
||||
if (cm.discriminator != null && cm.children != null) {
|
||||
for (CodegenModel child : cm.children) {
|
||||
// add child imports
|
||||
final ElmImport elmImport = createImport(child.classname);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{>licenseInfo}}
|
||||
|
||||
module Data.{{classname}} exposing ({{#models}}{{#model}}{{classname}}{{#hasChildren}}(..){{/hasChildren}}{{#isEnum}}(..){{/isEnum}}{{^isEnum}}{{#vars}}{{#isEnum}}, {{vendorExtensions.elmCustomType}}(..){{/isEnum}}{{/vars}}{{/isEnum}}, decoder, encode, toString{{/model}}{{/models}})
|
||||
module Data.{{classname}} exposing ({{#models}}{{#model}}{{classname}}{{#hasChildren}}(..){{/hasChildren}}{{#isEnum}}(..){{/isEnum}}{{^isEnum}}{{#vars}}{{#isEnum}}, {{vendorExtensions.elmCustomType}}(..){{/isEnum}}{{/vars}}{{/isEnum}}, decoder, encode{{^isEnum}}{{^discriminator}}{{^oneOf}}, encodeWithTag{{/oneOf}}{{/discriminator}}{{/isEnum}}, toString{{/model}}{{/models}})
|
||||
|
||||
{{>imports}}import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -14,7 +14,7 @@ import Json.Encode as Encode
|
||||
{-| {{{description}}}
|
||||
-}
|
||||
{{/description}}
|
||||
{{#isEnum}}{{>modelTypeCustom}}{{/isEnum}}{{^isEnum}}{{#discriminator}}{{>modelTypeDiscriminator}}{{/discriminator}}{{^discriminator}}{{#isAlias}}{{>modelTypePrimitive}}{{/isAlias}}{{^isAlias}}{{#isArrayModel}}{{>modelTypeArray}}{{/isArrayModel}}{{^isArrayModel}}{{>modelTypeRecord}}{{/isArrayModel}}{{/isAlias}}{{/discriminator}}{{/isEnum}}
|
||||
{{#isEnum}}{{>modelTypeCustom}}{{/isEnum}}{{^isEnum}}{{#discriminator}}{{>modelTypeDiscriminator}}{{/discriminator}}{{^discriminator}}{{#oneOf}}{{#-first}}{{>modelTypeDiscriminator}}{{/-first}}{{/oneOf}}{{^oneOf}}{{#isAlias}}{{>modelTypePrimitive}}{{/isAlias}}{{^isAlias}}{{#isArrayModel}}{{>modelTypeArray}}{{/isArrayModel}}{{^isArrayModel}}{{>modelTypeRecord}}{{/isArrayModel}}{{/isAlias}}{{/oneOf}}{{/discriminator}}{{/isEnum}}
|
||||
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
@ -1,11 +1,22 @@
|
||||
type {{classname}}
|
||||
{{#mappedModels}}
|
||||
{{^discriminator}}{{#oneOf}}
|
||||
{{#-first}}={{/-first}}{{^-first}}|{{/-first}} {{{.}}}Type {{{.}}}
|
||||
{{/oneOf}}{{/discriminator}}
|
||||
{{#discriminator}}{{#mappedModels}}
|
||||
{{#-first}}={{/-first}}{{^-first}}|{{/-first}} {{modelName}}Type {{modelName}}
|
||||
{{/mappedModels}}
|
||||
{{/mappedModels}}{{/discriminator}}
|
||||
|
||||
|
||||
decoder : Decoder {{classname}}
|
||||
decoder =
|
||||
{{^discriminator}}
|
||||
Decode.oneOf
|
||||
{{#oneOf}}
|
||||
{{#-first}}[{{/-first}}{{^-first}},{{/-first}} Decode.map {{{.}}}Type {{{.}}}.decoder
|
||||
{{/oneOf}}
|
||||
]
|
||||
{{/discriminator}}
|
||||
{{#discriminator}}
|
||||
Decode.field "{{{discriminator.propertyName}}}" Decode.string
|
||||
|> Decode.andThen {{classVarName}}Decoder
|
||||
|
||||
@ -19,17 +30,25 @@ decoder =
|
||||
|
||||
{{/mappedModels}}
|
||||
_ ->
|
||||
Decode.fail <| "Trying to decode {{classname}}, but {{{discriminatorName}}} " ++ tag ++ " is not supported."
|
||||
Decode.fail <| "Trying to decode {{classname}}, but {{{discriminatorName}}} '" ++ tag ++ "' is not supported."
|
||||
{{/discriminator}}
|
||||
|
||||
|
||||
encode : {{classname}} -> Encode.Value
|
||||
encode model =
|
||||
case model of
|
||||
{{^discriminator}}{{#oneOf}}
|
||||
{{{.}}}Type subModel ->
|
||||
{{{.}}}.encode subModel
|
||||
|
||||
{{/oneOf}}{{/discriminator}}
|
||||
{{#discriminator}}
|
||||
{{#mappedModels}}
|
||||
{{modelName}}Type subModel ->
|
||||
{{modelName}}.encode "{{mappingName}}" subModel
|
||||
{{modelName}}.encodeWithTag ("{{discriminatorName}}", "{{mappingName}}") subModel
|
||||
|
||||
{{/mappedModels}}
|
||||
{{/discriminator}}
|
||||
|
||||
|
||||
toString : {{classname}} -> String
|
||||
|
@ -18,7 +18,7 @@ type alias {{classname}} =
|
||||
|
||||
toString : {{classname}} -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode{{#vendorExtensions.discriminatorName}} ""{{/vendorExtensions.discriminatorName}}
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
{{#vars}}
|
||||
|
@ -1,7 +1,16 @@
|
||||
encode : {{#vendorExtensions.discriminatorName}}String -> {{/vendorExtensions.discriminatorName}}{{classname}} -> Encode.Value
|
||||
encode {{#vendorExtensions.discriminatorName}}tag {{/vendorExtensions.discriminatorName}}model =
|
||||
Encode.object
|
||||
encode : {{classname}} -> Encode.Value
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> {{classname}} -> Encode.Value
|
||||
encodeWithTag (tagField, tag) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : {{classname}} -> List (String, Encode.Value)
|
||||
encodePairs model =
|
||||
{{#allVars}}
|
||||
{{#-first}}[{{/-first}}{{^-first}},{{/-first}} {{>recordFieldEncoder}}
|
||||
{{/allVars}}{{#vendorExtensions.discriminatorName}} , ( "{{{vendorExtensions.discriminatorName}}}", Encode.string tag ){{/vendorExtensions.discriminatorName}}
|
||||
]
|
||||
{{#-first}}[{{/-first}}{{^-first}},{{/-first}} {{>recordFieldEncoder}}
|
||||
{{/allVars}}
|
||||
]
|
||||
|
@ -0,0 +1,121 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: Composition and Inheritence (Polymorphism)
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/oneOf:
|
||||
post:
|
||||
summary: One of
|
||||
responses:
|
||||
200:
|
||||
description: Response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OneOf'
|
||||
/oneOfWithDiscriminator:
|
||||
post:
|
||||
summary: One of with discriminator
|
||||
responses:
|
||||
200:
|
||||
description: Response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OneOfWithDiscriminator'
|
||||
/oneOfWithAllOfDiscriminator:
|
||||
post:
|
||||
summary: One of with discriminator from all of
|
||||
responses:
|
||||
200:
|
||||
description: Response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OneOfWithAllOfDiscriminator'
|
||||
/allOf:
|
||||
post:
|
||||
summary: All of
|
||||
responses:
|
||||
200:
|
||||
description: Response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/AllOf'
|
||||
/allOfWithDiscriminator:
|
||||
post:
|
||||
summary: All of with discriminator
|
||||
responses:
|
||||
200:
|
||||
description: Response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BaseObject'
|
||||
components:
|
||||
schemas:
|
||||
OneOf:
|
||||
oneOf:
|
||||
- $ref: "#/components/schemas/ObjectA"
|
||||
- $ref: "#/components/schemas/ObjectB"
|
||||
OneOfWithDiscriminator:
|
||||
oneOf:
|
||||
- $ref: "#/components/schemas/ObjectA"
|
||||
- $ref: "#/components/schemas/ObjectB"
|
||||
discriminator:
|
||||
propertyName: objectType
|
||||
mapping:
|
||||
a: "#/components/schemas/ObjectA"
|
||||
b: "#/components/schemas/ObjectB"
|
||||
OneOfWithAllOfDiscriminator:
|
||||
oneOf:
|
||||
- $ref: "#/components/schemas/SubObjectA"
|
||||
- $ref: "#/components/schemas/SubObjectB"
|
||||
AllOf:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ObjectA"
|
||||
- $ref: "#/components/schemas/ObjectB"
|
||||
BaseObject:
|
||||
required:
|
||||
- objectType
|
||||
- value
|
||||
properties:
|
||||
objectType:
|
||||
type: string
|
||||
value:
|
||||
type: boolean
|
||||
discriminator:
|
||||
propertyName: objectType
|
||||
ObjectA:
|
||||
type: object
|
||||
required:
|
||||
- objectType
|
||||
properties:
|
||||
objectType:
|
||||
type: string
|
||||
valueA:
|
||||
type: string
|
||||
ObjectB:
|
||||
type: object
|
||||
required:
|
||||
- objectType
|
||||
properties:
|
||||
objectType:
|
||||
type: string
|
||||
valueB:
|
||||
type: number
|
||||
SubObjectA:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/BaseObject"
|
||||
- type: object
|
||||
properties:
|
||||
valueA:
|
||||
type: string
|
||||
SubObjectB:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/BaseObject"
|
||||
- type: object
|
||||
properties:
|
||||
valueB:
|
||||
type: number
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.ApiResponse exposing (ApiResponse, decoder, encode, toString)
|
||||
module Data.ApiResponse exposing (ApiResponse, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -36,12 +36,21 @@ decoder =
|
||||
|
||||
|
||||
encode : ApiResponse -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
||||
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
||||
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> ApiResponse -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : ApiResponse -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
||||
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
||||
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
||||
]
|
||||
|
||||
|
||||
toString : ApiResponse -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Category exposing (Category, decoder, encode, toString)
|
||||
module Data.Category exposing (Category, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -34,11 +34,20 @@ decoder =
|
||||
|
||||
|
||||
encode : Category -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Category -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Category -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
]
|
||||
|
||||
|
||||
toString : Category -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Order_ exposing (Order_, Status(..), decoder, encode, toString)
|
||||
module Data.Order_ exposing (Order_, Status(..), decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import DateTime exposing (DateTime)
|
||||
import Dict exposing (Dict)
|
||||
@ -49,15 +49,24 @@ decoder =
|
||||
|
||||
|
||||
encode : Order_ -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "petId", Maybe.withDefault Encode.null (Maybe.map Encode.int model.petId) )
|
||||
, ( "quantity", Maybe.withDefault Encode.null (Maybe.map Encode.int model.quantity) )
|
||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Order_ -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Order_ -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "petId", Maybe.withDefault Encode.null (Maybe.map Encode.int model.petId) )
|
||||
, ( "quantity", Maybe.withDefault Encode.null (Maybe.map Encode.int model.quantity) )
|
||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||
]
|
||||
|
||||
|
||||
toString : Order_ -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Pet exposing (Pet, Status(..), decoder, encode, toString)
|
||||
module Data.Pet exposing (Pet, Status(..), decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Data.Category as Category exposing (Category)
|
||||
import Data.Tag as Tag exposing (Tag)
|
||||
@ -50,15 +50,24 @@ decoder =
|
||||
|
||||
|
||||
encode : Pet -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encode model.category) )
|
||||
, ( "name", Encode.string model.name )
|
||||
, ( "photoUrls", (Encode.list << List.map Encode.string) model.photoUrls )
|
||||
, ( "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) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Pet -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Pet -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encode model.category) )
|
||||
, ( "name", Encode.string model.name )
|
||||
, ( "photoUrls", (Encode.list << List.map Encode.string) model.photoUrls )
|
||||
, ( "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) )
|
||||
]
|
||||
|
||||
|
||||
toString : Pet -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Tag exposing (Tag, decoder, encode, toString)
|
||||
module Data.Tag exposing (Tag, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -34,11 +34,20 @@ decoder =
|
||||
|
||||
|
||||
encode : Tag -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Tag -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Tag -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
]
|
||||
|
||||
|
||||
toString : Tag -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.User exposing (User, decoder, encode, toString)
|
||||
module Data.User exposing (User, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -46,17 +46,26 @@ decoder =
|
||||
|
||||
|
||||
encode : User -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
|
||||
, ( "firstName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.firstName) )
|
||||
, ( "lastName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.lastName) )
|
||||
, ( "email", Maybe.withDefault Encode.null (Maybe.map Encode.string model.email) )
|
||||
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
||||
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
||||
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> User -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : User -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
|
||||
, ( "firstName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.firstName) )
|
||||
, ( "lastName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.lastName) )
|
||||
, ( "email", Maybe.withDefault Encode.null (Maybe.map Encode.string model.email) )
|
||||
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
||||
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
||||
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
||||
]
|
||||
|
||||
|
||||
toString : User -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.ApiResponse exposing (ApiResponse, decoder, encode, toString)
|
||||
module Data.ApiResponse exposing (ApiResponse, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -36,12 +36,21 @@ decoder =
|
||||
|
||||
|
||||
encode : ApiResponse -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
||||
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
||||
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> ApiResponse -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : ApiResponse -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
||||
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
||||
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
||||
]
|
||||
|
||||
|
||||
toString : ApiResponse -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Category exposing (Category, decoder, encode, toString)
|
||||
module Data.Category exposing (Category, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -34,11 +34,20 @@ decoder =
|
||||
|
||||
|
||||
encode : Category -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Category -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Category -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
]
|
||||
|
||||
|
||||
toString : Category -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Order_ exposing (Order_, Status(..), decoder, encode, toString)
|
||||
module Data.Order_ exposing (Order_, Status(..), decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import DateTime exposing (DateTime)
|
||||
import Dict exposing (Dict)
|
||||
@ -49,15 +49,24 @@ decoder =
|
||||
|
||||
|
||||
encode : Order_ -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "petId", Maybe.withDefault Encode.null (Maybe.map Encode.int model.petId) )
|
||||
, ( "quantity", Maybe.withDefault Encode.null (Maybe.map Encode.int model.quantity) )
|
||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Order_ -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Order_ -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "petId", Maybe.withDefault Encode.null (Maybe.map Encode.int model.petId) )
|
||||
, ( "quantity", Maybe.withDefault Encode.null (Maybe.map Encode.int model.quantity) )
|
||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||
]
|
||||
|
||||
|
||||
toString : Order_ -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Pet exposing (Pet, Status(..), decoder, encode, toString)
|
||||
module Data.Pet exposing (Pet, Status(..), decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Data.Category as Category exposing (Category)
|
||||
import Data.Tag as Tag exposing (Tag)
|
||||
@ -50,15 +50,24 @@ decoder =
|
||||
|
||||
|
||||
encode : Pet -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encode model.category) )
|
||||
, ( "name", Encode.string model.name )
|
||||
, ( "photoUrls", Encode.list Encode.string model.photoUrls )
|
||||
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list Tag.encode) model.tags) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Pet -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Pet -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encode model.category) )
|
||||
, ( "name", Encode.string model.name )
|
||||
, ( "photoUrls", Encode.list Encode.string model.photoUrls )
|
||||
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list Tag.encode) model.tags) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
]
|
||||
|
||||
|
||||
toString : Pet -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Tag exposing (Tag, decoder, encode, toString)
|
||||
module Data.Tag exposing (Tag, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -34,11 +34,20 @@ decoder =
|
||||
|
||||
|
||||
encode : Tag -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Tag -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Tag -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
]
|
||||
|
||||
|
||||
toString : Tag -> String
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.User exposing (User, decoder, encode, toString)
|
||||
module Data.User exposing (User, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -46,17 +46,26 @@ decoder =
|
||||
|
||||
|
||||
encode : User -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
|
||||
, ( "firstName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.firstName) )
|
||||
, ( "lastName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.lastName) )
|
||||
, ( "email", Maybe.withDefault Encode.null (Maybe.map Encode.string model.email) )
|
||||
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
||||
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
||||
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> User -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : User -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
|
||||
, ( "firstName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.firstName) )
|
||||
, ( "lastName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.lastName) )
|
||||
, ( "email", Maybe.withDefault Encode.null (Maybe.map Encode.string model.email) )
|
||||
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
||||
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
||||
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
||||
]
|
||||
|
||||
|
||||
toString : User -> String
|
||||
|
1
samples/openapi3/client/composition/elm/.gitignore
vendored
Normal file
1
samples/openapi3/client/composition/elm/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/elm-stuff
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1 @@
|
||||
4.2.1-SNAPSHOT
|
10
samples/openapi3/client/composition/elm/README.md
Normal file
10
samples/openapi3/client/composition/elm/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Elm API client
|
||||
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
## Overview
|
||||
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client.
|
||||
|
||||
- API version: 1.0.0
|
||||
- Package version:
|
||||
- Build package: org.openapitools.codegen.languages.ElmClientCodegen
|
14
samples/openapi3/client/composition/elm/elm-compile-test
Executable file
14
samples/openapi3/client/composition/elm/elm-compile-test
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash -e
|
||||
# elm make all elm files under src
|
||||
|
||||
for ELM in `find src -name "*.elm"`
|
||||
do
|
||||
echo "Compiling $ELM"
|
||||
elm make $ELM --output /dev/null
|
||||
rc=$?
|
||||
if [[ $rc != 0 ]]
|
||||
then
|
||||
echo "ERROR!! FAILED TO COMPILE $ELM"
|
||||
exit $rc;
|
||||
fi
|
||||
done
|
33
samples/openapi3/client/composition/elm/elm.json
Normal file
33
samples/openapi3/client/composition/elm/elm.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"type": "application",
|
||||
"source-directories": [
|
||||
"src"
|
||||
],
|
||||
"elm-version": "0.19.0",
|
||||
"dependencies": {
|
||||
"direct": {
|
||||
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
|
||||
"danyx23/elm-uuid": "2.1.2",
|
||||
"elm/browser": "1.0.1",
|
||||
"elm/core": "1.0.2",
|
||||
"elm/html": "1.0.0",
|
||||
"elm/http": "2.0.0",
|
||||
"elm/json": "1.1.2",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/url": "1.0.0",
|
||||
"rtfeldman/elm-iso8601-date-strings": "1.1.3"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/bytes": "1.0.5",
|
||||
"elm/file": "1.0.1",
|
||||
"elm/parser": "1.1.0",
|
||||
"elm/random": "1.0.0",
|
||||
"elm/regex": "1.0.0",
|
||||
"elm/virtual-dom": "1.0.2"
|
||||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
"direct": {},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
43
samples/openapi3/client/composition/elm/pom.xml
Normal file
43
samples/openapi3/client/composition/elm/pom.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>ElmCompositionTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>Elm Composition Client</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundle-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>./elm-compile-test</executable>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
18
samples/openapi3/client/composition/elm/src/Byte.elm
Normal file
18
samples/openapi3/client/composition/elm/src/Byte.elm
Normal file
@ -0,0 +1,18 @@
|
||||
module Byte exposing (Byte, decoder, encode)
|
||||
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type alias Byte =
|
||||
String
|
||||
|
||||
|
||||
decoder : Decoder Byte
|
||||
decoder =
|
||||
Decode.string
|
||||
|
||||
|
||||
encode : Byte -> Encode.Value
|
||||
encode model =
|
||||
Encode.string model
|
56
samples/openapi3/client/composition/elm/src/Data/AllOf.elm
Normal file
56
samples/openapi3/client/composition/elm/src/Data/AllOf.elm
Normal file
@ -0,0 +1,56 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.AllOf exposing (AllOf, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type alias AllOf =
|
||||
{ objectType : String
|
||||
, valueA : Maybe String
|
||||
, valueB : Maybe Float
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder AllOf
|
||||
decoder =
|
||||
Decode.succeed AllOf
|
||||
|> required "objectType" Decode.string
|
||||
|> optional "valueA" (Decode.nullable Decode.string) Nothing
|
||||
|> optional "valueB" (Decode.nullable Decode.float) Nothing
|
||||
|
||||
|
||||
encode : AllOf -> Encode.Value
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> AllOf -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : AllOf -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "objectType", Encode.string model.objectType )
|
||||
, ( "valueA", Maybe.withDefault Encode.null (Maybe.map Encode.string model.valueA) )
|
||||
, ( "valueB", Maybe.withDefault Encode.null (Maybe.map Encode.float model.valueB) )
|
||||
]
|
||||
|
||||
|
||||
toString : AllOf -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
@ -0,0 +1,59 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.BaseObject exposing (BaseObject(..), decoder, encode, toString)
|
||||
|
||||
import Data.SubObjectA as SubObjectA exposing (SubObjectA)
|
||||
import Data.SubObjectB as SubObjectB exposing (SubObjectB)
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type BaseObject
|
||||
= SubObjectAType SubObjectA
|
||||
| SubObjectBType SubObjectB
|
||||
|
||||
|
||||
decoder : Decoder BaseObject
|
||||
decoder =
|
||||
Decode.field "objectType" Decode.string
|
||||
|> Decode.andThen baseObjectDecoder
|
||||
|
||||
|
||||
baseObjectDecoder : String -> Decoder BaseObject
|
||||
baseObjectDecoder tag =
|
||||
case tag of
|
||||
"SubObjectA" ->
|
||||
Decode.map SubObjectAType SubObjectA.decoder
|
||||
|
||||
"SubObjectB" ->
|
||||
Decode.map SubObjectBType SubObjectB.decoder
|
||||
|
||||
_ ->
|
||||
Decode.fail <| "Trying to decode BaseObject, but objectType '" ++ tag ++ "' is not supported."
|
||||
|
||||
|
||||
encode : BaseObject -> Encode.Value
|
||||
encode model =
|
||||
case model of
|
||||
SubObjectAType subModel ->
|
||||
SubObjectA.encodeWithTag ( "objectType", "SubObjectA" ) subModel
|
||||
|
||||
SubObjectBType subModel ->
|
||||
SubObjectB.encodeWithTag ( "objectType", "SubObjectB" ) subModel
|
||||
|
||||
|
||||
toString : BaseObject -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
53
samples/openapi3/client/composition/elm/src/Data/ObjectA.elm
Normal file
53
samples/openapi3/client/composition/elm/src/Data/ObjectA.elm
Normal file
@ -0,0 +1,53 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.ObjectA exposing (ObjectA, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type alias ObjectA =
|
||||
{ objectType : String
|
||||
, valueA : Maybe String
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder ObjectA
|
||||
decoder =
|
||||
Decode.succeed ObjectA
|
||||
|> required "objectType" Decode.string
|
||||
|> optional "valueA" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
encode : ObjectA -> Encode.Value
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> ObjectA -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : ObjectA -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "objectType", Encode.string model.objectType )
|
||||
, ( "valueA", Maybe.withDefault Encode.null (Maybe.map Encode.string model.valueA) )
|
||||
]
|
||||
|
||||
|
||||
toString : ObjectA -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
53
samples/openapi3/client/composition/elm/src/Data/ObjectB.elm
Normal file
53
samples/openapi3/client/composition/elm/src/Data/ObjectB.elm
Normal file
@ -0,0 +1,53 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.ObjectB exposing (ObjectB, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type alias ObjectB =
|
||||
{ objectType : String
|
||||
, valueB : Maybe Float
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder ObjectB
|
||||
decoder =
|
||||
Decode.succeed ObjectB
|
||||
|> required "objectType" Decode.string
|
||||
|> optional "valueB" (Decode.nullable Decode.float) Nothing
|
||||
|
||||
|
||||
encode : ObjectB -> Encode.Value
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> ObjectB -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : ObjectB -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "objectType", Encode.string model.objectType )
|
||||
, ( "valueB", Maybe.withDefault Encode.null (Maybe.map Encode.float model.valueB) )
|
||||
]
|
||||
|
||||
|
||||
toString : ObjectB -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
48
samples/openapi3/client/composition/elm/src/Data/OneOf.elm
Normal file
48
samples/openapi3/client/composition/elm/src/Data/OneOf.elm
Normal file
@ -0,0 +1,48 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.OneOf exposing (OneOf, decoder, encode, toString)
|
||||
|
||||
import Data.ObjectA as ObjectA exposing (ObjectA)
|
||||
import Data.ObjectB as ObjectB exposing (ObjectB)
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type OneOf
|
||||
= ObjectAType ObjectA
|
||||
| ObjectBType ObjectB
|
||||
|
||||
|
||||
decoder : Decoder OneOf
|
||||
decoder =
|
||||
Decode.oneOf
|
||||
[ Decode.map ObjectAType ObjectA.decoder
|
||||
, Decode.map ObjectBType ObjectB.decoder
|
||||
]
|
||||
|
||||
|
||||
encode : OneOf -> Encode.Value
|
||||
encode model =
|
||||
case model of
|
||||
ObjectAType subModel ->
|
||||
ObjectA.encode subModel
|
||||
|
||||
ObjectBType subModel ->
|
||||
ObjectB.encode subModel
|
||||
|
||||
|
||||
toString : OneOf -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
@ -0,0 +1,48 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.OneOfWithAllOfDiscriminator exposing (OneOfWithAllOfDiscriminator, decoder, encode, toString)
|
||||
|
||||
import Data.SubObjectA as SubObjectA exposing (SubObjectA)
|
||||
import Data.SubObjectB as SubObjectB exposing (SubObjectB)
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type OneOfWithAllOfDiscriminator
|
||||
= SubObjectAType SubObjectA
|
||||
| SubObjectBType SubObjectB
|
||||
|
||||
|
||||
decoder : Decoder OneOfWithAllOfDiscriminator
|
||||
decoder =
|
||||
Decode.oneOf
|
||||
[ Decode.map SubObjectAType SubObjectA.decoder
|
||||
, Decode.map SubObjectBType SubObjectB.decoder
|
||||
]
|
||||
|
||||
|
||||
encode : OneOfWithAllOfDiscriminator -> Encode.Value
|
||||
encode model =
|
||||
case model of
|
||||
SubObjectAType subModel ->
|
||||
SubObjectA.encode subModel
|
||||
|
||||
SubObjectBType subModel ->
|
||||
SubObjectB.encode subModel
|
||||
|
||||
|
||||
toString : OneOfWithAllOfDiscriminator -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
@ -0,0 +1,59 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.OneOfWithDiscriminator exposing (OneOfWithDiscriminator, decoder, encode, toString)
|
||||
|
||||
import Data.ObjectA as ObjectA exposing (ObjectA)
|
||||
import Data.ObjectB as ObjectB exposing (ObjectB)
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type OneOfWithDiscriminator
|
||||
= ObjectAType ObjectA
|
||||
| ObjectBType ObjectB
|
||||
|
||||
|
||||
decoder : Decoder OneOfWithDiscriminator
|
||||
decoder =
|
||||
Decode.field "objectType" Decode.string
|
||||
|> Decode.andThen oneOfWithDiscriminatorDecoder
|
||||
|
||||
|
||||
oneOfWithDiscriminatorDecoder : String -> Decoder OneOfWithDiscriminator
|
||||
oneOfWithDiscriminatorDecoder tag =
|
||||
case tag of
|
||||
"a" ->
|
||||
Decode.map ObjectAType ObjectA.decoder
|
||||
|
||||
"b" ->
|
||||
Decode.map ObjectBType ObjectB.decoder
|
||||
|
||||
_ ->
|
||||
Decode.fail <| "Trying to decode OneOfWithDiscriminator, but objectType '" ++ tag ++ "' is not supported."
|
||||
|
||||
|
||||
encode : OneOfWithDiscriminator -> Encode.Value
|
||||
encode model =
|
||||
case model of
|
||||
ObjectAType subModel ->
|
||||
ObjectA.encodeWithTag ( "objectType", "a" ) subModel
|
||||
|
||||
ObjectBType subModel ->
|
||||
ObjectB.encodeWithTag ( "objectType", "b" ) subModel
|
||||
|
||||
|
||||
toString : OneOfWithDiscriminator -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
@ -0,0 +1,53 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.SubObjectA exposing (SubObjectA, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type alias SubObjectA =
|
||||
{ value : Bool
|
||||
, valueA : Maybe String
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder SubObjectA
|
||||
decoder =
|
||||
Decode.succeed SubObjectA
|
||||
|> required "value" Decode.bool
|
||||
|> optional "valueA" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
encode : SubObjectA -> Encode.Value
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> SubObjectA -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : SubObjectA -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "value", Encode.bool model.value )
|
||||
, ( "valueA", Maybe.withDefault Encode.null (Maybe.map Encode.string model.valueA) )
|
||||
]
|
||||
|
||||
|
||||
toString : SubObjectA -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
@ -0,0 +1,50 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.SubObjectAAllOf exposing (SubObjectAAllOf, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type alias SubObjectAAllOf =
|
||||
{ valueA : Maybe String
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder SubObjectAAllOf
|
||||
decoder =
|
||||
Decode.succeed SubObjectAAllOf
|
||||
|> optional "valueA" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
encode : SubObjectAAllOf -> Encode.Value
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> SubObjectAAllOf -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : SubObjectAAllOf -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "valueA", Maybe.withDefault Encode.null (Maybe.map Encode.string model.valueA) )
|
||||
]
|
||||
|
||||
|
||||
toString : SubObjectAAllOf -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
@ -0,0 +1,53 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.SubObjectB exposing (SubObjectB, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type alias SubObjectB =
|
||||
{ value : Bool
|
||||
, valueB : Maybe Float
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder SubObjectB
|
||||
decoder =
|
||||
Decode.succeed SubObjectB
|
||||
|> required "value" Decode.bool
|
||||
|> optional "valueB" (Decode.nullable Decode.float) Nothing
|
||||
|
||||
|
||||
encode : SubObjectB -> Encode.Value
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> SubObjectB -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : SubObjectB -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "value", Encode.bool model.value )
|
||||
, ( "valueB", Maybe.withDefault Encode.null (Maybe.map Encode.float model.valueB) )
|
||||
]
|
||||
|
||||
|
||||
toString : SubObjectB -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
@ -0,0 +1,50 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Data.SubObjectBAllOf exposing (SubObjectBAllOf, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
type alias SubObjectBAllOf =
|
||||
{ valueB : Maybe Float
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder SubObjectBAllOf
|
||||
decoder =
|
||||
Decode.succeed SubObjectBAllOf
|
||||
|> optional "valueB" (Decode.nullable Decode.float) Nothing
|
||||
|
||||
|
||||
encode : SubObjectBAllOf -> Encode.Value
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> SubObjectBAllOf -> Encode.Value
|
||||
encodeWithTag ( tagField, tag ) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : SubObjectBAllOf -> List ( String, Encode.Value )
|
||||
encodePairs model =
|
||||
[ ( "valueB", Maybe.withDefault Encode.null (Maybe.map Encode.float model.valueB) )
|
||||
]
|
||||
|
||||
|
||||
toString : SubObjectBAllOf -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
37
samples/openapi3/client/composition/elm/src/DateOnly.elm
Normal file
37
samples/openapi3/client/composition/elm/src/DateOnly.elm
Normal file
@ -0,0 +1,37 @@
|
||||
module DateOnly exposing (DateOnly, decoder, encode, toString)
|
||||
|
||||
import Iso8601
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Encode as Encode
|
||||
import Result
|
||||
import Time
|
||||
|
||||
|
||||
type alias DateOnly =
|
||||
Time.Posix
|
||||
|
||||
|
||||
decoder : Decoder DateOnly
|
||||
decoder =
|
||||
Decode.string
|
||||
|> Decode.andThen decodeIsoString
|
||||
|
||||
|
||||
encode : DateOnly -> Encode.Value
|
||||
encode =
|
||||
Encode.string << toString
|
||||
|
||||
|
||||
decodeIsoString : String -> Decoder DateOnly
|
||||
decodeIsoString str =
|
||||
case Iso8601.toTime (str ++ "T00:00:00.000Z") of
|
||||
Result.Ok posix ->
|
||||
Decode.succeed posix
|
||||
|
||||
Result.Err _ ->
|
||||
Decode.fail <| "Invalid date: " ++ str
|
||||
|
||||
|
||||
toString : DateOnly -> String
|
||||
toString =
|
||||
String.left 10 << Iso8601.fromTime
|
37
samples/openapi3/client/composition/elm/src/DateTime.elm
Normal file
37
samples/openapi3/client/composition/elm/src/DateTime.elm
Normal file
@ -0,0 +1,37 @@
|
||||
module DateTime exposing (DateTime, decoder, encode, toString)
|
||||
|
||||
import Iso8601
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Encode as Encode
|
||||
import Result
|
||||
import Time
|
||||
|
||||
|
||||
type alias DateTime =
|
||||
Time.Posix
|
||||
|
||||
|
||||
decoder : Decoder DateTime
|
||||
decoder =
|
||||
Decode.string
|
||||
|> Decode.andThen decodeIsoString
|
||||
|
||||
|
||||
encode : DateTime -> Encode.Value
|
||||
encode =
|
||||
Encode.string << toString
|
||||
|
||||
|
||||
decodeIsoString : String -> Decoder DateTime
|
||||
decodeIsoString str =
|
||||
case Iso8601.toTime str of
|
||||
Result.Ok posix ->
|
||||
Decode.succeed posix
|
||||
|
||||
Result.Err _ ->
|
||||
Decode.fail <| "Invalid date: " ++ str
|
||||
|
||||
|
||||
toString : DateTime -> String
|
||||
toString =
|
||||
Iso8601.fromTime
|
61
samples/openapi3/client/composition/elm/src/Main.elm
Normal file
61
samples/openapi3/client/composition/elm/src/Main.elm
Normal file
@ -0,0 +1,61 @@
|
||||
module Main exposing (main)
|
||||
|
||||
import Browser
|
||||
import Html exposing (Html)
|
||||
|
||||
|
||||
main : Program () Model Msg
|
||||
main =
|
||||
Browser.element
|
||||
{ init = init
|
||||
, view = view
|
||||
, update = update
|
||||
, subscriptions = subscriptions
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- MODEL
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ value : Int
|
||||
}
|
||||
|
||||
|
||||
init : () -> ( Model, Cmd Msg )
|
||||
init _ =
|
||||
( Model 0, Cmd.none )
|
||||
|
||||
|
||||
|
||||
-- UPDATE
|
||||
|
||||
|
||||
type Msg
|
||||
= NoOp
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
NoOp ->
|
||||
( model, Cmd.none )
|
||||
|
||||
|
||||
|
||||
-- SUBSCRIPTIONS
|
||||
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions _ =
|
||||
Sub.none
|
||||
|
||||
|
||||
|
||||
-- VIEW
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view _ =
|
||||
Html.text "main"
|
123
samples/openapi3/client/composition/elm/src/Request/Default.elm
Normal file
123
samples/openapi3/client/composition/elm/src/Request/Default.elm
Normal file
@ -0,0 +1,123 @@
|
||||
{-
|
||||
Composition and Inheritence (Polymorphism)
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
NOTE: This file is auto generated by the openapi-generator.
|
||||
https://github.com/openapitools/openapi-generator.git
|
||||
Do not edit this file manually.
|
||||
-}
|
||||
|
||||
|
||||
module Request.Default exposing (allOfPost, allOfWithDiscriminatorPost, oneOfPost, oneOfWithAllOfDiscriminatorPost, oneOfWithDiscriminatorPost)
|
||||
|
||||
import Data.AllOf as AllOf exposing (AllOf)
|
||||
import Data.BaseObject as BaseObject exposing (BaseObject)
|
||||
import Data.OneOf as OneOf exposing (OneOf)
|
||||
import Data.OneOfWithAllOfDiscriminator as OneOfWithAllOfDiscriminator exposing (OneOfWithAllOfDiscriminator)
|
||||
import Data.OneOfWithDiscriminator as OneOfWithDiscriminator exposing (OneOfWithDiscriminator)
|
||||
import Dict
|
||||
import Http
|
||||
import Json.Decode as Decode
|
||||
import Url.Builder as Url
|
||||
|
||||
|
||||
basePath : String
|
||||
basePath =
|
||||
"http://localhost"
|
||||
|
||||
|
||||
allOfPost :
|
||||
{ onSend : Result Http.Error AllOf -> msg
|
||||
}
|
||||
-> Cmd msg
|
||||
allOfPost params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "allOf" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend AllOf.decoder
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
allOfWithDiscriminatorPost :
|
||||
{ onSend : Result Http.Error BaseObject -> msg
|
||||
}
|
||||
-> Cmd msg
|
||||
allOfWithDiscriminatorPost params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "allOfWithDiscriminator" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend BaseObject.decoder
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
oneOfPost :
|
||||
{ onSend : Result Http.Error OneOf -> msg
|
||||
}
|
||||
-> Cmd msg
|
||||
oneOfPost params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "oneOf" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend OneOf.decoder
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
oneOfWithAllOfDiscriminatorPost :
|
||||
{ onSend : Result Http.Error OneOfWithAllOfDiscriminator -> msg
|
||||
}
|
||||
-> Cmd msg
|
||||
oneOfWithAllOfDiscriminatorPost params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "oneOfWithAllOfDiscriminator" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend OneOfWithAllOfDiscriminator.decoder
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
oneOfWithDiscriminatorPost :
|
||||
{ onSend : Result Http.Error OneOfWithDiscriminator -> msg
|
||||
}
|
||||
-> Cmd msg
|
||||
oneOfWithDiscriminatorPost params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "oneOfWithDiscriminator" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend OneOfWithDiscriminator.decoder
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
@ -1 +1 @@
|
||||
4.0.3-SNAPSHOT
|
||||
4.2.1-SNAPSHOT
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.ApiResponse exposing (ApiResponse, decoder, encode)
|
||||
module Data.ApiResponse exposing (ApiResponse, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -37,12 +37,28 @@ decoder =
|
||||
|
||||
|
||||
encode : ApiResponse -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
||||
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
||||
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
||||
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> ApiResponse -> Encode.Value
|
||||
encodeWithTag (tagField, tag) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : ApiResponse -> List (String, Encode.Value)
|
||||
encodePairs model =
|
||||
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
||||
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
||||
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : ApiResponse -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Category exposing (Category, decoder, encode)
|
||||
module Data.Category exposing (Category, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -35,11 +35,27 @@ decoder =
|
||||
|
||||
|
||||
encode : Category -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Category -> Encode.Value
|
||||
encodeWithTag (tagField, tag) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Category -> List (String, Encode.Value)
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Category -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.InlineObject exposing (InlineObject, decoder, encode)
|
||||
module Data.InlineObject exposing (InlineObject, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -33,11 +33,27 @@ decoder =
|
||||
|
||||
|
||||
encode : InlineObject -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map Encode.string model.status) )
|
||||
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> InlineObject -> Encode.Value
|
||||
encodeWithTag (tagField, tag) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : InlineObject -> List (String, Encode.Value)
|
||||
encodePairs model =
|
||||
[ ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map Encode.string model.status) )
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : InlineObject -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.InlineObject1 exposing (InlineObject1, decoder, encode)
|
||||
module Data.InlineObject1 exposing (InlineObject1, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -33,11 +33,27 @@ decoder =
|
||||
|
||||
|
||||
encode : InlineObject1 -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "additionalMetadata", Maybe.withDefault Encode.null (Maybe.map Encode.string model.additionalMetadata) )
|
||||
, ( "file", Maybe.withDefault Encode.null (Maybe.map Encode.string model.file) )
|
||||
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> InlineObject1 -> Encode.Value
|
||||
encodeWithTag (tagField, tag) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : InlineObject1 -> List (String, Encode.Value)
|
||||
encodePairs model =
|
||||
[ ( "additionalMetadata", Maybe.withDefault Encode.null (Maybe.map Encode.string model.additionalMetadata) )
|
||||
, ( "file", Maybe.withDefault Encode.null (Maybe.map Encode.string model.file) )
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : InlineObject1 -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Order_ exposing (Order_, Status(..), decoder, encode)
|
||||
module Data.Order_ exposing (Order_, Status(..), decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import DateTime exposing (DateTime)
|
||||
import Dict exposing (Dict)
|
||||
@ -51,16 +51,31 @@ decoder =
|
||||
|
||||
|
||||
encode : Order_ -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "petId", Maybe.withDefault Encode.null (Maybe.map Encode.int model.petId) )
|
||||
, ( "quantity", Maybe.withDefault Encode.null (Maybe.map Encode.int model.quantity) )
|
||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Order_ -> Encode.Value
|
||||
encodeWithTag (tagField, tag) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Order_ -> List (String, Encode.Value)
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "petId", Maybe.withDefault Encode.null (Maybe.map Encode.int model.petId) )
|
||||
, ( "quantity", Maybe.withDefault Encode.null (Maybe.map Encode.int model.quantity) )
|
||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Order_ -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
@ -99,3 +114,4 @@ encodeStatus model =
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Pet exposing (Pet, Status(..), decoder, encode)
|
||||
module Data.Pet exposing (Pet, Status(..), decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Data.Category as Category exposing (Category)
|
||||
import Data.Tag as Tag exposing (Tag)
|
||||
@ -52,16 +52,31 @@ decoder =
|
||||
|
||||
|
||||
encode : Pet -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encode model.category) )
|
||||
, ( "name", Encode.string model.name )
|
||||
, ( "photoUrls", (Encode.list Encode.string) model.photoUrls )
|
||||
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list Tag.encode) model.tags) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Pet -> Encode.Value
|
||||
encodeWithTag (tagField, tag) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Pet -> List (String, Encode.Value)
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encode model.category) )
|
||||
, ( "name", Encode.string model.name )
|
||||
, ( "photoUrls", (Encode.list Encode.string) model.photoUrls )
|
||||
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list Tag.encode) model.tags) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Pet -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
@ -100,3 +115,4 @@ encodeStatus model =
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.Tag exposing (Tag, decoder, encode)
|
||||
module Data.Tag exposing (Tag, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -35,11 +35,27 @@ decoder =
|
||||
|
||||
|
||||
encode : Tag -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> Tag -> Encode.Value
|
||||
encodeWithTag (tagField, tag) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : Tag -> List (String, Encode.Value)
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Tag -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
-}
|
||||
|
||||
|
||||
module Data.User exposing (User, decoder, encode)
|
||||
module Data.User exposing (User, decoder, encode, encodeWithTag, toString)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -47,17 +47,33 @@ decoder =
|
||||
|
||||
|
||||
encode : User -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
|
||||
, ( "firstName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.firstName) )
|
||||
, ( "lastName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.lastName) )
|
||||
, ( "email", Maybe.withDefault Encode.null (Maybe.map Encode.string model.email) )
|
||||
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
||||
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
||||
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
||||
|
||||
]
|
||||
encode =
|
||||
Encode.object << encodePairs
|
||||
|
||||
|
||||
encodeWithTag : ( String, String ) -> User -> Encode.Value
|
||||
encodeWithTag (tagField, tag) model =
|
||||
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
|
||||
|
||||
|
||||
encodePairs : User -> List (String, Encode.Value)
|
||||
encodePairs model =
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
|
||||
, ( "firstName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.firstName) )
|
||||
, ( "lastName", Maybe.withDefault Encode.null (Maybe.map Encode.string model.lastName) )
|
||||
, ( "email", Maybe.withDefault Encode.null (Maybe.map Encode.string model.email) )
|
||||
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
||||
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
||||
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : User -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -25,8 +25,8 @@ type Status
|
||||
| StatusPending
|
||||
| StatusSold
|
||||
|
||||
statusToString : Status -> String
|
||||
statusToString value =
|
||||
stringifyStatus : Status -> String
|
||||
stringifyStatus value =
|
||||
case value of
|
||||
StatusAvailable ->
|
||||
"available"
|
||||
@ -58,10 +58,10 @@ addPet :
|
||||
addPet params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet"]
|
||||
[]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| Pet.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -83,10 +83,10 @@ deletePet :
|
||||
deletePet headers params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = List.filterMap identity [Maybe.map (Http.header "api_key" ) headers.apiKey]
|
||||
, headers = List.filterMap identity [Maybe.map (Http.header "api_key" << identity) headers.apiKey]
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
[]
|
||||
["pet", String.fromInt params.petId]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -108,10 +108,10 @@ findPetsByStatus :
|
||||
findPetsByStatus params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", "findByStatus"]
|
||||
(List.filterMap identity [Just (Url.string "status" <| (String.join "," << List.map statusToString) params.status)])
|
||||
(List.filterMap identity [(Just << Url.string "status" << String.join "," << List.map stringifyStatus) params.status])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
||||
, timeout = Just 30000
|
||||
@ -127,16 +127,16 @@ findPetsByTags :
|
||||
|
||||
|
||||
|
||||
, tags : List String , maxCount : Maybe (Int)
|
||||
, tags : List String
|
||||
}
|
||||
-> Cmd msg
|
||||
findPetsByTags params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", "findByTags"]
|
||||
(List.filterMap identity [Just (Url.string "tags" <| (String.join ",") params.tags), Maybe.map (Url.string "maxCount" << String.fromInt) params.maxCount])
|
||||
(List.filterMap identity [(Just << Url.string "tags" << String.join "," << List.map identity) params.tags])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
||||
, timeout = Just 30000
|
||||
@ -158,10 +158,10 @@ getPetById :
|
||||
getPetById params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
[]
|
||||
["pet", String.fromInt params.petId]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Pet.decoder
|
||||
, timeout = Just 30000
|
||||
@ -181,10 +181,10 @@ updatePet :
|
||||
updatePet params =
|
||||
Http.request
|
||||
{ method = "PUT"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet"]
|
||||
[]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| Pet.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -204,10 +204,10 @@ updatePetWithForm :
|
||||
updatePetWithForm params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
[]
|
||||
["pet", String.fromInt params.petId]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -227,10 +227,10 @@ uploadFile :
|
||||
uploadFile params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId, "uploadImage"]
|
||||
[]
|
||||
["pet", String.fromInt params.petId, "uploadImage"]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend ApiResponse.decoder
|
||||
, timeout = Just 30000
|
||||
|
@ -40,10 +40,10 @@ deleteOrder :
|
||||
deleteOrder params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order", params.orderId]
|
||||
[]
|
||||
["store", "order", identity params.orderId]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -65,10 +65,10 @@ getInventory :
|
||||
getInventory params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "inventory"]
|
||||
[]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.dict Decode.int)
|
||||
, timeout = Just 30000
|
||||
@ -90,10 +90,10 @@ getOrderById :
|
||||
getOrderById params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order", String.fromInt params.orderId]
|
||||
[]
|
||||
["store", "order", String.fromInt params.orderId]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Order_.decoder
|
||||
, timeout = Just 30000
|
||||
@ -113,10 +113,10 @@ placeOrder :
|
||||
placeOrder params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order"]
|
||||
[]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| Order_.encode params.body
|
||||
, expect = Http.expectJson params.onSend Order_.decoder
|
||||
, timeout = Just 30000
|
||||
|
@ -40,10 +40,10 @@ createUser :
|
||||
createUser params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user"]
|
||||
[]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -63,10 +63,10 @@ createUsersWithArrayInput :
|
||||
createUsersWithArrayInput params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "createWithArray"]
|
||||
[]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -86,10 +86,10 @@ createUsersWithListInput :
|
||||
createUsersWithListInput params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "createWithList"]
|
||||
[]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -111,10 +111,10 @@ deleteUser :
|
||||
deleteUser params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", params.username]
|
||||
[]
|
||||
["user", identity params.username]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -134,10 +134,10 @@ getUserByName :
|
||||
getUserByName params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", params.username]
|
||||
[]
|
||||
["user", identity params.username]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend User.decoder
|
||||
, timeout = Just 30000
|
||||
@ -157,10 +157,10 @@ loginUser :
|
||||
loginUser params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "login"]
|
||||
(List.filterMap identity [Just (Url.string "username" params.username), Just (Url.string "password" params.password)])
|
||||
(List.filterMap identity [(Just << Url.string "username" << identity) params.username, (Just << Url.string "password" << identity) params.password])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Decode.string
|
||||
, timeout = Just 30000
|
||||
@ -180,10 +180,10 @@ logoutUser :
|
||||
logoutUser params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "logout"]
|
||||
[]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -205,10 +205,10 @@ updateUser :
|
||||
updateUser params =
|
||||
Http.request
|
||||
{ method = "PUT"
|
||||
, headers = []
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", params.username]
|
||||
[]
|
||||
["user", identity params.username]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
|
Loading…
x
Reference in New Issue
Block a user