Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript][angular] basePath through injected config #367

Merged
merged 2 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: java
jdk:
- openjdk8


cache:
directories:
- $HOME/.m2
Expand Down Expand Up @@ -35,6 +36,7 @@ services:

# comment out the host table change to use the public petstore server
addons:
chrome: stable
hosts:
- petstore.swagger.io

Expand Down
1 change: 1 addition & 0 deletions CI/pom.xml.circleci
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@
<!-- clients -->
<!-- test non-java projects -->
<module>samples/client/petstore/go</module>
<module>samples/client/petstore/typescript-angular-v6-provided-in-root</module>
<!-- test java-related projects -->
<module>samples/client/petstore/scala-akka</module>
<module>samples/client/petstore/scala-httpclient</module>
Expand Down
1 change: 1 addition & 0 deletions CI/pom.xml.circleci.java7
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@
<module>samples/client/petstore/kotlin/</module>
<!-- test non-java projects -->
<!--<module>samples/client/petstore/go</module>-->
<module>samples/client/petstore/typescript-angular-v6-provided-in-root</module>
<!-- servers -->
<module>samples/server/petstore/java-vertx/rx</module>
<module>samples/server/petstore/java-vertx/async</module>
Expand Down
4 changes: 4 additions & 0 deletions bin/typescript-angular-petstore-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
./bin/typescript-angular-v2-petstore-interfaces.sh
./bin/typescript-angular-v4-petstore-with-npm.sh
./bin/typescript-angular-v4.3-petstore-with-npm.sh
./bin/typescript-angular-v6-petstore-not-provided-in-root.sh
./bin/typescript-angular-v6-petstore-not-provided-in-root-with-npm.sh
./bin/typescript-angular-v6-petstore-provided-in-root.sh
./bin/typescript-angular-v6-petstore-provided-in-root-with-npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"npmName": "@swagger/typescript-angular-petstore",
"npmVersion": "1.0.0",
"npmRepository" : "https://skimdb.npmjs.com/registry",
"snapshot" : false
}
Original file line number Diff line number Diff line change
@@ -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 -B 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/2_0/petstore.yaml -g typescript-angular -c bin/typescript-angular-v6-petstore-not-provided-in-root-with-npm.json -o samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm -D providedInRoot=false --additional-properties ngVersion=6.0.0 $@"

java $JAVA_OPTS -jar $executable $ags
32 changes: 32 additions & 0 deletions bin/typescript-angular-v6-petstore-not-provided-in-root.sh
Original file line number Diff line number Diff line change
@@ -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 -B 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/2_0/petstore.yaml -g typescript-angular -o samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default -D providedInRoot=false --additional-properties ngVersion=6.0.0 $@"

java $JAVA_OPTS -jar $executable $ags
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"npmName": "@swagger/typescript-angular-petstore",
"npmVersion": "1.0.0",
"npmRepository" : "https://skimdb.npmjs.com/registry",
"snapshot" : false
}
32 changes: 32 additions & 0 deletions bin/typescript-angular-v6-petstore-provided-in-root-with-npm.sh
Original file line number Diff line number Diff line change
@@ -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 -B 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/2_0/petstore.yaml -g typescript-angular -c bin/typescript-angular-v6-petstore-provided-in-root-with-npm.json -o samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm --additional-properties ngVersion=6.0.0 $@"

java $JAVA_OPTS -jar $executable $ags
32 changes: 32 additions & 0 deletions bin/typescript-angular-v6-petstore-provided-in-root.sh
Original file line number Diff line number Diff line change
@@ -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 -B 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/2_0/petstore.yaml -g typescript-angular -o samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default --additional-properties ngVersion=6.0.0 $@"

java $JAVA_OPTS -jar $executable $ags
2 changes: 2 additions & 0 deletions bin/windows/typescript-angular-petstore-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ call .\bin\windows\typescript-angular-v2.bat
call .\bin\windows\typescript-angular-v4-with-npm.bat
call .\bin\windows\typescript-angular-v4.3-with-npm.bat
call .\bin\windows\typescript-angular-v6-provided-in-root.bat
call .\bin\windows\typescript-angular-v6-provided-in-root-with-npm.bat
call .\bin\windows\typescript-angular-v6-not-provided-in-root.bat
call .\bin\windows\typescript-angular-v6-not-provided-in-root-with-npm.bat


Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin\typescript-angular-v6-petstore-not-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\builds\with-npm -D providedInRoot=false --additional-properties ngVersion=6.0.0

