diff --git a/.gitignore b/.gitignore index e72b71f24d1f..68d730962307 100644 --- a/.gitignore +++ b/.gitignore @@ -215,7 +215,9 @@ cabal.project.local samples/client/petstore/haskell-http-client/docs/haddock-bundle.min.js samples/client/petstore/haskell-http-client/docs/meta.json samples/client/petstore/haskell-http-client/docs/quick-jump.css +samples/client/petstore/haskell-http-client/stack.yaml.lock samples/server/petstore/haskell-servant/stack.yaml.lock +samples/server/petstore/haskell-yesod/stack.yaml.lock # R .Rproj.user diff --git a/README.md b/README.md index a781fd756886..070ceef5a98a 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se | | Languages/Frameworks | | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.0, .NET Core 2.0, .NET 5.0. Libraries: RestSharp, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient, Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client), **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 11.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) | -| **Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/)), **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) | +| **Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/)), **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) | | **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** | | **Configuration files** | [**Apache2**](https://httpd.apache.org/) | | **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Protocol Buffer**, **WSDL** | @@ -940,6 +940,7 @@ Here is a list of template creators: * Go (Gin) Server: @kemokemo * GraphQL Express Server: @renepardon * Haskell Servant: @algas + * Haskell Yesod: @yotsuya * Java MSF4J: @sanjeewa-malalgoda * Java Spring Boot: @diyfr * Java Undertow: @stevehu diff --git a/docs/generators.md b/docs/generators.md index 448f6bc4013b..b008000a275b 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -94,7 +94,7 @@ The following generators are available: * [go-server](generators/go-server.md) * [graphql-nodejs-express-server](generators/graphql-nodejs-express-server.md) * [haskell](generators/haskell.md) -* [haskell-yesod](generators/haskell-yesod.md) +* [haskell-yesod (beta)](generators/haskell-yesod.md) * [java-inflector](generators/java-inflector.md) * [java-msf4j](generators/java-msf4j.md) * [java-pkmst](generators/java-pkmst.md) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellYesodServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellYesodServerCodegen.java index e09edd61bcdf..3c67e4230441 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellYesodServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellYesodServerCodegen.java @@ -1,31 +1,44 @@ +/* + * Copyright 2018 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 + * + * https://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.languages; -import org.openapitools.codegen.*; -import org.openapitools.codegen.meta.features.*; -import org.openapitools.codegen.utils.ModelUtils; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.MapProperty; -import io.swagger.models.properties.Property; -import io.swagger.models.parameters.Parameter; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.servers.Server; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.StringUtils; +import org.openapitools.codegen.*; +import org.openapitools.codegen.meta.GeneratorMetadata; +import org.openapitools.codegen.meta.Stability; +import org.openapitools.codegen.meta.features.*; +import org.openapitools.codegen.utils.ModelUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.util.*; import java.util.regex.Pattern; -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.lang3.StringUtils; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.openapitools.codegen.utils.StringUtils.*; +import static org.openapitools.codegen.utils.StringUtils.camelize; +import static org.openapitools.codegen.utils.StringUtils.dashize; public class HaskellYesodServerCodegen extends DefaultCodegen implements CodegenConfig { public static final String PROJECT_NAME = "projectName"; @@ -85,6 +98,10 @@ public HaskellYesodServerCodegen() { ) ); + generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata) + .stability(Stability.BETA) + .build(); + // override the mapping to keep the original mapping in Haskell specialCharReplacements.put("-", "Dash"); specialCharReplacements.put(">", "GreaterThan"); @@ -161,9 +178,9 @@ public HaskellYesodServerCodegen() { importMapping.clear(); cliOptions.add(new CliOption(PROJECT_NAME, - "name of the project (Default: generated from info.title or \"openapi-haskell-yesod-server\")")); + "name of the project (Default: generated from info.title or \"openapi-haskell-yesod-server\")")); cliOptions.add(new CliOption(API_MODULE_NAME, - "name of the API module (Default: generated from info.title or \"API\")")); + "name of the API module (Default: generated from info.title or \"API\")")); } @Override @@ -393,7 +410,7 @@ public CodegenOperation fromOperation(String resourcePath, String httpMethod, Op String path = pathToYesodPath(op.path, op.pathParams); String resource = pathToYesodResource(op.path, op.pathParams); - List > routes = (List >) additionalProperties.get("routes"); + List> routes = (List>) additionalProperties.get("routes"); if (routes == null) { routes = new ArrayList>(); additionalProperties.put("routes", routes); @@ -440,7 +457,7 @@ public CodegenOperation fromOperation(String resourcePath, String httpMethod, Op return op; } - public Boolean hasOverlappedPath(String path, List > routes) { + public Boolean hasOverlappedPath(String path, List> routes) { for (Map route : routes) { String processedPath = (String) route.get("path"); if (processedPath.startsWith("!")) { diff --git a/samples/server/petstore/haskell-yesod/pom.xml b/samples/server/petstore/haskell-yesod/pom.xml new file mode 100644 index 000000000000..c442e5c87cd8 --- /dev/null +++ b/samples/server/petstore/haskell-yesod/pom.xml @@ -0,0 +1,63 @@ + + 4.0.0 + org.openapitools + openapi-petstore-haskell-yesod + pom + 1.0-SNAPSHOT + OpenAPI Petstore - Haskell yesod server + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + stack-haddock + pre-integration-test + + exec + + + stack + + --install-ghc + --no-haddock-deps + haddock + --fast + + + + + stack-test + integration-test + + exec + + + stack + + test + --fast + + + + + + + +