Skip to content

Commit 0fb154e

Browse files
bkryzawing328
authored andcommitted
[Bash] Bash client script generator (#4541)
* Initial commit * Remormatted petstore tests * Added Bash codegen to main README.md * Added bash to integration tests * Fixed stdin detection in generated script * Added back ruby module
1 parent 2e4de0c commit 0fb154e

File tree

24 files changed

+8338
-1
lines changed

24 files changed

+8338
-1
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ before_install:
2424
- docker pull swaggerapi/petstore
2525
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
2626
- docker ps -a
27+
# Add bats test framework and cURL for Bash script integration tests
28+
- sudo add-apt-repository ppa:duggan/bats --yes
29+
- sudo apt-get update -qq
30+
- sudo apt-get install -qq bats
31+
- sudo apt-get install -qq curl
32+
2733
# show host table to confirm petstore.swagger.io is mapped to localhost
2834
- cat /etc/hosts
2935

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ For a list of variables available in the template, please refer to this [page](h
3030
### Style guide
3131
Code change should conform to the programming style guide of the respective languages:
3232
- Android: https://source.android.com/source/code-style.html
33+
- Bash: https://github.com/bahamas10/bash-style-guide
3334
- C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
3435
- C++: https://google.github.io/styleguide/cppguide.html
3536
- Clojure: https://github.com/bbatsov/clojure-style-guide

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
## Overview
1616
This is the swagger codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification). Currently, the following languages/frameworks are supported:
1717

18-
- **API clients**: **ActionScript**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Go**, **Groovy**, **Haskell**, **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign), **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **Python**, **Ruby**, **Scala**, **Swift** (2.x, 3.x), **Typescript** (Angular1.x, Angular2.x, Fetch, Node)
18+
- **API clients**: **ActionScript**, **Bash**,**C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Go**, **Groovy**, **Haskell**, **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign), **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **Python**, **Ruby**, **Scala**, **Swift** (2.x, 3.x), **Typescript** (Angular1.x, Angular2.x, Fetch, Node)
1919
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **Erlang**, **Go**, **Haskell**, **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy), **PHP** (Lumen, Slim, Silex), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Scala** (Scalatra)
2020
- **API documentation generators**: **HTML**, **Confluence Wiki**
2121
- **Others**: **JMeter**
@@ -463,6 +463,7 @@ AndroidClientCodegen.java
463463
AspNet5ServerCodegen.java
464464
AspNetCoreServerCodegen.java
465465
AsyncScalaClientCodegen.java
466+
BashClientCodegen.java
466467
CSharpClientCodegen.java
467468
ClojureClientCodegen.java
468469
CsharpDotNet2ClientCodegen.java
@@ -891,6 +892,7 @@ Swagger Codegen core team members are contributors who have been making signific
891892
Here is a list of template creators:
892893
* API Clients:
893894
* Akka-Scala: @cchafer
895+
* Bash: @bkryza
894896
* C++ REST: @Danielku15
895897
* C# (.NET 2.0): @who
896898
* Clojure: @xhh

bin/bash-petstore.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
args="$@ generate -t modules/swagger-codegen/src/main/resources/bash -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l bash -o samples/client/petstore/bash -c modules/swagger-codegen/src/test/resources/2_0/bash-config.json"
30+
31+
java $JAVA_OPTS -jar $executable $args

0 commit comments

Comments
 (0)