mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 19:08:52 +00:00
[elm][haskell-servant] Fix issue 3256 (#3262)
* [elm] fix empty operation exception (#3256) * [haskell-servant] fix empty operation type (#3256) * [elm][haskell-servant] update samples
This commit is contained in:
parent
35262aa7d1
commit
95ba9525f9
@ -446,7 +446,9 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
op.path = ("\"" + path + "\"").replaceAll(" \\+\\+ \"\"", "");
|
||||
} else {
|
||||
final List<String> paths = Arrays.asList(op.path.substring(1).split("/"));
|
||||
String path = paths.stream().map(str -> str.charAt(0) == '{' ? str : "\"" + str + "\"").collect(Collectors.joining(", "));
|
||||
String path = paths.stream()
|
||||
.map(str -> str.startsWith("{") && str.endsWith("}") ? str : "\"" + str + "\"")
|
||||
.collect(Collectors.joining(", "));
|
||||
for (CodegenParameter param : op.pathParams) {
|
||||
String str = paramToString("params", param, false, null);
|
||||
path = path.replace("{" + param.paramName + "}", str);
|
||||
|
@ -411,6 +411,11 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
for (CodegenParameter param : pathParams) {
|
||||
captureTypes.put(param.baseName, param.dataType);
|
||||
}
|
||||
|
||||
// Properly handle root-only routes (#3256)
|
||||
if (path.contentEquals("/")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// Cut off the leading slash, if it is present.
|
||||
if (path.startsWith("/")) {
|
||||
|
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.elm;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.ClientOpts;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.MockDefaultGenerator;
|
||||
import org.openapitools.codegen.languages.ElmClientCodegen;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
public class ElmClientCodegenTest {
|
||||
|
||||
@Test
|
||||
public void testPostProcessRootEndpoint() {
|
||||
// given
|
||||
final ElmClientCodegen codegen = new ElmClientCodegen();
|
||||
|
||||
CodegenOperation rootOp = new CodegenOperation() {{ path = "/"; }};
|
||||
List<CodegenOperation> ops = newArrayList(rootOp);
|
||||
|
||||
Map<String, Object> operations = new HashMap<>();
|
||||
operations.put("operations", ImmutableMap
|
||||
.<String, Object>builder()
|
||||
.put("operation", ops)
|
||||
.build());
|
||||
|
||||
// when
|
||||
Map<String, Object> result = codegen.postProcessOperationsWithModels(operations, emptyList());
|
||||
|
||||
// then
|
||||
assertEquals(result.size(), 2);
|
||||
assertTrue(result.containsKey("operations"));
|
||||
assertTrue(result.containsKey("elmImports"));
|
||||
|
||||
assertEquals(rootOp.path, "\"\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerateRootEndpoint() throws IOException {
|
||||
// given
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
|
||||
final ElmClientCodegen codegen = new ElmClientCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/rootOperation.yaml", null, new ParseOptions())
|
||||
.getOpenAPI();
|
||||
|
||||
ClientOpts opts = new ClientOpts();
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.setOpenAPI(openAPI);
|
||||
input.setConfig(codegen);
|
||||
input.setOpts(opts);
|
||||
|
||||
// when
|
||||
MockDefaultGenerator generator = new MockDefaultGenerator();
|
||||
generator.opts(input).generate();
|
||||
|
||||
// then
|
||||
assertFileContains(generator, outputPath + "/src/Request/Default.elm", "rootGet", "[\"\"]");
|
||||
}
|
||||
|
||||
private static void assertFileContains(MockDefaultGenerator generator, String file, String... expected) {
|
||||
String content = generator.getFiles().get(file);
|
||||
assertNotNull(content, "The file \"" + file + "\" was not generated");
|
||||
for (String line : expected) {
|
||||
assertTrue(content.contains(line), "The file \"" + file + "\" does not contain \"" + line + "\"");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.haskellservant;
|
||||
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.ClientOpts;
|
||||
import org.openapitools.codegen.MockDefaultGenerator;
|
||||
import org.openapitools.codegen.languages.HaskellServantCodegen;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
public class HaskellServantCodegenTest {
|
||||
|
||||
@Test
|
||||
public void testGenerateRootEndpoint() throws IOException {
|
||||
// given
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
|
||||
final HaskellServantCodegen codegen = new HaskellServantCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/rootOperation.yaml", null, new ParseOptions())
|
||||
.getOpenAPI();
|
||||
|
||||
ClientOpts opts = new ClientOpts();
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.setOpenAPI(openAPI);
|
||||
input.setConfig(codegen);
|
||||
input.setOpts(opts);
|
||||
|
||||
// when
|
||||
MockDefaultGenerator generator = new MockDefaultGenerator();
|
||||
generator.opts(input).generate();
|
||||
|
||||
// then
|
||||
assertFileNotContains(generator, outputPath + "/lib/RootOperation/API.hs", "\"\" :>");
|
||||
}
|
||||
|
||||
private static void assertFileNotContains(MockDefaultGenerator generator, String file, String... expected) {
|
||||
String content = generator.getFiles().get(file);
|
||||
assertNotNull(content, "The file \"" + file + "\" was not generated");
|
||||
for (String line : expected) {
|
||||
assertFalse(content.contains(line), "The file \"" + file + "\" contains \"" + line + "\"");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
openapi: 3.0.0
|
||||
|
||||
info:
|
||||
title: Root Operation
|
||||
version: 1.0.0
|
||||
|
||||
paths:
|
||||
/:
|
||||
get:
|
||||
summary: Simple root endpoint
|
||||
responses:
|
||||
204:
|
||||
description: No response body
|
@ -1 +1 @@
|
||||
4.0.0-SNAPSHOT
|
||||
4.0.3-SNAPSHOT
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -21,9 +21,9 @@ import Json.Encode as Encode
|
||||
{-| Describes the result of uploading an image resource
|
||||
-}
|
||||
type alias ApiResponse =
|
||||
{ code : Maybe Int
|
||||
, type_ : Maybe String
|
||||
, message : Maybe String
|
||||
{ code : Maybe (Int)
|
||||
, type_ : Maybe (String)
|
||||
, message : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
@ -35,10 +35,14 @@ decoder =
|
||||
|> optional "message" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
||||
{-| A category for a pet
|
||||
-}
|
||||
type alias Category =
|
||||
{ id : Maybe Int
|
||||
, name : Maybe String
|
||||
{ id : Maybe (Int)
|
||||
, name : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
@ -33,9 +33,13 @@ decoder =
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -22,12 +22,12 @@ import Json.Encode as Encode
|
||||
{-| An order for a pets from the pet store
|
||||
-}
|
||||
type alias Order_ =
|
||||
{ id : Maybe Int
|
||||
, petId : Maybe Int
|
||||
, quantity : Maybe Int
|
||||
, shipDate : Maybe DateTime
|
||||
, status : Maybe Status
|
||||
, complete : Maybe Bool
|
||||
{ id : Maybe (Int)
|
||||
, petId : Maybe (Int)
|
||||
, quantity : Maybe (Int)
|
||||
, shipDate : Maybe (DateTime)
|
||||
, status : Maybe (Status)
|
||||
, complete : Maybe (Bool)
|
||||
}
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ type Status
|
||||
| Delivered
|
||||
|
||||
|
||||
|
||||
decoder : Decoder Order_
|
||||
decoder =
|
||||
decode Order_
|
||||
@ -48,6 +49,7 @@ decoder =
|
||||
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
||||
|
||||
|
||||
|
||||
encode : Order_ -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
@ -57,9 +59,11 @@ encode model =
|
||||
, ( "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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
statusDecoder : Decoder Status
|
||||
statusDecoder =
|
||||
Decode.string
|
||||
@ -80,6 +84,7 @@ statusDecoder =
|
||||
)
|
||||
|
||||
|
||||
|
||||
encodeStatus : Status -> Encode.Value
|
||||
encodeStatus model =
|
||||
case model of
|
||||
@ -91,3 +96,6 @@ encodeStatus model =
|
||||
|
||||
Delivered ->
|
||||
Encode.string "delivered"
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -23,12 +23,12 @@ import Json.Encode as Encode
|
||||
{-| A pet for sale in the pet store
|
||||
-}
|
||||
type alias Pet =
|
||||
{ id : Maybe Int
|
||||
, category : Maybe Category
|
||||
{ id : Maybe (Int)
|
||||
, category : Maybe (Category)
|
||||
, name : String
|
||||
, photoUrls : List String
|
||||
, tags : Maybe (List Tag)
|
||||
, status : Maybe Status
|
||||
, photoUrls : (List String)
|
||||
, tags : Maybe ((List Tag))
|
||||
, status : Maybe (Status)
|
||||
}
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ type Status
|
||||
| Sold
|
||||
|
||||
|
||||
|
||||
decoder : Decoder Pet
|
||||
decoder =
|
||||
decode Pet
|
||||
@ -49,6 +50,7 @@ decoder =
|
||||
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
||||
|
||||
|
||||
|
||||
encode : Pet -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
@ -58,9 +60,11 @@ encode model =
|
||||
, ( "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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
statusDecoder : Decoder Status
|
||||
statusDecoder =
|
||||
Decode.string
|
||||
@ -81,6 +85,7 @@ statusDecoder =
|
||||
)
|
||||
|
||||
|
||||
|
||||
encodeStatus : Status -> Encode.Value
|
||||
encodeStatus model =
|
||||
case model of
|
||||
@ -92,3 +97,6 @@ encodeStatus model =
|
||||
|
||||
Sold ->
|
||||
Encode.string "sold"
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
||||
{-| A tag for a pet
|
||||
-}
|
||||
type alias Tag =
|
||||
{ id : Maybe Int
|
||||
, name : Maybe String
|
||||
{ id : Maybe (Int)
|
||||
, name : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
@ -33,9 +33,13 @@ decoder =
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -21,14 +21,14 @@ import Json.Encode as Encode
|
||||
{-| A User who is purchasing from the pet store
|
||||
-}
|
||||
type alias User =
|
||||
{ id : Maybe Int
|
||||
, username : Maybe String
|
||||
, firstName : Maybe String
|
||||
, lastName : Maybe String
|
||||
, email : Maybe String
|
||||
, password : Maybe String
|
||||
, phone : Maybe String
|
||||
, userStatus : Maybe Int
|
||||
{ id : Maybe (Int)
|
||||
, username : Maybe (String)
|
||||
, firstName : Maybe (String)
|
||||
, lastName : Maybe (String)
|
||||
, email : Maybe (String)
|
||||
, password : Maybe (String)
|
||||
, phone : Maybe (String)
|
||||
, userStatus : Maybe (Int)
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ decoder =
|
||||
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
||||
|
||||
|
||||
|
||||
encode : User -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
@ -56,4 +57,7 @@ encode model =
|
||||
, ( "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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
@ -34,4 +34,4 @@ decodeIsoString str =
|
||||
|
||||
toString : DateTime -> String
|
||||
toString =
|
||||
toIsoString
|
||||
toIsoString
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -12,8 +12,8 @@
|
||||
|
||||
module Request.Pet exposing (addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
||||
|
||||
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||
import Data.Pet as Pet exposing (Pet)
|
||||
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||
import Dict
|
||||
import Http
|
||||
import Json.Decode as Decode
|
||||
@ -40,7 +40,7 @@ addPet model =
|
||||
deletePet : Int -> Http.Request ()
|
||||
deletePet petId =
|
||||
{ method = "DELETE"
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||
@ -85,7 +85,7 @@ findPetsByTags =
|
||||
getPetById : Int -> Http.Request Pet
|
||||
getPetById petId =
|
||||
{ method = "GET"
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson Pet.decoder
|
||||
@ -111,7 +111,7 @@ updatePet model =
|
||||
updatePetWithForm : Int -> Http.Request ()
|
||||
updatePetWithForm petId =
|
||||
{ method = "POST"
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||
@ -124,7 +124,7 @@ updatePetWithForm petId =
|
||||
uploadFile : Int -> Http.Request ApiResponse
|
||||
uploadFile petId =
|
||||
{ method = "POST"
|
||||
, url = basePath ++ "/pet/" ++ toString petId ++ "/uploadImage"
|
||||
, url = basePath ++ "/pet/" ++ toString petId ++ "/uploadImage"
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson ApiResponse.decoder
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -28,7 +28,7 @@ basePath =
|
||||
deleteOrder : String -> Http.Request ()
|
||||
deleteOrder orderId =
|
||||
{ method = "DELETE"
|
||||
, url = basePath ++ "/store/order/" ++ orderId
|
||||
, url = basePath ++ "/store/order/" ++ orderId
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||
@ -58,7 +58,7 @@ getInventory =
|
||||
getOrderById : Int -> Http.Request Order_
|
||||
getOrderById orderId =
|
||||
{ method = "GET"
|
||||
, url = basePath ++ "/store/order/" ++ toString orderId
|
||||
, url = basePath ++ "/store/order/" ++ toString orderId
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson Order_.decoder
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -69,7 +69,7 @@ createUsersWithListInput model =
|
||||
deleteUser : String -> Http.Request ()
|
||||
deleteUser username =
|
||||
{ method = "DELETE"
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||
@ -82,7 +82,7 @@ deleteUser username =
|
||||
getUserByName : String -> Http.Request User
|
||||
getUserByName username =
|
||||
{ method = "GET"
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson User.decoder
|
||||
@ -123,7 +123,7 @@ logoutUser =
|
||||
updateUser : String -> User -> Http.Request ()
|
||||
updateUser username model =
|
||||
{ method = "PUT"
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, headers = []
|
||||
, body = Http.jsonBody <| User.encode model
|
||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||
|
@ -1 +1 @@
|
||||
4.0.0-SNAPSHOT
|
||||
4.0.3-SNAPSHOT
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -21,9 +21,9 @@ import Json.Encode as Encode
|
||||
{-| Describes the result of uploading an image resource
|
||||
-}
|
||||
type alias ApiResponse =
|
||||
{ code : Maybe Int
|
||||
, type_ : Maybe String
|
||||
, message : Maybe String
|
||||
{ code : Maybe (Int)
|
||||
, type_ : Maybe (String)
|
||||
, message : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
@ -35,10 +35,14 @@ decoder =
|
||||
|> optional "message" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
||||
{-| A category for a pet
|
||||
-}
|
||||
type alias Category =
|
||||
{ id : Maybe Int
|
||||
, name : Maybe String
|
||||
{ id : Maybe (Int)
|
||||
, name : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
@ -33,9 +33,13 @@ decoder =
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -22,12 +22,12 @@ import Json.Encode as Encode
|
||||
{-| An order for a pets from the pet store
|
||||
-}
|
||||
type alias Order_ =
|
||||
{ id : Maybe Int
|
||||
, petId : Maybe Int
|
||||
, quantity : Maybe Int
|
||||
, shipDate : Maybe DateTime
|
||||
, status : Maybe Status
|
||||
, complete : Maybe Bool
|
||||
{ id : Maybe (Int)
|
||||
, petId : Maybe (Int)
|
||||
, quantity : Maybe (Int)
|
||||
, shipDate : Maybe (DateTime)
|
||||
, status : Maybe (Status)
|
||||
, complete : Maybe (Bool)
|
||||
}
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ type Status
|
||||
| Delivered
|
||||
|
||||
|
||||
|
||||
decoder : Decoder Order_
|
||||
decoder =
|
||||
Decode.succeed Order_
|
||||
@ -48,6 +49,7 @@ decoder =
|
||||
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
||||
|
||||
|
||||
|
||||
encode : Order_ -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
@ -57,9 +59,11 @@ encode model =
|
||||
, ( "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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
statusDecoder : Decoder Status
|
||||
statusDecoder =
|
||||
Decode.string
|
||||
@ -80,6 +84,7 @@ statusDecoder =
|
||||
)
|
||||
|
||||
|
||||
|
||||
encodeStatus : Status -> Encode.Value
|
||||
encodeStatus model =
|
||||
case model of
|
||||
@ -91,3 +96,6 @@ encodeStatus model =
|
||||
|
||||
Delivered ->
|
||||
Encode.string "delivered"
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -23,12 +23,12 @@ import Json.Encode as Encode
|
||||
{-| A pet for sale in the pet store
|
||||
-}
|
||||
type alias Pet =
|
||||
{ id : Maybe Int
|
||||
, category : Maybe Category
|
||||
{ id : Maybe (Int)
|
||||
, category : Maybe (Category)
|
||||
, name : String
|
||||
, photoUrls : List String
|
||||
, tags : Maybe (List Tag)
|
||||
, status : Maybe Status
|
||||
, photoUrls : (List String)
|
||||
, tags : Maybe ((List Tag))
|
||||
, status : Maybe (Status)
|
||||
}
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ type Status
|
||||
| Sold
|
||||
|
||||
|
||||
|
||||
decoder : Decoder Pet
|
||||
decoder =
|
||||
Decode.succeed Pet
|
||||
@ -49,18 +50,21 @@ decoder =
|
||||
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
||||
|
||||
|
||||
|
||||
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 )
|
||||
, ( "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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
statusDecoder : Decoder Status
|
||||
statusDecoder =
|
||||
Decode.string
|
||||
@ -81,6 +85,7 @@ statusDecoder =
|
||||
)
|
||||
|
||||
|
||||
|
||||
encodeStatus : Status -> Encode.Value
|
||||
encodeStatus model =
|
||||
case model of
|
||||
@ -92,3 +97,6 @@ encodeStatus model =
|
||||
|
||||
Sold ->
|
||||
Encode.string "sold"
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
||||
{-| A tag for a pet
|
||||
-}
|
||||
type alias Tag =
|
||||
{ id : Maybe Int
|
||||
, name : Maybe String
|
||||
{ id : Maybe (Int)
|
||||
, name : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
@ -33,9 +33,13 @@ decoder =
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -21,14 +21,14 @@ import Json.Encode as Encode
|
||||
{-| A User who is purchasing from the pet store
|
||||
-}
|
||||
type alias User =
|
||||
{ id : Maybe Int
|
||||
, username : Maybe String
|
||||
, firstName : Maybe String
|
||||
, lastName : Maybe String
|
||||
, email : Maybe String
|
||||
, password : Maybe String
|
||||
, phone : Maybe String
|
||||
, userStatus : Maybe Int
|
||||
{ id : Maybe (Int)
|
||||
, username : Maybe (String)
|
||||
, firstName : Maybe (String)
|
||||
, lastName : Maybe (String)
|
||||
, email : Maybe (String)
|
||||
, password : Maybe (String)
|
||||
, phone : Maybe (String)
|
||||
, userStatus : Maybe (Int)
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ decoder =
|
||||
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
||||
|
||||
|
||||
|
||||
encode : User -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
@ -56,4 +57,7 @@ encode model =
|
||||
, ( "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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
@ -34,4 +34,4 @@ decodeIsoString str =
|
||||
|
||||
toString : DateTime -> String
|
||||
toString =
|
||||
Iso8601.fromTime
|
||||
Iso8601.fromTime
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -10,10 +10,10 @@
|
||||
-}
|
||||
|
||||
|
||||
module Request.Pet exposing (Status(..), addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
||||
module Request.Pet exposing (addPet, deletePet, findPetsByStatus, Status(..), findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
||||
|
||||
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||
import Data.Pet as Pet exposing (Pet)
|
||||
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||
import Dict
|
||||
import Http
|
||||
import Json.Decode as Decode
|
||||
@ -25,7 +25,6 @@ type Status
|
||||
| Pending
|
||||
| Sold
|
||||
|
||||
|
||||
statusToString : Status -> String
|
||||
statusToString value =
|
||||
case value of
|
||||
@ -39,6 +38,9 @@ statusToString value =
|
||||
"sold"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
basePath : String
|
||||
basePath =
|
||||
"http://petstore.swagger.io/v2"
|
||||
@ -46,17 +48,20 @@ basePath =
|
||||
|
||||
addPet :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : Pet
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
addPet params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet" ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet"]
|
||||
[]
|
||||
, body = Http.jsonBody <| Pet.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -65,21 +70,23 @@ addPet params =
|
||||
|
||||
|
||||
deletePet :
|
||||
{ apiKey : Maybe String
|
||||
{ apiKey : Maybe (String)
|
||||
} ->
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
->
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
, petId : Int
|
||||
}
|
||||
-> Cmd msg
|
||||
deletePet headers params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = List.filterMap identity [ Maybe.map (Http.header "api_key") headers.apiKey ]
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", String.fromInt params.petId ]
|
||||
[]
|
||||
, headers = List.filterMap identity [Maybe.map (Http.header "api_key" ) headers.apiKey]
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -91,6 +98,10 @@ deletePet headers params =
|
||||
-}
|
||||
findPetsByStatus :
|
||||
{ onSend : Result Http.Error (List Pet) -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
, status : List Status
|
||||
}
|
||||
-> Cmd msg
|
||||
@ -98,10 +109,9 @@ findPetsByStatus params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", "findByStatus" ]
|
||||
(List.filterMap identity [ Just (Url.string "status" <| (String.join "," << List.map statusToString) params.status) ])
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", "findByStatus"]
|
||||
(List.filterMap identity [Just (Url.string "status" <| (String.join "," << List.map statusToString) params.status)])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
||||
, timeout = Just 30000
|
||||
@ -113,6 +123,10 @@ findPetsByStatus params =
|
||||
-}
|
||||
findPetsByTags :
|
||||
{ onSend : Result Http.Error (List Pet) -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
, tags : List String
|
||||
}
|
||||
-> Cmd msg
|
||||
@ -120,10 +134,9 @@ findPetsByTags params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", "findByTags" ]
|
||||
(List.filterMap identity [ Just (Url.string "tags" <| String.join "," params.tags) ])
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", "findByTags"]
|
||||
(List.filterMap identity [Just (Url.string "tags" <| (String.join ",") params.tags)])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
||||
, timeout = Just 30000
|
||||
@ -135,17 +148,20 @@ findPetsByTags params =
|
||||
-}
|
||||
getPetById :
|
||||
{ onSend : Result Http.Error Pet -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getPetById params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", String.fromInt params.petId ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Pet.decoder
|
||||
, timeout = Just 30000
|
||||
@ -155,17 +171,20 @@ getPetById params =
|
||||
|
||||
updatePet :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : Pet
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
updatePet params =
|
||||
Http.request
|
||||
{ method = "PUT"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet" ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet"]
|
||||
[]
|
||||
, body = Http.jsonBody <| Pet.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -175,17 +194,20 @@ updatePet params =
|
||||
|
||||
updatePetWithForm :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
updatePetWithForm params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", String.fromInt params.petId ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -195,17 +217,20 @@ updatePetWithForm params =
|
||||
|
||||
uploadFile :
|
||||
{ onSend : Result Http.Error ApiResponse -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
uploadFile params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", String.fromInt params.petId, "uploadImage" ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId, "uploadImage"]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend ApiResponse.decoder
|
||||
, timeout = Just 30000
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -19,6 +19,8 @@ import Json.Decode as Decode
|
||||
import Url.Builder as Url
|
||||
|
||||
|
||||
|
||||
|
||||
basePath : String
|
||||
basePath =
|
||||
"http://petstore.swagger.io/v2"
|
||||
@ -28,17 +30,20 @@ basePath =
|
||||
-}
|
||||
deleteOrder :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, orderId : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
deleteOrder params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "store", "order", params.orderId ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order", params.orderId]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -50,16 +55,20 @@ deleteOrder params =
|
||||
-}
|
||||
getInventory :
|
||||
{ onSend : Result Http.Error (Dict.Dict String Int) -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getInventory params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "store", "inventory" ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "inventory"]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.dict Decode.int)
|
||||
, timeout = Just 30000
|
||||
@ -71,17 +80,20 @@ getInventory params =
|
||||
-}
|
||||
getOrderById :
|
||||
{ onSend : Result Http.Error Order_ -> msg
|
||||
|
||||
|
||||
|
||||
, orderId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getOrderById params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "store", "order", String.fromInt params.orderId ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order", String.fromInt params.orderId]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Order_.decoder
|
||||
, timeout = Just 30000
|
||||
@ -91,17 +103,20 @@ getOrderById params =
|
||||
|
||||
placeOrder :
|
||||
{ onSend : Result Http.Error Order_ -> msg
|
||||
|
||||
|
||||
, body : Order_
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
placeOrder params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "store", "order" ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order"]
|
||||
[]
|
||||
, body = Http.jsonBody <| Order_.encode params.body
|
||||
, expect = Http.expectJson params.onSend Order_.decoder
|
||||
, timeout = Just 30000
|
||||
|
@ -2,7 +2,7 @@
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
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
|
||||
@ -19,6 +19,8 @@ import Json.Decode as Decode
|
||||
import Url.Builder as Url
|
||||
|
||||
|
||||
|
||||
|
||||
basePath : String
|
||||
basePath =
|
||||
"http://petstore.swagger.io/v2"
|
||||
@ -28,17 +30,20 @@ basePath =
|
||||
-}
|
||||
createUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
createUser params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user" ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["user"]
|
||||
[]
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -48,17 +53,20 @@ createUser params =
|
||||
|
||||
createUsersWithArrayInput :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
createUsersWithArrayInput params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", "createWithArray" ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "createWithArray"]
|
||||
[]
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -68,17 +76,20 @@ createUsersWithArrayInput params =
|
||||
|
||||
createUsersWithListInput :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
createUsersWithListInput params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", "createWithList" ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "createWithList"]
|
||||
[]
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -90,17 +101,20 @@ createUsersWithListInput params =
|
||||
-}
|
||||
deleteUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, username : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
deleteUser params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", params.username ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", params.username]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -110,17 +124,20 @@ deleteUser params =
|
||||
|
||||
getUserByName :
|
||||
{ onSend : Result Http.Error User -> msg
|
||||
|
||||
|
||||
|
||||
, username : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getUserByName params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", params.username ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", params.username]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend User.decoder
|
||||
, timeout = Just 30000
|
||||
@ -130,18 +147,20 @@ getUserByName params =
|
||||
|
||||
loginUser :
|
||||
{ onSend : Result Http.Error String -> msg
|
||||
, username : String
|
||||
, password : String
|
||||
|
||||
|
||||
|
||||
|
||||
, username : String , password : String
|
||||
}
|
||||
-> Cmd msg
|
||||
loginUser params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", "login" ]
|
||||
(List.filterMap identity [ Just (Url.string "username" params.username), Just (Url.string "password" params.password) ])
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "login"]
|
||||
(List.filterMap identity [Just (Url.string "username" params.username), Just (Url.string "password" params.password)])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Decode.string
|
||||
, timeout = Just 30000
|
||||
@ -151,16 +170,20 @@ loginUser params =
|
||||
|
||||
logoutUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
logoutUser params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", "logout" ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "logout"]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -172,18 +195,20 @@ logoutUser params =
|
||||
-}
|
||||
updateUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
, username : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
updateUser params =
|
||||
Http.request
|
||||
{ method = "PUT"
|
||||
, headers = []
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", params.username ]
|
||||
[]
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", params.username]
|
||||
[]
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
|
1
samples/openapi3/client/petstore/elm/.gitignore
vendored
Normal file
1
samples/openapi3/client/petstore/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.0.3-SNAPSHOT
|
10
samples/openapi3/client/petstore/elm/README.md
Normal file
10
samples/openapi3/client/petstore/elm/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Elm API client
|
||||
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
## 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
|
33
samples/openapi3/client/petstore/elm/elm.json
Normal file
33
samples/openapi3/client/petstore/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": {}
|
||||
}
|
||||
}
|
18
samples/openapi3/client/petstore/elm/src/Byte.elm
Normal file
18
samples/openapi3/client/petstore/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
|
@ -0,0 +1,48 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.ApiResponse exposing (ApiResponse, decoder, encode)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
{-| Describes the result of uploading an image resource
|
||||
-}
|
||||
type alias ApiResponse =
|
||||
{ code : Maybe (Int)
|
||||
, type_ : Maybe (String)
|
||||
, message : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder ApiResponse
|
||||
decoder =
|
||||
Decode.succeed ApiResponse
|
||||
|> optional "code" (Decode.nullable Decode.int) Nothing
|
||||
|> optional "type" (Decode.nullable Decode.string) Nothing
|
||||
|> optional "message" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
45
samples/openapi3/client/petstore/elm/src/Data/Category.elm
Normal file
45
samples/openapi3/client/petstore/elm/src/Data/Category.elm
Normal file
@ -0,0 +1,45 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.Category exposing (Category, decoder, encode)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
{-| A category for a pet
|
||||
-}
|
||||
type alias Category =
|
||||
{ id : Maybe (Int)
|
||||
, name : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder Category
|
||||
decoder =
|
||||
Decode.succeed Category
|
||||
|> optional "id" (Decode.nullable Decode.int) Nothing
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.InlineObject exposing (InlineObject, decoder, encode)
|
||||
|
||||
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 InlineObject =
|
||||
{ name : Maybe (String)
|
||||
, status : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder InlineObject
|
||||
decoder =
|
||||
Decode.succeed InlineObject
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|> optional "status" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.InlineObject1 exposing (InlineObject1, decoder, encode)
|
||||
|
||||
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 InlineObject1 =
|
||||
{ additionalMetadata : Maybe (String)
|
||||
, file : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder InlineObject1
|
||||
decoder =
|
||||
Decode.succeed InlineObject1
|
||||
|> optional "additionalMetadata" (Decode.nullable Decode.string) Nothing
|
||||
|> optional "file" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
101
samples/openapi3/client/petstore/elm/src/Data/Order_.elm
Normal file
101
samples/openapi3/client/petstore/elm/src/Data/Order_.elm
Normal file
@ -0,0 +1,101 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.Order_ exposing (Order_, Status(..), decoder, encode)
|
||||
|
||||
import DateTime exposing (DateTime)
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
{-| An order for a pets from the pet store
|
||||
-}
|
||||
type alias Order_ =
|
||||
{ id : Maybe (Int)
|
||||
, petId : Maybe (Int)
|
||||
, quantity : Maybe (Int)
|
||||
, shipDate : Maybe (DateTime)
|
||||
, status : Maybe (Status)
|
||||
, complete : Maybe (Bool)
|
||||
}
|
||||
|
||||
|
||||
type Status
|
||||
= StatusPlaced
|
||||
| StatusApproved
|
||||
| StatusDelivered
|
||||
|
||||
|
||||
|
||||
decoder : Decoder Order_
|
||||
decoder =
|
||||
Decode.succeed Order_
|
||||
|> optional "id" (Decode.nullable Decode.int) Nothing
|
||||
|> optional "petId" (Decode.nullable Decode.int) Nothing
|
||||
|> optional "quantity" (Decode.nullable Decode.int) Nothing
|
||||
|> optional "shipDate" (Decode.nullable DateTime.decoder) Nothing
|
||||
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
||||
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
statusDecoder : Decoder Status
|
||||
statusDecoder =
|
||||
Decode.string
|
||||
|> Decode.andThen
|
||||
(\str ->
|
||||
case str of
|
||||
"placed" ->
|
||||
Decode.succeed StatusPlaced
|
||||
|
||||
"approved" ->
|
||||
Decode.succeed StatusApproved
|
||||
|
||||
"delivered" ->
|
||||
Decode.succeed StatusDelivered
|
||||
|
||||
other ->
|
||||
Decode.fail <| "Unknown type: " ++ other
|
||||
)
|
||||
|
||||
|
||||
|
||||
encodeStatus : Status -> Encode.Value
|
||||
encodeStatus model =
|
||||
case model of
|
||||
StatusPlaced ->
|
||||
Encode.string "placed"
|
||||
|
||||
StatusApproved ->
|
||||
Encode.string "approved"
|
||||
|
||||
StatusDelivered ->
|
||||
Encode.string "delivered"
|
||||
|
||||
|
||||
|
102
samples/openapi3/client/petstore/elm/src/Data/Pet.elm
Normal file
102
samples/openapi3/client/petstore/elm/src/Data/Pet.elm
Normal file
@ -0,0 +1,102 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.Pet exposing (Pet, Status(..), decoder, encode)
|
||||
|
||||
import Data.Category as Category exposing (Category)
|
||||
import Data.Tag as Tag exposing (Tag)
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
{-| A pet for sale in the pet store
|
||||
-}
|
||||
type alias Pet =
|
||||
{ id : Maybe (Int)
|
||||
, category : Maybe (Category)
|
||||
, name : String
|
||||
, photoUrls : (List String)
|
||||
, tags : Maybe ((List Tag))
|
||||
, status : Maybe (Status)
|
||||
}
|
||||
|
||||
|
||||
type Status
|
||||
= StatusAvailable
|
||||
| StatusPending
|
||||
| StatusSold
|
||||
|
||||
|
||||
|
||||
decoder : Decoder Pet
|
||||
decoder =
|
||||
Decode.succeed Pet
|
||||
|> optional "id" (Decode.nullable Decode.int) Nothing
|
||||
|> optional "category" (Decode.nullable Category.decoder) Nothing
|
||||
|> required "name" Decode.string
|
||||
|> required "photoUrls" (Decode.list Decode.string)
|
||||
|> optional "tags" (Decode.nullable (Decode.list Tag.decoder)) Nothing
|
||||
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
statusDecoder : Decoder Status
|
||||
statusDecoder =
|
||||
Decode.string
|
||||
|> Decode.andThen
|
||||
(\str ->
|
||||
case str of
|
||||
"available" ->
|
||||
Decode.succeed StatusAvailable
|
||||
|
||||
"pending" ->
|
||||
Decode.succeed StatusPending
|
||||
|
||||
"sold" ->
|
||||
Decode.succeed StatusSold
|
||||
|
||||
other ->
|
||||
Decode.fail <| "Unknown type: " ++ other
|
||||
)
|
||||
|
||||
|
||||
|
||||
encodeStatus : Status -> Encode.Value
|
||||
encodeStatus model =
|
||||
case model of
|
||||
StatusAvailable ->
|
||||
Encode.string "available"
|
||||
|
||||
StatusPending ->
|
||||
Encode.string "pending"
|
||||
|
||||
StatusSold ->
|
||||
Encode.string "sold"
|
||||
|
||||
|
||||
|
45
samples/openapi3/client/petstore/elm/src/Data/Tag.elm
Normal file
45
samples/openapi3/client/petstore/elm/src/Data/Tag.elm
Normal file
@ -0,0 +1,45 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.Tag exposing (Tag, decoder, encode)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
{-| A tag for a pet
|
||||
-}
|
||||
type alias Tag =
|
||||
{ id : Maybe (Int)
|
||||
, name : Maybe (String)
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder Tag
|
||||
decoder =
|
||||
Decode.succeed Tag
|
||||
|> optional "id" (Decode.nullable Decode.int) Nothing
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
63
samples/openapi3/client/petstore/elm/src/Data/User.elm
Normal file
63
samples/openapi3/client/petstore/elm/src/Data/User.elm
Normal file
@ -0,0 +1,63 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.User exposing (User, decoder, encode)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (optional, required)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
{-| A User who is purchasing from the pet store
|
||||
-}
|
||||
type alias User =
|
||||
{ id : Maybe (Int)
|
||||
, username : Maybe (String)
|
||||
, firstName : Maybe (String)
|
||||
, lastName : Maybe (String)
|
||||
, email : Maybe (String)
|
||||
, password : Maybe (String)
|
||||
, phone : Maybe (String)
|
||||
, userStatus : Maybe (Int)
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder User
|
||||
decoder =
|
||||
Decode.succeed User
|
||||
|> optional "id" (Decode.nullable Decode.int) Nothing
|
||||
|> optional "username" (Decode.nullable Decode.string) Nothing
|
||||
|> optional "firstName" (Decode.nullable Decode.string) Nothing
|
||||
|> optional "lastName" (Decode.nullable Decode.string) Nothing
|
||||
|> optional "email" (Decode.nullable Decode.string) Nothing
|
||||
|> optional "password" (Decode.nullable Decode.string) Nothing
|
||||
|> optional "phone" (Decode.nullable Decode.string) Nothing
|
||||
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
||||
|
||||
|
||||
|
||||
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) )
|
||||
|
||||
]
|
||||
|
||||
|
37
samples/openapi3/client/petstore/elm/src/DateOnly.elm
Normal file
37
samples/openapi3/client/petstore/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/petstore/elm/src/DateTime.elm
Normal file
37
samples/openapi3/client/petstore/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/petstore/elm/src/Main.elm
Normal file
61
samples/openapi3/client/petstore/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"
|
238
samples/openapi3/client/petstore/elm/src/Request/Pet.elm
Normal file
238
samples/openapi3/client/petstore/elm/src/Request/Pet.elm
Normal file
@ -0,0 +1,238 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.Pet exposing (addPet, deletePet, findPetsByStatus, Status(..), findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
||||
|
||||
import Data.Pet as Pet exposing (Pet)
|
||||
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||
import Dict
|
||||
import Http
|
||||
import Json.Decode as Decode
|
||||
import Url.Builder as Url
|
||||
|
||||
|
||||
type Status
|
||||
= StatusAvailable
|
||||
| StatusPending
|
||||
| StatusSold
|
||||
|
||||
statusToString : Status -> String
|
||||
statusToString value =
|
||||
case value of
|
||||
StatusAvailable ->
|
||||
"available"
|
||||
|
||||
StatusPending ->
|
||||
"pending"
|
||||
|
||||
StatusSold ->
|
||||
"sold"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
basePath : String
|
||||
basePath =
|
||||
"http://petstore.swagger.io/v2"
|
||||
|
||||
|
||||
addPet :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : Pet
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
addPet params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet"]
|
||||
[]
|
||||
, body = Http.jsonBody <| Pet.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
deletePet :
|
||||
{ apiKey : Maybe (String)
|
||||
} ->
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
deletePet headers params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = List.filterMap identity [Maybe.map (Http.header "api_key" ) headers.apiKey]
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
{-| Multiple status values can be provided with comma separated strings
|
||||
-}
|
||||
findPetsByStatus :
|
||||
{ onSend : Result Http.Error (List Pet) -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
, status : List Status
|
||||
}
|
||||
-> Cmd msg
|
||||
findPetsByStatus params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", "findByStatus"]
|
||||
(List.filterMap identity [Just (Url.string "status" <| (String.join "," << List.map statusToString) params.status)])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
{-| Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
-}
|
||||
findPetsByTags :
|
||||
{ onSend : Result Http.Error (List Pet) -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
, tags : List String , maxCount : Maybe (Int)
|
||||
}
|
||||
-> Cmd msg
|
||||
findPetsByTags params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, 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])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
{-| Returns a single pet
|
||||
-}
|
||||
getPetById :
|
||||
{ onSend : Result Http.Error Pet -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getPetById params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Pet.decoder
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
updatePet :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : Pet
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
updatePet params =
|
||||
Http.request
|
||||
{ method = "PUT"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet"]
|
||||
[]
|
||||
, body = Http.jsonBody <| Pet.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
updatePetWithForm :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
updatePetWithForm params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
uploadFile :
|
||||
{ onSend : Result Http.Error ApiResponse -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
uploadFile params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId, "uploadImage"]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend ApiResponse.decoder
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
124
samples/openapi3/client/petstore/elm/src/Request/Store.elm
Normal file
124
samples/openapi3/client/petstore/elm/src/Request/Store.elm
Normal file
@ -0,0 +1,124 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.Store exposing (deleteOrder, getInventory, getOrderById, placeOrder)
|
||||
|
||||
import Data.Order_ as Order_ exposing (Order_)
|
||||
import Dict
|
||||
import Http
|
||||
import Json.Decode as Decode
|
||||
import Url.Builder as Url
|
||||
|
||||
|
||||
|
||||
|
||||
basePath : String
|
||||
basePath =
|
||||
"http://petstore.swagger.io/v2"
|
||||
|
||||
|
||||
{-| For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
-}
|
||||
deleteOrder :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, orderId : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
deleteOrder params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order", params.orderId]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
{-| Returns a map of status codes to quantities
|
||||
-}
|
||||
getInventory :
|
||||
{ onSend : Result Http.Error (Dict.Dict String Int) -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getInventory params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "inventory"]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.dict Decode.int)
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
{-| For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
-}
|
||||
getOrderById :
|
||||
{ onSend : Result Http.Error Order_ -> msg
|
||||
|
||||
|
||||
|
||||
, orderId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getOrderById params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order", String.fromInt params.orderId]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Order_.decoder
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
placeOrder :
|
||||
{ onSend : Result Http.Error Order_ -> msg
|
||||
|
||||
|
||||
, body : Order_
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
placeOrder params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order"]
|
||||
[]
|
||||
, body = Http.jsonBody <| Order_.encode params.body
|
||||
, expect = Http.expectJson params.onSend Order_.decoder
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
216
samples/openapi3/client/petstore/elm/src/Request/User.elm
Normal file
216
samples/openapi3/client/petstore/elm/src/Request/User.elm
Normal file
@ -0,0 +1,216 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.User exposing (createUser, createUsersWithArrayInput, createUsersWithListInput, deleteUser, getUserByName, loginUser, logoutUser, updateUser)
|
||||
|
||||
import Data.User as User exposing (User)
|
||||
import Dict
|
||||
import Http
|
||||
import Json.Decode as Decode
|
||||
import Url.Builder as Url
|
||||
|
||||
|
||||
|
||||
|
||||
basePath : String
|
||||
basePath =
|
||||
"http://petstore.swagger.io/v2"
|
||||
|
||||
|
||||
{-| This can only be done by the logged in user.
|
||||
-}
|
||||
createUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
createUser params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user"]
|
||||
[]
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
createUsersWithArrayInput :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
createUsersWithArrayInput params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "createWithArray"]
|
||||
[]
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
createUsersWithListInput :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
createUsersWithListInput params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "createWithList"]
|
||||
[]
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
{-| This can only be done by the logged in user.
|
||||
-}
|
||||
deleteUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, username : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
deleteUser params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", params.username]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
getUserByName :
|
||||
{ onSend : Result Http.Error User -> msg
|
||||
|
||||
|
||||
|
||||
, username : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getUserByName params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", params.username]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend User.decoder
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
loginUser :
|
||||
{ onSend : Result Http.Error String -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
, username : String , password : String
|
||||
}
|
||||
-> Cmd msg
|
||||
loginUser params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "login"]
|
||||
(List.filterMap identity [Just (Url.string "username" params.username), Just (Url.string "password" params.password)])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Decode.string
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
logoutUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
logoutUser params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "logout"]
|
||||
[]
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
|
||||
{-| This can only be done by the logged in user.
|
||||
-}
|
||||
updateUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
, username : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
updateUser params =
|
||||
Http.request
|
||||
{ method = "PUT"
|
||||
, headers = []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", params.username]
|
||||
[]
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
, tracker = Nothing
|
||||
}
|
@ -1 +1 @@
|
||||
4.0.0-SNAPSHOT
|
||||
4.0.3-SNAPSHOT
|
Loading…
Reference in New Issue
Block a user