diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java index cc5246dc21..4a3a68d2a8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java @@ -446,7 +446,9 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig { op.path = ("\"" + path + "\"").replaceAll(" \\+\\+ \"\"", ""); } else { final List 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); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java index dd8ca1b529..a46452c65c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java @@ -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("/")) { diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/elm/ElmClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/elm/ElmClientCodegenTest.java new file mode 100644 index 0000000000..005711ca08 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/elm/ElmClientCodegenTest.java @@ -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 ops = newArrayList(rootOp); + + Map operations = new HashMap<>(); + operations.put("operations", ImmutableMap + .builder() + .put("operation", ops) + .build()); + + // when + Map 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 + "\""); + } + } +} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/haskellservant/HaskellServantCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/haskellservant/HaskellServantCodegenTest.java new file mode 100644 index 0000000000..8673f7f958 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/haskellservant/HaskellServantCodegenTest.java @@ -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 + "\""); + } + } +} diff --git a/modules/openapi-generator/src/test/resources/3_0/rootOperation.yaml b/modules/openapi-generator/src/test/resources/3_0/rootOperation.yaml new file mode 100644 index 0000000000..15004510a4 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/rootOperation.yaml @@ -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 diff --git a/samples/client/petstore/elm-0.18/.openapi-generator/VERSION b/samples/client/petstore/elm-0.18/.openapi-generator/VERSION index afa6365606..479c313e87 100644 --- a/samples/client/petstore/elm-0.18/.openapi-generator/VERSION +++ b/samples/client/petstore/elm-0.18/.openapi-generator/VERSION @@ -1 +1 @@ -4.0.0-SNAPSHOT \ No newline at end of file +4.0.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/elm-0.18/src/Data/ApiResponse.elm b/samples/client/petstore/elm-0.18/src/Data/ApiResponse.elm index f4120a0924..bb1003f9a0 100644 --- a/samples/client/petstore/elm-0.18/src/Data/ApiResponse.elm +++ b/samples/client/petstore/elm-0.18/src/Data/ApiResponse.elm @@ -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) ) + ] + + diff --git a/samples/client/petstore/elm-0.18/src/Data/Category.elm b/samples/client/petstore/elm-0.18/src/Data/Category.elm index a97f62791d..127436ffc0 100644 --- a/samples/client/petstore/elm-0.18/src/Data/Category.elm +++ b/samples/client/petstore/elm-0.18/src/Data/Category.elm @@ -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) ) + ] + + diff --git a/samples/client/petstore/elm-0.18/src/Data/Order_.elm b/samples/client/petstore/elm-0.18/src/Data/Order_.elm index 03de721dec..e4b1474154 100644 --- a/samples/client/petstore/elm-0.18/src/Data/Order_.elm +++ b/samples/client/petstore/elm-0.18/src/Data/Order_.elm @@ -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" + + + diff --git a/samples/client/petstore/elm-0.18/src/Data/Pet.elm b/samples/client/petstore/elm-0.18/src/Data/Pet.elm index a777915436..7ab7b76a4f 100644 --- a/samples/client/petstore/elm-0.18/src/Data/Pet.elm +++ b/samples/client/petstore/elm-0.18/src/Data/Pet.elm @@ -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" + + + diff --git a/samples/client/petstore/elm-0.18/src/Data/Tag.elm b/samples/client/petstore/elm-0.18/src/Data/Tag.elm index 372029cde7..d1344af5de 100644 --- a/samples/client/petstore/elm-0.18/src/Data/Tag.elm +++ b/samples/client/petstore/elm-0.18/src/Data/Tag.elm @@ -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) ) + ] + + diff --git a/samples/client/petstore/elm-0.18/src/Data/User.elm b/samples/client/petstore/elm-0.18/src/Data/User.elm index 667c93f4d8..4b1870d9ca 100644 --- a/samples/client/petstore/elm-0.18/src/Data/User.elm +++ b/samples/client/petstore/elm-0.18/src/Data/User.elm @@ -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) ) + ] + + diff --git a/samples/client/petstore/elm-0.18/src/DateTime.elm b/samples/client/petstore/elm-0.18/src/DateTime.elm index 7e07312468..6a20f0482a 100644 --- a/samples/client/petstore/elm-0.18/src/DateTime.elm +++ b/samples/client/petstore/elm-0.18/src/DateTime.elm @@ -34,4 +34,4 @@ decodeIsoString str = toString : DateTime -> String toString = - toIsoString + toIsoString \ No newline at end of file diff --git a/samples/client/petstore/elm-0.18/src/Request/Pet.elm b/samples/client/petstore/elm-0.18/src/Request/Pet.elm index 472eb73a15..5b1e3444d3 100644 --- a/samples/client/petstore/elm-0.18/src/Request/Pet.elm +++ b/samples/client/petstore/elm-0.18/src/Request/Pet.elm @@ -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 diff --git a/samples/client/petstore/elm-0.18/src/Request/Store.elm b/samples/client/petstore/elm-0.18/src/Request/Store.elm index c2872e305c..d8f70f4177 100644 --- a/samples/client/petstore/elm-0.18/src/Request/Store.elm +++ b/samples/client/petstore/elm-0.18/src/Request/Store.elm @@ -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 diff --git a/samples/client/petstore/elm-0.18/src/Request/User.elm b/samples/client/petstore/elm-0.18/src/Request/User.elm index c6e4048a05..ce6b79ca63 100644 --- a/samples/client/petstore/elm-0.18/src/Request/User.elm +++ b/samples/client/petstore/elm-0.18/src/Request/User.elm @@ -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 ()) diff --git a/samples/client/petstore/elm/.openapi-generator/VERSION b/samples/client/petstore/elm/.openapi-generator/VERSION index afa6365606..479c313e87 100644 --- a/samples/client/petstore/elm/.openapi-generator/VERSION +++ b/samples/client/petstore/elm/.openapi-generator/VERSION @@ -1 +1 @@ -4.0.0-SNAPSHOT \ No newline at end of file +4.0.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/elm/src/Data/ApiResponse.elm b/samples/client/petstore/elm/src/Data/ApiResponse.elm index 9bdc2ac4da..3559c4f3fe 100644 --- a/samples/client/petstore/elm/src/Data/ApiResponse.elm +++ b/samples/client/petstore/elm/src/Data/ApiResponse.elm @@ -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) ) + ] + + diff --git a/samples/client/petstore/elm/src/Data/Category.elm b/samples/client/petstore/elm/src/Data/Category.elm index 091166fb62..9a5803626d 100644 --- a/samples/client/petstore/elm/src/Data/Category.elm +++ b/samples/client/petstore/elm/src/Data/Category.elm @@ -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) ) + ] + + diff --git a/samples/client/petstore/elm/src/Data/Order_.elm b/samples/client/petstore/elm/src/Data/Order_.elm index 0deb606623..cd304947c5 100644 --- a/samples/client/petstore/elm/src/Data/Order_.elm +++ b/samples/client/petstore/elm/src/Data/Order_.elm @@ -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" + + + diff --git a/samples/client/petstore/elm/src/Data/Pet.elm b/samples/client/petstore/elm/src/Data/Pet.elm index f7ccb9ab1c..e2518c95b0 100644 --- a/samples/client/petstore/elm/src/Data/Pet.elm +++ b/samples/client/petstore/elm/src/Data/Pet.elm @@ -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" + + + diff --git a/samples/client/petstore/elm/src/Data/Tag.elm b/samples/client/petstore/elm/src/Data/Tag.elm index d81dc66126..16118b9b80 100644 --- a/samples/client/petstore/elm/src/Data/Tag.elm +++ b/samples/client/petstore/elm/src/Data/Tag.elm @@ -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) ) + ] + + diff --git a/samples/client/petstore/elm/src/Data/User.elm b/samples/client/petstore/elm/src/Data/User.elm index 8db61e71fd..0b0cba12cc 100644 --- a/samples/client/petstore/elm/src/Data/User.elm +++ b/samples/client/petstore/elm/src/Data/User.elm @@ -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) ) + ] + + diff --git a/samples/client/petstore/elm/src/DateTime.elm b/samples/client/petstore/elm/src/DateTime.elm index 80b62fb7de..7d4a5c642c 100644 --- a/samples/client/petstore/elm/src/DateTime.elm +++ b/samples/client/petstore/elm/src/DateTime.elm @@ -34,4 +34,4 @@ decodeIsoString str = toString : DateTime -> String toString = - Iso8601.fromTime + Iso8601.fromTime \ No newline at end of file diff --git a/samples/client/petstore/elm/src/Request/Pet.elm b/samples/client/petstore/elm/src/Request/Pet.elm index 1743382c61..cd46555148 100644 --- a/samples/client/petstore/elm/src/Request/Pet.elm +++ b/samples/client/petstore/elm/src/Request/Pet.elm @@ -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 diff --git a/samples/client/petstore/elm/src/Request/Store.elm b/samples/client/petstore/elm/src/Request/Store.elm index e251c07557..7ac926fe41 100644 --- a/samples/client/petstore/elm/src/Request/Store.elm +++ b/samples/client/petstore/elm/src/Request/Store.elm @@ -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 diff --git a/samples/client/petstore/elm/src/Request/User.elm b/samples/client/petstore/elm/src/Request/User.elm index 75fa422bcb..6d6d21918a 100644 --- a/samples/client/petstore/elm/src/Request/User.elm +++ b/samples/client/petstore/elm/src/Request/User.elm @@ -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 diff --git a/samples/openapi3/client/petstore/elm/.gitignore b/samples/openapi3/client/petstore/elm/.gitignore new file mode 100644 index 0000000000..8b0d053e4e --- /dev/null +++ b/samples/openapi3/client/petstore/elm/.gitignore @@ -0,0 +1 @@ +/elm-stuff \ No newline at end of file diff --git a/samples/openapi3/client/petstore/elm/.openapi-generator-ignore b/samples/openapi3/client/petstore/elm/.openapi-generator-ignore new file mode 100644 index 0000000000..7484ee590a --- /dev/null +++ b/samples/openapi3/client/petstore/elm/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/client/petstore/elm/.openapi-generator/VERSION b/samples/openapi3/client/petstore/elm/.openapi-generator/VERSION new file mode 100644 index 0000000000..479c313e87 --- /dev/null +++ b/samples/openapi3/client/petstore/elm/.openapi-generator/VERSION @@ -0,0 +1 @@ +4.0.3-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/elm/README.md b/samples/openapi3/client/petstore/elm/README.md new file mode 100644 index 0000000000..3f36740911 --- /dev/null +++ b/samples/openapi3/client/petstore/elm/README.md @@ -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 diff --git a/samples/openapi3/client/petstore/elm/elm.json b/samples/openapi3/client/petstore/elm/elm.json new file mode 100644 index 0000000000..398da0d2d6 --- /dev/null +++ b/samples/openapi3/client/petstore/elm/elm.json @@ -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": {} + } +} diff --git a/samples/openapi3/client/petstore/elm/src/Byte.elm b/samples/openapi3/client/petstore/elm/src/Byte.elm new file mode 100644 index 0000000000..d83623d984 --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Byte.elm @@ -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 diff --git a/samples/openapi3/client/petstore/elm/src/Data/ApiResponse.elm b/samples/openapi3/client/petstore/elm/src/Data/ApiResponse.elm new file mode 100644 index 0000000000..3559c4f3fe --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Data/ApiResponse.elm @@ -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) ) + + ] + + diff --git a/samples/openapi3/client/petstore/elm/src/Data/Category.elm b/samples/openapi3/client/petstore/elm/src/Data/Category.elm new file mode 100644 index 0000000000..9a5803626d --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Data/Category.elm @@ -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) ) + + ] + + diff --git a/samples/openapi3/client/petstore/elm/src/Data/InlineObject.elm b/samples/openapi3/client/petstore/elm/src/Data/InlineObject.elm new file mode 100644 index 0000000000..0fda842c6c --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Data/InlineObject.elm @@ -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) ) + + ] + + diff --git a/samples/openapi3/client/petstore/elm/src/Data/InlineObject1.elm b/samples/openapi3/client/petstore/elm/src/Data/InlineObject1.elm new file mode 100644 index 0000000000..8ec67406c3 --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Data/InlineObject1.elm @@ -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) ) + + ] + + diff --git a/samples/openapi3/client/petstore/elm/src/Data/Order_.elm b/samples/openapi3/client/petstore/elm/src/Data/Order_.elm new file mode 100644 index 0000000000..f1a620a19f --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Data/Order_.elm @@ -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" + + + diff --git a/samples/openapi3/client/petstore/elm/src/Data/Pet.elm b/samples/openapi3/client/petstore/elm/src/Data/Pet.elm new file mode 100644 index 0000000000..4eaf5a4793 --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Data/Pet.elm @@ -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" + + + diff --git a/samples/openapi3/client/petstore/elm/src/Data/Tag.elm b/samples/openapi3/client/petstore/elm/src/Data/Tag.elm new file mode 100644 index 0000000000..16118b9b80 --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Data/Tag.elm @@ -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) ) + + ] + + diff --git a/samples/openapi3/client/petstore/elm/src/Data/User.elm b/samples/openapi3/client/petstore/elm/src/Data/User.elm new file mode 100644 index 0000000000..0b0cba12cc --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Data/User.elm @@ -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) ) + + ] + + diff --git a/samples/openapi3/client/petstore/elm/src/DateOnly.elm b/samples/openapi3/client/petstore/elm/src/DateOnly.elm new file mode 100644 index 0000000000..a31efc88c3 --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/DateOnly.elm @@ -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 diff --git a/samples/openapi3/client/petstore/elm/src/DateTime.elm b/samples/openapi3/client/petstore/elm/src/DateTime.elm new file mode 100644 index 0000000000..7d4a5c642c --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/DateTime.elm @@ -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 \ No newline at end of file diff --git a/samples/openapi3/client/petstore/elm/src/Main.elm b/samples/openapi3/client/petstore/elm/src/Main.elm new file mode 100644 index 0000000000..7c9ddd056d --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Main.elm @@ -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" diff --git a/samples/openapi3/client/petstore/elm/src/Request/Pet.elm b/samples/openapi3/client/petstore/elm/src/Request/Pet.elm new file mode 100644 index 0000000000..af5b1654ec --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Request/Pet.elm @@ -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 + } diff --git a/samples/openapi3/client/petstore/elm/src/Request/Store.elm b/samples/openapi3/client/petstore/elm/src/Request/Store.elm new file mode 100644 index 0000000000..7ac926fe41 --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Request/Store.elm @@ -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 + } diff --git a/samples/openapi3/client/petstore/elm/src/Request/User.elm b/samples/openapi3/client/petstore/elm/src/Request/User.elm new file mode 100644 index 0000000000..6d6d21918a --- /dev/null +++ b/samples/openapi3/client/petstore/elm/src/Request/User.elm @@ -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 + } diff --git a/samples/server/petstore/haskell-servant/.openapi-generator/VERSION b/samples/server/petstore/haskell-servant/.openapi-generator/VERSION index afa6365606..479c313e87 100644 --- a/samples/server/petstore/haskell-servant/.openapi-generator/VERSION +++ b/samples/server/petstore/haskell-servant/.openapi-generator/VERSION @@ -1 +1 @@ -4.0.0-SNAPSHOT \ No newline at end of file +4.0.3-SNAPSHOT \ No newline at end of file