Skip to content

Commit

Permalink
add petstore samples for typescript aurelia
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Jul 23, 2017
1 parent 21619c5 commit 188e998
Show file tree
Hide file tree
Showing 28 changed files with 1,460 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ samples/client/petstore/typescript-fetch/**/dist/
samples/client/petstore/typescript-fetch/**/typings
samples/client/petstore/typescript-angular2/npm/npm-debug.log
samples/client/petstore/typescript-node/npm/npm-debug.log
samples/client/petstore/typescript-aurelia/**/dist/

# aspnetcore
samples/server/petstore/aspnetcore/.vs/
Expand Down
Empty file modified bin/apache2-petstore-config.sh
100644 → 100755
Empty file.
Empty file modified bin/eiffel-petstore.sh
100644 → 100755
Empty file.
Empty file modified bin/java-play-framework-petstore-server-all.sh
100644 → 100755
Empty file.
Empty file modified bin/java-play-framework-petstore-server-controller-only.sh
100644 → 100755
Empty file.
Empty file modified bin/java-play-framework-petstore-server-no-bean-validation.sh
100644 → 100755
Empty file.
Empty file.
Empty file modified bin/java-play-framework-petstore-server-no-interface.sh
100644 → 100755
Empty file.
Empty file modified bin/java-play-framework-petstore-server-no-swagger-ui.sh
100644 → 100755
Empty file.
Empty file modified bin/java-play-framework-petstore-server-no-wrap-calls.sh
100644 → 100755
Empty file.
31 changes: 31 additions & 0 deletions bin/typescript-aurelia-petstore.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-aurelia -o samples/client/petstore/typescript-aurelia/default"

java $JAVA_OPTS -jar $executable $ags
Empty file modified bin/typescript-jquery-petstore-with-npm.sh
100644 → 100755
Empty file.
Empty file modified bin/typescript-jquery-petstore.sh
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions samples/client/petstore/typescript-aurelia/default/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wwwroot/*.js
node_modules
typings
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3.0-SNAPSHOT
76 changes: 76 additions & 0 deletions samples/client/petstore/typescript-aurelia/default/Api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/

import { HttpClient } from 'aurelia-http-client';
import { AuthStorage } from './AuthStorage';

const BASE_PATH = 'http://petstore.swagger.io/v2'.replace(/\/+$/, '');

export class Api {
basePath: string;
httpClient: HttpClient;
authStorage: AuthStorage;

constructor(httpClient: HttpClient, authStorage: AuthStorage, basePath: string = BASE_PATH) {
this.basePath = basePath;
this.httpClient = httpClient;
this.authStorage = authStorage;
}

/**
* Encodes a query string.
*
* @param params The params to encode.
* @return An encoded query string.
*/
protected queryString(params: { [key: string]: any }): string {
const queries = [];
for (let key in params) {
const value = this.toString(params[key]);
if (value != null) {
queries.push(`${key}=${encodeURIComponent(value)}`);
}
}

return queries.join('&');
}

/**
* Converts a value to string.
*
* @param value The value to convert.
*/
protected toString(value: any): string | null {
if (value === null) {
return null;
}
switch (typeof value) {
case 'undefined': return null;
case 'boolean': return value ? 'true' : 'false';
case 'string': return value;
default: return '' + value;
}
}

/**
* Ensures that a given parameter is set.
*
* @param context A name for the callee's context.
* @param params The parameters being set.
* @param paramName The required parameter to check.
*/
protected ensureParamIsSet<T>(context: string, params: T, paramName: keyof T): void {
if (null === params[paramName]) {
throw new Error(`Missing required parameter ${paramName} when calling ${context}`);
}
}
}
72 changes: 72 additions & 0 deletions samples/client/petstore/typescript-aurelia/default/AuthStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/

/**
* Class to storage authentication data
*/
export class AuthStorage {
private storage: Map<string, string>;

constructor() {
this.storage = new Map();
}

/**
* Sets the api_key auth method value.
*
* @param value The new value to set for api_key.
*/
setapi_key(value: string): this {
this.storage.set('api_key', value);
return this;
}

/**
* Removes the api_key auth method value.
*/
removeapi_key(): this {
this.storage.delete('api_key');
return this;
}

/**
* Gets the api_key auth method value.
*/
getapi_key(): null | string {
return this.storage.get('api_key') || null;
}

/**
* Sets the petstore_auth auth method value.
*
* @param value The new value to set for petstore_auth.
*/
setpetstore_auth(value: string): this {
this.storage.set('petstore_auth', value);
return this;
}

/**
* Removes the petstore_auth auth method value.
*/
removepetstore_auth(): this {
this.storage.delete('petstore_auth');
return this;
}

/**
* Gets the petstore_auth auth method value.
*/
getpetstore_auth(): null | string {
return this.storage.get('petstore_auth') || null;
}
}
Loading

0 comments on commit 188e998

Please sign in to comment.