diff --git a/bin/openapi3/erlang-petstore-client.sh b/bin/openapi3/erlang-petstore-client.sh new file mode 100755 index 00000000000..e813ad78985 --- /dev/null +++ b/bin/openapi3/erlang-petstore-client.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +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 -t modules/openapi-generator/src/main/resources/erlang-client -DpackageName=petstore -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l erlang-client -o samples/client/petstore/erlang-client" + +java $JAVA_OPTS -jar $executable $ags diff --git a/samples/client/petstore/erlang-client/src/petstore_store_api.erl b/samples/client/petstore/erlang-client/src/petstore_store_api.erl index 178cd0a2cb2..2e72823d9d9 100644 --- a/samples/client/petstore/erlang-client/src/petstore_store_api.erl +++ b/samples/client/petstore/erlang-client/src/petstore_store_api.erl @@ -86,7 +86,7 @@ place_order(Ctx, PetstoreOrder, Optional) -> QS = [], Headers = [], Body1 = PetstoreOrder, - ContentTypeHeader = petstore_utils:select_header_content_type([]), + ContentTypeHeader = petstore_utils:select_header_content_type([<<"application/json">>]), Opts = maps:get(hackney_opts, Optional, []), petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). diff --git a/samples/client/petstore/erlang-client/src/petstore_user_api.erl b/samples/client/petstore/erlang-client/src/petstore_user_api.erl index b1f07026be8..45a8a9d7872 100644 --- a/samples/client/petstore/erlang-client/src/petstore_user_api.erl +++ b/samples/client/petstore/erlang-client/src/petstore_user_api.erl @@ -27,7 +27,7 @@ create_user(Ctx, PetstoreUser, Optional) -> QS = [], Headers = [], Body1 = PetstoreUser, - ContentTypeHeader = petstore_utils:select_header_content_type([]), + ContentTypeHeader = petstore_utils:select_header_content_type([<<"application/json">>]), Opts = maps:get(hackney_opts, Optional, []), petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). @@ -48,7 +48,7 @@ create_users_with_array_input(Ctx, PetstoreUserArray, Optional) -> QS = [], Headers = [], Body1 = PetstoreUserArray, - ContentTypeHeader = petstore_utils:select_header_content_type([]), + ContentTypeHeader = petstore_utils:select_header_content_type([<<"application/json">>]), Opts = maps:get(hackney_opts, Optional, []), petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). @@ -69,7 +69,7 @@ create_users_with_list_input(Ctx, PetstoreUserArray, Optional) -> QS = [], Headers = [], Body1 = PetstoreUserArray, - ContentTypeHeader = petstore_utils:select_header_content_type([]), + ContentTypeHeader = petstore_utils:select_header_content_type([<<"application/json">>]), Opts = maps:get(hackney_opts, Optional, []), petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). @@ -174,7 +174,7 @@ update_user(Ctx, Username, PetstoreUser, Optional) -> QS = [], Headers = [], Body1 = PetstoreUser, - ContentTypeHeader = petstore_utils:select_header_content_type([]), + ContentTypeHeader = petstore_utils:select_header_content_type([<<"application/json">>]), Opts = maps:get(hackney_opts, Optional, []), petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).