forked from loafle/openapi-generator-original
		
	[haskell-yesod] Better code format, mark generator as beta (#10222)
* better code format, mark haskell-yesod as beta * fix copyright * update doc
This commit is contained in:
		
							parent
							
								
									3de5483aa0
								
							
						
					
					
						commit
						90fca17de1
					
				
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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)  
 | 
			
		||||
 | 
			
		||||
@ -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 class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
 | 
			
		||||
                )
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        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 class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
 | 
			
		||||
        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 class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
 | 
			
		||||
        String path = pathToYesodPath(op.path, op.pathParams);
 | 
			
		||||
        String resource = pathToYesodResource(op.path, op.pathParams);
 | 
			
		||||
 | 
			
		||||
        List <Map<String, Object>> routes = (List <Map<String, Object>>) additionalProperties.get("routes");
 | 
			
		||||
        List<Map<String, Object>> routes = (List<Map<String, Object>>) additionalProperties.get("routes");
 | 
			
		||||
        if (routes == null) {
 | 
			
		||||
            routes = new ArrayList<Map<String, Object>>();
 | 
			
		||||
            additionalProperties.put("routes", routes);
 | 
			
		||||
@ -440,7 +457,7 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
 | 
			
		||||
        return op;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Boolean hasOverlappedPath(String path, List <Map<String, Object>> routes) {
 | 
			
		||||
    public Boolean hasOverlappedPath(String path, List<Map<String, Object>> routes) {
 | 
			
		||||
        for (Map<String, Object> route : routes) {
 | 
			
		||||
            String processedPath = (String) route.get("path");
 | 
			
		||||
            if (processedPath.startsWith("!")) {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										63
									
								
								samples/server/petstore/haskell-yesod/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								samples/server/petstore/haskell-yesod/pom.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,63 @@
 | 
			
		||||
<project>
 | 
			
		||||
  <modelVersion>4.0.0</modelVersion>
 | 
			
		||||
  <groupId>org.openapitools</groupId>
 | 
			
		||||
  <artifactId>openapi-petstore-haskell-yesod</artifactId>
 | 
			
		||||
  <packaging>pom</packaging>
 | 
			
		||||
  <version>1.0-SNAPSHOT</version>
 | 
			
		||||
  <name>OpenAPI Petstore - Haskell yesod server</name>
 | 
			
		||||
  <build>
 | 
			
		||||
    <plugins>
 | 
			
		||||
      <plugin>
 | 
			
		||||
        <artifactId>maven-dependency-plugin</artifactId>
 | 
			
		||||
        <executions>
 | 
			
		||||
          <execution>
 | 
			
		||||
            <phase>package</phase>
 | 
			
		||||
            <goals>
 | 
			
		||||
              <goal>copy-dependencies</goal>
 | 
			
		||||
            </goals>
 | 
			
		||||
            <configuration>
 | 
			
		||||
              <outputDirectory>${project.build.directory}</outputDirectory>
 | 
			
		||||
            </configuration>
 | 
			
		||||
          </execution>
 | 
			
		||||
        </executions>
 | 
			
		||||
      </plugin>
 | 
			
		||||
      <plugin>
 | 
			
		||||
        <groupId>org.codehaus.mojo</groupId>
 | 
			
		||||
        <artifactId>exec-maven-plugin</artifactId>
 | 
			
		||||
        <version>1.2.1</version>
 | 
			
		||||
        <executions>
 | 
			
		||||
          <execution>
 | 
			
		||||
            <id>stack-haddock</id>
 | 
			
		||||
            <phase>pre-integration-test</phase>
 | 
			
		||||
            <goals>
 | 
			
		||||
              <goal>exec</goal>
 | 
			
		||||
            </goals>
 | 
			
		||||
            <configuration>
 | 
			
		||||
              <executable>stack</executable>
 | 
			
		||||
              <arguments>
 | 
			
		||||
                <argument>--install-ghc</argument>
 | 
			
		||||
                <argument>--no-haddock-deps</argument>
 | 
			
		||||
                <argument>haddock</argument>
 | 
			
		||||
                <argument>--fast</argument>
 | 
			
		||||
              </arguments>
 | 
			
		||||
            </configuration>
 | 
			
		||||
          </execution>
 | 
			
		||||
          <execution>
 | 
			
		||||
            <id>stack-test</id>
 | 
			
		||||
            <phase>integration-test</phase>
 | 
			
		||||
            <goals>
 | 
			
		||||
              <goal>exec</goal>
 | 
			
		||||
            </goals>
 | 
			
		||||
            <configuration>
 | 
			
		||||
              <executable>stack</executable>
 | 
			
		||||
              <arguments>
 | 
			
		||||
                <argument>test</argument>
 | 
			
		||||
                <argument>--fast</argument>
 | 
			
		||||
              </arguments>
 | 
			
		||||
            </configuration>
 | 
			
		||||
          </execution>
 | 
			
		||||
        </executions>
 | 
			
		||||
      </plugin>
 | 
			
		||||
    </plugins>
 | 
			
		||||
  </build>
 | 
			
		||||
</project>
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user