From 95e04f91dbd515ff6c922c83efa49c12db88f702 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 2 May 2018 23:04:16 +0800 Subject: [PATCH] Add Elm script with Petstore OAS3 (#293) * add elm script with petstore oas3 * change default value for elm generator * update default value for elm templates * fix typo --- bin/openapi3/elm-petstore.sh | 32 +++++++++++++++++++ .../codegen/languages/ElmClientCodegen.java | 2 +- .../src/main/resources/elm/README.mustache | 4 +-- .../main/resources/elm/licenseInfo.mustache | 4 +-- samples/client/petstore/elm/README.md | 2 +- .../petstore/elm/src/Data/ApiResponse.elm | 4 +-- .../client/petstore/elm/src/Data/Category.elm | 4 +-- .../client/petstore/elm/src/Data/Order.elm | 4 +-- samples/client/petstore/elm/src/Data/Pet.elm | 4 +-- samples/client/petstore/elm/src/Data/Tag.elm | 4 +-- samples/client/petstore/elm/src/Data/User.elm | 4 +-- .../client/petstore/elm/src/Request/Pet.elm | 4 +-- .../client/petstore/elm/src/Request/Store.elm | 4 +-- .../client/petstore/elm/src/Request/User.elm | 4 +-- 14 files changed, 56 insertions(+), 24 deletions(-) create mode 100755 bin/openapi3/elm-petstore.sh diff --git a/bin/openapi3/elm-petstore.sh b/bin/openapi3/elm-petstore.sh new file mode 100755 index 00000000000..6817455b9f8 --- /dev/null +++ b/bin/openapi3/elm-petstore.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l elm -o samples/client/petstore/elm $@" + +java $JAVA_OPTS -jar $executable $ags 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 e7bb13b30a5..09942d6fb88 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 @@ -48,7 +48,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig { private Set customPrimitives = new HashSet(); - protected String packageName = "swagger"; + protected String packageName = "openapi"; protected String packageVersion = "1.0.0"; public CodegenType getTag() { diff --git a/modules/openapi-generator/src/main/resources/elm/README.mustache b/modules/openapi-generator/src/main/resources/elm/README.mustache index ebd05fd1207..2de630289d4 100644 --- a/modules/openapi-generator/src/main/resources/elm/README.mustache +++ b/modules/openapi-generator/src/main/resources/elm/README.mustache @@ -2,10 +2,10 @@ {{#appDescription}} {{{appDescription}}} -{{/appDescription}} +{{/appDescription}} ## Overview -This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client. +This API client was generated by the [openapi-generator](https://github.com/openapitools/openapi-generator) 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: {{appVersion}} - Package version: {{packageVersion}} diff --git a/modules/openapi-generator/src/main/resources/elm/licenseInfo.mustache b/modules/openapi-generator/src/main/resources/elm/licenseInfo.mustache index d08c7760030..ab4d7b671fd 100644 --- a/modules/openapi-generator/src/main/resources/elm/licenseInfo.mustache +++ b/modules/openapi-generator/src/main/resources/elm/licenseInfo.mustache @@ -5,7 +5,7 @@ {{#version}}OpenAPI spec version: {{{version}}}{{/version}} {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} - NOTE: This file is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen.git + NOTE: This file is auto generated by the openapi-generator. + https://github.com/openapitools/openapi-generator.git Do not edit this file manually. -} diff --git a/samples/client/petstore/elm/README.md b/samples/client/petstore/elm/README.md index bb46f25fb29..6c9b674da72 100644 --- a/samples/client/petstore/elm/README.md +++ b/samples/client/petstore/elm/README.md @@ -3,7 +3,7 @@ This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. ## Overview -This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client. +This API client was generated by the [openapi-generator](https://github.com/openapitools/openapi-generator) 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: diff --git a/samples/client/petstore/elm/src/Data/ApiResponse.elm b/samples/client/petstore/elm/src/Data/ApiResponse.elm index 59964431c31..c1885f477c5 100644 --- a/samples/client/petstore/elm/src/Data/ApiResponse.elm +++ b/samples/client/petstore/elm/src/Data/ApiResponse.elm @@ -5,8 +5,8 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io - NOTE: This file is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen.git + NOTE: This file is auto generated by the openapi-generator. + https://github.com/openapitools/openapi-generator.git Do not edit this file manually. -} diff --git a/samples/client/petstore/elm/src/Data/Category.elm b/samples/client/petstore/elm/src/Data/Category.elm index 64bf9f537d7..621e8323e43 100644 --- a/samples/client/petstore/elm/src/Data/Category.elm +++ b/samples/client/petstore/elm/src/Data/Category.elm @@ -5,8 +5,8 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io - NOTE: This file is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen.git + NOTE: This file is auto generated by the openapi-generator. + https://github.com/openapitools/openapi-generator.git Do not edit this file manually. -} diff --git a/samples/client/petstore/elm/src/Data/Order.elm b/samples/client/petstore/elm/src/Data/Order.elm index d8b54832936..3721ea0d273 100644 --- a/samples/client/petstore/elm/src/Data/Order.elm +++ b/samples/client/petstore/elm/src/Data/Order.elm @@ -5,8 +5,8 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io - NOTE: This file is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen.git + NOTE: This file is auto generated by the openapi-generator. + https://github.com/openapitools/openapi-generator.git Do not edit this file manually. -} diff --git a/samples/client/petstore/elm/src/Data/Pet.elm b/samples/client/petstore/elm/src/Data/Pet.elm index f9282a9055f..2365b5b1a57 100644 --- a/samples/client/petstore/elm/src/Data/Pet.elm +++ b/samples/client/petstore/elm/src/Data/Pet.elm @@ -5,8 +5,8 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io - NOTE: This file is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen.git + NOTE: This file is auto generated by the openapi-generator. + https://github.com/openapitools/openapi-generator.git Do not edit this file manually. -} diff --git a/samples/client/petstore/elm/src/Data/Tag.elm b/samples/client/petstore/elm/src/Data/Tag.elm index c136da42827..2500cbb09ee 100644 --- a/samples/client/petstore/elm/src/Data/Tag.elm +++ b/samples/client/petstore/elm/src/Data/Tag.elm @@ -5,8 +5,8 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io - NOTE: This file is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen.git + NOTE: This file is auto generated by the openapi-generator. + https://github.com/openapitools/openapi-generator.git Do not edit this file manually. -} diff --git a/samples/client/petstore/elm/src/Data/User.elm b/samples/client/petstore/elm/src/Data/User.elm index 2fc965cb921..02f72b2df50 100644 --- a/samples/client/petstore/elm/src/Data/User.elm +++ b/samples/client/petstore/elm/src/Data/User.elm @@ -5,8 +5,8 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io - NOTE: This file is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen.git + NOTE: This file is auto generated by the openapi-generator. + https://github.com/openapitools/openapi-generator.git Do not edit this file manually. -} diff --git a/samples/client/petstore/elm/src/Request/Pet.elm b/samples/client/petstore/elm/src/Request/Pet.elm index 5738cb2c7e7..0765a06ce75 100644 --- a/samples/client/petstore/elm/src/Request/Pet.elm +++ b/samples/client/petstore/elm/src/Request/Pet.elm @@ -5,8 +5,8 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io - NOTE: This file is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen.git + NOTE: This file is auto generated by the openapi-generator. + https://github.com/openapitools/openapi-generator.git Do not edit this file manually. -} diff --git a/samples/client/petstore/elm/src/Request/Store.elm b/samples/client/petstore/elm/src/Request/Store.elm index 83a4aa24e70..388fb60af05 100644 --- a/samples/client/petstore/elm/src/Request/Store.elm +++ b/samples/client/petstore/elm/src/Request/Store.elm @@ -5,8 +5,8 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io - NOTE: This file is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen.git + NOTE: This file is auto generated by the openapi-generator. + https://github.com/openapitools/openapi-generator.git Do not edit this file manually. -} diff --git a/samples/client/petstore/elm/src/Request/User.elm b/samples/client/petstore/elm/src/Request/User.elm index c7ec38acd40..341b193ecac 100644 --- a/samples/client/petstore/elm/src/Request/User.elm +++ b/samples/client/petstore/elm/src/Request/User.elm @@ -5,8 +5,8 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io - NOTE: This file is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen.git + NOTE: This file is auto generated by the openapi-generator. + https://github.com/openapitools/openapi-generator.git Do not edit this file manually. -}