java %JAVA_OPTS% -jar %executable% %ags%
2 changes: 1 addition & 1 deletion bin/windows/typescript-angular-v6-not-provided-in-root.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ If Not Exist %executable% (
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\default -D providedInRoot=false --additional-properties ngVersion=6.0.0
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\builds\default -D providedInRoot=false --additional-properties ngVersion=6.0.0

java %JAVA_OPTS% -jar %executable% %ags%
12 changes: 12 additions & 0 deletions bin/windows/typescript-angular-v6-provided-in-root-with-npm.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\default --additional-properties ngVersion=6.0.0
REM it is same like like setting -D providedInRoot=true
REM set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin\typescript-angular-v6-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\with-npm -D providedInRoot=true --additional-properties ngVersion=6.0.0

java %JAVA_OPTS% -jar %executable% %ags%
2 changes: 1 addition & 1 deletion bin/windows/typescript-angular-v6-provided-in-root.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ If Not Exist %executable% (
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\default --additional-properties ngVersion=6.0.0
REM it is same like like setting -D providedInRoot=true
REM set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\default -D providedInRoot=true --additional-properties ngVersion=6.0.0
REM set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\default -D providedInRoot=true --additional-properties ngVersion=6.0.0

java %JAVA_OPTS% -jar %executable% %ags%
15 changes: 15 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ jobs:
- run: sudo apt-get update -qq
- run: sudo apt-get install -qq bats
- run: sudo apt-get install -qq curl
# Install latest stable node for angular 6
- run:
name: Install node@stable (for angular 6)
command: |
set +e
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install stable
nvm alias default stable

# Each step uses the same `$BASH_ENV`, so need to modify it
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV
- run: node --version
# - run: docker pull openapitools/openapi-petstore
# - run: docker run -d -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 80:8080 openapitools/openapi-petstore
- run: docker pull swaggerapi/petstore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ export class {{classname}} {
public configuration = new Configuration();

constructor(protected {{#useHttpClient}}httpClient: HttpClient{{/useHttpClient}}{{^useHttpClient}}http: Http{{/useHttpClient}}, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
if (basePath) {
this.basePath = basePath;
}

if (configuration) {
this.configuration = configuration;
this.basePath = basePath || configuration.basePath || this.basePath;
this.configuration.basePath = configuration.basePath || basePath || this.basePath;

} else {
this.configuration.basePath = basePath || this.basePath;
}
}

Expand Down Expand Up @@ -303,7 +304,7 @@ export class {{classname}} {

{{/hasFormParams}}
{{#useHttpClient}}
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isBodyAllowed}}
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.configuration.basePath}{{{path}}}`,{{#isBodyAllowed}}
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}}
{
{{#hasQueryParams}}
Expand Down Expand Up @@ -342,7 +343,7 @@ export class {{classname}} {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

return this.http.request(`${this.basePath}{{{path}}}`, requestOptions);
return this.http.request(`${this.configuration.basePath}{{{path}}}`, requestOptions);
{{/useHttpClient}}
}

Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,7 @@
<!--<module>samples/client/petstore/typescript-angular-v2/npm</module>-->
<module>samples/client/petstore/typescript-angular-v4/npm</module>
<module>samples/client/petstore/typescript-angular-v4.3/npm</module>
<module>samples/client/petstore/typescript-angular-v6-provided-in-root</module>
<!--<module>samples/client/petstore/bash</module>-->
<module>samples/client/petstore/ruby</module>
<module>samples/server/petstore/rust-server</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ export class PetService {
public configuration = new Configuration();

constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
if (basePath) {
this.basePath = basePath;
}

if (configuration) {
this.configuration = configuration;
this.basePath = basePath || configuration.basePath || this.basePath;
this.configuration.basePath = configuration.basePath || basePath || this.basePath;

} else {
this.configuration.basePath = basePath || this.basePath;
}
}

Expand Down Expand Up @@ -242,7 +243,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

return this.http.request(`${this.basePath}/pet`, requestOptions);
return this.http.request(`${this.configuration.basePath}/pet`, requestOptions);
}

/**
Expand Down Expand Up @@ -292,7 +293,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
return this.http.request(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}

/**
Expand Down Expand Up @@ -346,7 +347,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

return this.http.request(`${this.basePath}/pet/findByStatus`, requestOptions);
return this.http.request(`${this.configuration.basePath}/pet/findByStatus`, requestOptions);
}

/**
Expand Down Expand Up @@ -400,7 +401,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

return this.http.request(`${this.basePath}/pet/findByTags`, requestOptions);
return this.http.request(`${this.configuration.basePath}/pet/findByTags`, requestOptions);
}

/**
Expand Down Expand Up @@ -445,7 +446,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
return this.http.request(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}

/**
Expand Down Expand Up @@ -498,7 +499,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

return this.http.request(`${this.basePath}/pet`, requestOptions);
return this.http.request(`${this.configuration.basePath}/pet`, requestOptions);
}

/**
Expand Down Expand Up @@ -570,7 +571,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
return this.http.request(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}

/**
Expand Down Expand Up @@ -646,7 +647,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, requestOptions);
return this.http.request(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, requestOptions);
}

}
Loading