Skip to content

Commit

Permalink
cleans / updates Petstore samples, adds a new sample for Angular 5
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesHoppe committed Apr 6, 2018
1 parent b0a3240 commit 471d248
Show file tree
Hide file tree
Showing 66 changed files with 1,913 additions and 2,313 deletions.
4 changes: 4 additions & 0 deletions bin/typescript-angular-petstore-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ java $JAVA_OPTS -jar $executable $ags
echo "Typescript Petstore API client (v4.3 { Adding HttpClientModule over HttpModule })"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v4.3/npm --additional-properties ngVersion=4.3"
java $JAVA_OPTS -jar $executable $ags

echo "Typescript Petstore API client (v5 { Uses latest version of ng-packagr })"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v5/npm --additional-properties ngVersion=5"
java $JAVA_OPTS -jar $executable $ags
31 changes: 31 additions & 0 deletions bin/typescript-angular-v5-petstore-with-npm.1.sh
Original file line number Diff line number Diff line change
@@ -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/swagger-codegen-cli/target/swagger-codegen-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/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v5/npm --additional-properties ngVersion=5"

java $JAVA_OPTS -jar $executable $ags
1 change: 1 addition & 0 deletions bin/windows/typescript-angular-petstore-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ call .\bin\windows\typescript-angular-v2-interfaces.bat
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-v5-with-npm.bat


10 changes: 10 additions & 0 deletions bin/windows/typescript-angular-v5-with-npm.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -c bin\typescript-petstore-npm.json -l typescript-angular -o samples\client\petstore\typescript-angular-v5\npm --additional-properties ngVersion=5

java %JAVA_OPTS% -jar %executable% %ags%
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
additionalProperties.put("useNgPackagr", false);
} else {
additionalProperties.put("useNgPackagr", true);
supportingFiles.add(new SupportingFile("ng-package.mustache", getIndexDirectory(), "ng-package.json"));
}

// Libraries generated with v1.x of ng-packagr will ship with AoT metadata in v3, which is intended for Angular v4.
Expand All @@ -171,7 +172,6 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
supportingFiles.add(new SupportingFile("package.mustache", getIndexDirectory(), "package.json"));
supportingFiles.add(new SupportingFile("typings.mustache", getIndexDirectory(), "typings.json"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", getIndexDirectory(), "tsconfig.json"));
supportingFiles.add(new SupportingFile("ng-package.mustache", getIndexDirectory(), "ng-package.json"));
}

private String getIndexDirectory() {
Expand Down
201 changes: 0 additions & 201 deletions samples/client/petstore/typescript-angular-v2/default/LICENSE

This file was deleted.

15 changes: 7 additions & 8 deletions samples/client/petstore/typescript-angular-v2/default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,41 @@

### Building

To build an compile the typescript sources to javascript use:
To install the required dependencies and to build the typescript sources run:
```
npm install
npm run build
```

### publishing

First build the package than run ```npm publish```
First build the package than run ```npm publish dist``` (don`t forget to specify the `dist` folder!)

### consuming

navigate to the folder of your consuming project and run one of next commando's.
navigate to the folder of your consuming project and run one of next commands.

_published:_

```
npm install @ --save
```

_unPublished (not recommended):_
_without publishing (not recommended):_

```
npm install PATH_TO_GENERATED_PACKAGE --save
npm install PATH_TO_GENERATED_PACKAGE/dist --save
```

_using `npm link`:_

In PATH_TO_GENERATED_PACKAGE:
In PATH_TO_GENERATED_PACKAGE/dist:
```
npm link
```

In your project:
```
npm link @
npm link
```

In your Angular project:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class UserService {
/**
*
* @summary Get user by user name
* @param username The name that needs to be fetched. Use user1 for testing.
* @param username The name that needs to be fetched. Use user1 for testing.
*/
public getUserByName(username: string, extraHttpRequestParams?: RequestOptionsArgs): Observable<User> {
return this.getUserByNameWithHttpInfo(username, extraHttpRequestParams)
Expand Down Expand Up @@ -365,7 +365,7 @@ export class UserService {
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @param username The name that needs to be fetched. Use user1 for testing.
*/
public getUserByNameWithHttpInfo(username: string, extraHttpRequestParams?: RequestOptionsArgs): Observable<Response> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class Configuration {
* Select the correct content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param {string[]} contentTypes - the array of content types that are available for selection
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
* @param contentTypes - the array of content types that are available for selection
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/
public selectHeaderContentType (contentTypes: string[]): string | undefined {
if (contentTypes.length == 0) {
Expand All @@ -47,8 +47,8 @@ export class Configuration {
* Select the correct accept content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param {string[]} accepts - the array of content types that are available for selection.
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
* @param accepts - the array of content types that are available for selection.
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/
public selectHeaderAccept(accepts: string[]): string | undefined {
if (accepts.length == 0) {
Expand All @@ -69,8 +69,8 @@ export class Configuration {
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
* @return {boolean} True if the given MIME is JSON, false otherwise.
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
Expand Down
Loading

0 comments on commit 471d248

Please sign in to comment.