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 #289

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ec8c581
#282: Use injected configuration to refer to basePath
akehir Jun 12, 2018
03939c8
Regenerate tests with new api templates
akehir Jun 12, 2018
9930f61
Ignore signing for other branches than master (#288)
jmini Jun 12, 2018
2ff81ca
Expanding customization docs (#283)
Jun 12, 2018
55f9e31
Update template modification docs (#291)
jimschubert Jun 13, 2018
ff94464
Updated api to always use configuration even if old http client is us…
akehir Jun 13, 2018
2995273
[go-server] Add dockerfile for building and run petstore service (#274)
etherealjoy Jun 13, 2018
49b8ece
update cpp server scripts/batch files (#296)
wing328 Jun 13, 2018
6f6a4a1
[rust-server] (Re-)Adding support for rust-server (#290)
bjgill Jun 13, 2018
f964873
Change "samples" profile name to "samples.shippable" (#305)
jmini Jun 13, 2018
91d6d77
[rust-server] Add rust-server to travis CI (#308)
bjgill Jun 13, 2018
7126074
add Go client test - TestPlaceOrder (#321)
grokify Jun 14, 2018
24104da
Add option modelPropertyNaming to javascript generator (#299)
stianlik Jun 14, 2018
f8e61ac
[typescript] fix cast problem (#303)
topce Jun 14, 2018
680a2bc
Configuration option to disable HTML escaping when using Gson (#298)
stianlik Jun 14, 2018
5630746
Remove "CI/pom.xml.shippable" (#319)
jmini Jun 15, 2018
6c996a7
Various improvement to CI (#326)
wing328 Jun 15, 2018
e5635d2
update brew readme (#330)
wing328 Jun 16, 2018
798bf61
Grammar and spelling fixes (#329)
scop Jun 16, 2018
53d9878
Update Petstore samples (#331)
wing328 Jun 16, 2018
c607ea8
Add fixes for es6 generator (#180)
delenius Jun 16, 2018
7c49bdd
CircleCI migration from 1.0 to 2.0 (#333)
wing328 Jun 17, 2018
75171b4
[C++] Rename template dir (#332)
ackintosh Jun 17, 2018
97bab92
[cli] Enable recommendations on validate command (#292)
jimschubert Jun 17, 2018
c51986d
Go server clean up (#328)
bvwells Jun 17, 2018
30d1021
Add links for released versions in compat table (#336)
grokify Jun 18, 2018
74914b6
Prepare release 3.0.2 (#337)
jmini Jun 18, 2018
9511586
Prepare 3.0.3-SNAPSHOT (#338)
jmini Jun 18, 2018
1ffc4a2
Moved Typescript Angular 6 builds into 'builds' subdirectory to confo…
akehir Jun 19, 2018
9151f65
Adding in Telstra (#357)
developersteve Jun 20, 2018
231202d
Initial roadmap (#295)
jimschubert Jun 20, 2018
3c9cf1d
Restore unit test (#346)
jmini Jun 20, 2018
d19a2fa
[php] Correctly handle multiple valid responses (#128)
fMads Jun 20, 2018
645a25b
Added angular 6 with-npm sample client
akehir Jun 20, 2018
108aabc
Add test cases for angular 6 generated sample client, as well as for …
akehir Jun 20, 2018
35fbac1
Fixed typos in typescript pom.xml
akehir Jun 20, 2018
9993684
Add no-watch to karma
akehir Jun 20, 2018
d4654fc
Use PhantomJS instead of Chrome, rename all typescript-angular-poms t…
akehir Jun 20, 2018
d5b209d
#282: Use injected configuration to refer to basePath
akehir Jun 12, 2018
63326b8
Regenerate tests with new api templates
akehir Jun 12, 2018
ddab13c
Updated api to always use configuration even if old http client is us…
akehir Jun 13, 2018
dc74492
Moved Typescript Angular 6 builds into 'builds' subdirectory to confo…
akehir Jun 19, 2018
6ec5160
Added angular 6 with-npm sample client
akehir Jun 20, 2018
d4d23d2
Add test cases for angular 6 generated sample client, as well as for …
akehir Jun 20, 2018
7cb71ab
Fixed typos in typescript pom.xml
akehir Jun 20, 2018
2353fe7
Add no-watch to karma
akehir Jun 20, 2018
802a42b
Use PhantomJS instead of Chrome, rename all typescript-angular-poms t…
akehir Jun 20, 2018
ea59f19
Merge branch 'feature/basePathThroughInjectedConfig' of github.com:ak…
akehir Jun 20, 2018
871445a
Enable angular 6 test cases in circleci
akehir Jun 20, 2018
dc880e8
Use nvm to update node
akehir Jun 20, 2018
6beb630
Do not show angular build progress as it spams the ci log
akehir Jun 20, 2018
c983865
Do not duplicate addons in travis
akehir Jun 20, 2018
dcb3d12
Run Chrome in headless mode for CI
akehir Jun 20, 2018
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 bin/typescript-angular-petstore-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
./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-provided-in-root.sh
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 -l typescript-angular -o samples/client/petstore/typescript-angular-v6-not-provided-in-root/default -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-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 -l typescript-angular -o samples/client/petstore/typescript-angular-v6-provided-in-root/default --additional-properties ngVersion=6.0.0 $@"

java $JAVA_OPTS -jar $executable $ags
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't you want to set

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

in order to account for the situation where you pass a configuration object that does not contain a base path plus a basePath parameter, since the basePath property of Configuration is optional, see
https://github.com/openapitools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-angular/configuration.mustache#L15
?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would even mark the basePath property of the api service as deprecated, since only this.configuration.basePath should be used. what do you think about that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good now

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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.1-SNAPSHOT
3.0.2-SNAPSHOT
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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ export class StoreService {
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 @@ -156,7 +157,7 @@ export class StoreService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
return this.http.request(`${this.configuration.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
}

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

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

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

return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
return this.http.request(`${this.configuration.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
}

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

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ export class UserService {
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 @@ -227,7 +228,7 @@ export class UserService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.1-SNAPSHOT
3.0.2-SNAPSHOT
Loading