forked from loafle/openapi-generator-original
Merge pull request #2645 from Vrolijkx/master
Typescript angular2 client
This commit is contained in:
commit
25ccb250cc
@ -48,4 +48,5 @@ cd $APP_DIR
|
||||
./bin/swift-petstore.sh
|
||||
./bin/tizen-petstore.sh
|
||||
./bin/typescript-angular-petstore.sh
|
||||
./bin/typescript-angular2-petstore.sh
|
||||
./bin/typescript-node-petstore.sh
|
||||
|
31
bin/typescript-angular2-petstore.sh
Executable file
31
bin/typescript-angular2-petstore.sh
Executable file
@ -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.json -l typescript-angular2 -o samples/client/petstore/typescript-angular2"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
10
bin/windows/typescript-angular2.bat
Executable file
10
bin/windows/typescript-angular2.bat
Executable file
@ -0,0 +1,10 @@
|
||||
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-angular -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-angular2 -o samples\client\petstore\typescript-angular
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -0,0 +1,81 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import io.swagger.codegen.CodegenParameter;
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.FileProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
|
||||
public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
|
||||
public TypeScriptAngular2ClientCodegen() {
|
||||
super();
|
||||
this.outputFolder = "generated-code/typescript-angular2";
|
||||
|
||||
embeddedTemplateDir = templateDir = "typescript-angular2";
|
||||
modelTemplateFiles.put("model.mustache", ".ts");
|
||||
apiTemplateFiles.put("api.mustache", ".ts");
|
||||
typeMapping.put("Date","Date");
|
||||
apiPackage = "api";
|
||||
modelPackage = "model";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "typescript-angular2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a TypeScript Angular2 client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
supportingFiles.clear();
|
||||
supportingFiles.add(new SupportingFile("model.d.mustache", modelPackage().replace('.', File.separatorChar), "model.d.ts"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
Property inner;
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty mp1 = (ArrayProperty)p;
|
||||
inner = mp1.getItems();
|
||||
return this.getSwaggerType(p) + "<" + this.getTypeDeclaration(inner) + ">";
|
||||
} else if(p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty)p;
|
||||
inner = mp.getAdditionalProperties();
|
||||
return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }";
|
||||
} else {
|
||||
return p instanceof FileProperty ? "any" : super.getTypeDeclaration(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
return addModelPrefix(swaggerType);
|
||||
}
|
||||
|
||||
private String addModelPrefix(String swaggerType) {
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if (languageSpecificPrimitives.contains(type))
|
||||
return type;
|
||||
} else
|
||||
type = "model." + swaggerType;
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
super.postProcessParameter(parameter);
|
||||
parameter.dataType = addModelPrefix(parameter.dataType);
|
||||
}
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
import java.io.File;
|
||||
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
|
||||
public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
|
||||
@Override
|
||||
@ -14,14 +15,13 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
public String getHelp() {
|
||||
return "Generates a TypeScript AngularJS client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
supportingFiles.add(new SupportingFile("api.d.mustache", apiPackage().replace('.', File.separatorChar), "api.d.ts"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
supportingFiles.add(new SupportingFile("api.d.mustache", apiPackage().replace('.', File.separatorChar), "api.d.ts"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ io.swagger.codegen.languages.SwaggerGenerator
|
||||
io.swagger.codegen.languages.SwaggerYamlGenerator
|
||||
io.swagger.codegen.languages.SwiftCodegen
|
||||
io.swagger.codegen.languages.TizenClientCodegen
|
||||
io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen
|
||||
io.swagger.codegen.languages.TypeScriptAngularClientCodegen
|
||||
io.swagger.codegen.languages.TypeScriptNodeClientCodegen
|
||||
io.swagger.codegen.languages.AkkaScalaClientCodegen
|
||||
|
@ -0,0 +1,87 @@
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http';
|
||||
import {Injectable} from 'angular2/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as model from "../model/model.d.ts"
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
{{#operations}}
|
||||
'use strict';
|
||||
|
||||
{{#description}}
|
||||
/**
|
||||
* {{&description}}
|
||||
*/
|
||||
{{/description}}
|
||||
@Injectable()
|
||||
export class {{classname}} {
|
||||
protected basePath = '{{basePath}}';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{summary}}
|
||||
* {{notes}}
|
||||
{{#allParams}}* @param {{paramName}} {{description}}
|
||||
{{/allParams}}*/
|
||||
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> {
|
||||
const path = this.basePath + '{{path}}'{{#pathParams}}
|
||||
.replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}};
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
{{#hasFormParams}}
|
||||
let formParams = new URLSearchParams();
|
||||
|
||||
{{/hasFormParams}}
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
// verify required parameter '{{paramName}}' is set
|
||||
if (!{{paramName}}) {
|
||||
throw new Error('Missing required parameter {{paramName}} when calling {{nickname}}');
|
||||
}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
{{#queryParams}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
queryParameters['{{baseName}}'] = {{paramName}};
|
||||
}
|
||||
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
headerParams.set('{{baseName}}', {{paramName }});
|
||||
|
||||
{{/headerParams}}
|
||||
{{#hasFormParams}}
|
||||
headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
{{/hasFormParams}}
|
||||
{{#formParams}}
|
||||
formParams['{{baseName}}'] = {{paramName}};
|
||||
|
||||
{{/formParams}}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: '{{httpMethod}}',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
{{#bodyParam}}
|
||||
requestOptions.body = JSON.stringify({{paramName}});
|
||||
{{/bodyParam}}
|
||||
{{#hasFormParams}}
|
||||
requestOptions.body = formParams.toString();
|
||||
{{/hasFormParams}}
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
@ -0,0 +1,17 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
export * from './{{{ classname }}}';
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
||||
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
export * from '../api/{{classname}}';
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
'use strict';
|
||||
import * as model from "./model.d.ts"
|
||||
|
||||
{{#description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/description}}
|
||||
export interface {{classname}} {{#parent}}extends model.{{{parent}}} {{/parent}}{
|
||||
{{#vars}}
|
||||
|
||||
{{#description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/description}}
|
||||
|
||||
{{name}}?: {{#isEnum}}{{classname}}.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
{{#hasEnums}}
|
||||
export namespace {{classname}} {
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
|
||||
export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}}
|
||||
{{.}} = <any> '{{.}}',{{/values}}{{/allowableValues}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
}
|
||||
{{/hasEnums}}
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -0,0 +1,32 @@
|
||||
package io.swagger.codegen.options;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
|
||||
public class TypeScriptAngular2ClientOptionsProvider implements OptionsProvider {
|
||||
public static final String SORT_PARAMS_VALUE = "false";
|
||||
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
||||
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
return "typescript-angular2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> createOptions() {
|
||||
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
|
||||
return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
|
||||
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
|
||||
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServer() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package io.swagger.codegen.typescriptangular2;
|
||||
|
||||
import io.swagger.codegen.AbstractOptionsTest;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen;
|
||||
import io.swagger.codegen.options.TypeScriptAngular2ClientOptionsProvider;
|
||||
import io.swagger.codegen.options.TypeScriptAngularClientOptionsProvider;
|
||||
import mockit.Expectations;
|
||||
import mockit.Tested;
|
||||
|
||||
public class TypeScriptAngular2ClientOptionsTest extends AbstractOptionsTest {
|
||||
|
||||
@Tested
|
||||
private TypeScriptAngular2ClientCodegen clientCodegen;
|
||||
|
||||
public TypeScriptAngular2ClientOptionsTest() {
|
||||
super(new TypeScriptAngular2ClientOptionsProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CodegenConfig getCodegenConfig() {
|
||||
return clientCodegen;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
protected void setExpectations() {
|
||||
new Expectations(clientCodegen) {{
|
||||
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptAngularClientOptionsProvider.SORT_PARAMS_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setModelPropertyNaming(TypeScriptAngularClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
|
||||
times = 1;
|
||||
}};
|
||||
}
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
package io.swagger.codegen.typescriptangular2;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import io.swagger.codegen.CodegenModel;
|
||||
import io.swagger.codegen.CodegenProperty;
|
||||
import io.swagger.codegen.DefaultCodegen;
|
||||
import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen;
|
||||
import io.swagger.models.ArrayModel;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.ModelImpl;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.DateTimeProperty;
|
||||
import io.swagger.models.properties.LongProperty;
|
||||
import io.swagger.models.properties.RefProperty;
|
||||
import io.swagger.models.properties.StringProperty;
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
public class TypeScriptAngular2ModelTest {
|
||||
|
||||
@Test(description = "convert a simple TypeScript Angular2 model")
|
||||
public void simpleModelTest() {
|
||||
final Model model = new ModelImpl()
|
||||
.description("a sample model")
|
||||
.property("id", new LongProperty())
|
||||
.property("name", new StringProperty())
|
||||
.property("createdAt", new DateTimeProperty())
|
||||
.required("id")
|
||||
.required("name");
|
||||
final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen();
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 3);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.datatype, "number");
|
||||
Assert.assertEquals(property1.name, "id");
|
||||
Assert.assertEquals(property1.defaultValue, "null");
|
||||
Assert.assertEquals(property1.baseType, "number");
|
||||
Assert.assertTrue(property1.hasMore);
|
||||
Assert.assertTrue(property1.required);
|
||||
Assert.assertTrue(property1.isNotContainer);
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "name");
|
||||
Assert.assertEquals(property2.datatype, "string");
|
||||
Assert.assertEquals(property2.name, "name");
|
||||
Assert.assertEquals(property2.defaultValue, "null");
|
||||
Assert.assertEquals(property2.baseType, "string");
|
||||
Assert.assertTrue(property2.hasMore);
|
||||
Assert.assertTrue(property2.required);
|
||||
Assert.assertTrue(property2.isNotContainer);
|
||||
|
||||
final CodegenProperty property3 = cm.vars.get(2);
|
||||
Assert.assertEquals(property3.baseName, "createdAt");
|
||||
Assert.assertEquals(property3.complexType, null);
|
||||
Assert.assertEquals(property3.datatype, "Date");
|
||||
Assert.assertEquals(property3.name, "createdAt");
|
||||
Assert.assertEquals(property3.defaultValue, "null");
|
||||
Assert.assertNull(property3.hasMore);
|
||||
Assert.assertNull(property3.required);
|
||||
Assert.assertTrue(property3.isNotContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with list property")
|
||||
public void listPropertyTest() {
|
||||
final Model model = new ModelImpl()
|
||||
.description("a sample model")
|
||||
.property("id", new LongProperty())
|
||||
.property("urls", new ArrayProperty().items(new StringProperty()))
|
||||
.required("id");
|
||||
final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen();
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 2);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.datatype, "number");
|
||||
Assert.assertEquals(property1.name, "id");
|
||||
Assert.assertEquals(property1.defaultValue, "null");
|
||||
Assert.assertEquals(property1.baseType, "number");
|
||||
Assert.assertTrue(property1.hasMore);
|
||||
Assert.assertTrue(property1.required);
|
||||
Assert.assertTrue(property1.isNotContainer);
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "urls");
|
||||
Assert.assertEquals(property2.datatype, "Array<string>");
|
||||
Assert.assertEquals(property2.name, "urls");
|
||||
Assert.assertEquals(property2.baseType, "Array");
|
||||
Assert.assertNull(property2.hasMore);
|
||||
Assert.assertNull(property2.required);
|
||||
Assert.assertTrue(property2.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with complex property")
|
||||
public void complexPropertyTest() {
|
||||
final Model model = new ModelImpl()
|
||||
.description("a sample model")
|
||||
.property("children", new RefProperty("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen();
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.datatype, "model.Children");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.defaultValue, "null");
|
||||
Assert.assertEquals(property1.baseType, "model.Children");
|
||||
Assert.assertNull(property1.required);
|
||||
Assert.assertTrue(property1.isNotContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with complex list property")
|
||||
public void complexListPropertyTest() {
|
||||
final Model model = new ModelImpl()
|
||||
.description("a sample model")
|
||||
.property("children", new ArrayProperty()
|
||||
.items(new RefProperty("#/definitions/Children")));
|
||||
final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen();
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.complexType, "model.Children");
|
||||
Assert.assertEquals(property1.datatype, "Array<model.Children>");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "Array");
|
||||
Assert.assertNull(property1.required);
|
||||
Assert.assertTrue(property1.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert an array model")
|
||||
public void arrayModelTest() {
|
||||
final Model model = new ArrayModel()
|
||||
.description("an array model")
|
||||
.items(new RefProperty("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen();
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "an array model");
|
||||
Assert.assertEquals(cm.vars.size(), 0);
|
||||
}
|
||||
|
||||
@Test(description = "convert a map model")
|
||||
public void mapModelTest() {
|
||||
final Model model = new ModelImpl()
|
||||
.description("a map model")
|
||||
.additionalProperties(new RefProperty("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen();
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a map model");
|
||||
Assert.assertEquals(cm.vars.size(), 0);
|
||||
Assert.assertEquals(cm.imports.size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("model.Children")).size(), 1);
|
||||
}
|
||||
}
|
236
samples/client/petstore/typescript-angular2/api/PetApi.ts
Normal file
236
samples/client/petstore/typescript-angular2/api/PetApi.ts
Normal file
@ -0,0 +1,236 @@
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http';
|
||||
import {Injectable} from 'angular2/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as model from "../model/model.d.ts"
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
'use strict';
|
||||
|
||||
@Injectable()
|
||||
export class PetApi {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
*/
|
||||
public addPet (body?: model.Pet, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
*/
|
||||
public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling deletePet');
|
||||
}
|
||||
headerParams.set('api_key', apiKey);
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'DELETE',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* Multiple status values can be provided with comma seperated strings
|
||||
* @param status Status values that need to be considered for filter
|
||||
*/
|
||||
public findPetsByStatus (status?: model.Array<string>, extraHttpRequestParams?: any ) : Observable<Array<model.Pet>> {
|
||||
const path = this.basePath + '/pet/findByStatus';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
if (status !== undefined) {
|
||||
queryParameters['status'] = status;
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
* @param tags Tags to filter by
|
||||
*/
|
||||
public findPetsByTags (tags?: model.Array<string>, extraHttpRequestParams?: any ) : Observable<Array<model.Pet>> {
|
||||
const path = this.basePath + '/pet/findByTags';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
if (tags !== undefined) {
|
||||
queryParameters['tags'] = tags;
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
* @param petId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getPetById (petId: number, extraHttpRequestParams?: any ) : Observable<model.Pet> {
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling getPetById');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
*/
|
||||
public updatePet (body?: model.Pet, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'PUT',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
* @param petId ID of pet that needs to be updated
|
||||
* @param name Updated name of the pet
|
||||
* @param status Updated status of the pet
|
||||
*/
|
||||
public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let formParams = new URLSearchParams();
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling updatePetWithForm');
|
||||
}
|
||||
headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
formParams['name'] = name;
|
||||
|
||||
formParams['status'] = status;
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = formParams.toString();
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads an image
|
||||
*
|
||||
* @param petId ID of pet to update
|
||||
* @param additionalMetadata Additional data to pass to server
|
||||
* @param file file to upload
|
||||
*/
|
||||
public uploadFile (petId: number, additionalMetadata?: string, file?: model.any, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet/{petId}/uploadImage'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let formParams = new URLSearchParams();
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling uploadFile');
|
||||
}
|
||||
headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
formParams['additionalMetadata'] = additionalMetadata;
|
||||
|
||||
formParams['file'] = file;
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = formParams.toString();
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
}
|
111
samples/client/petstore/typescript-angular2/api/StoreApi.ts
Normal file
111
samples/client/petstore/typescript-angular2/api/StoreApi.ts
Normal file
@ -0,0 +1,111 @@
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http';
|
||||
import {Injectable} from 'angular2/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as model from "../model/model.d.ts"
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
'use strict';
|
||||
|
||||
@Injectable()
|
||||
export class StoreApi {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
*/
|
||||
public deleteOrder (orderId: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
// verify required parameter 'orderId' is set
|
||||
if (!orderId) {
|
||||
throw new Error('Missing required parameter orderId when calling deleteOrder');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'DELETE',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
*/
|
||||
public getInventory (extraHttpRequestParams?: any ) : Observable<{ [key: string]: number; }> {
|
||||
const path = this.basePath + '/store/inventory';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getOrderById (orderId: string, extraHttpRequestParams?: any ) : Observable<model.Order> {
|
||||
const path = this.basePath + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
// verify required parameter 'orderId' is set
|
||||
if (!orderId) {
|
||||
throw new Error('Missing required parameter orderId when calling getOrderById');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
* @param body order placed for purchasing the pet
|
||||
*/
|
||||
public placeOrder (body?: model.Order, extraHttpRequestParams?: any ) : Observable<model.Order> {
|
||||
const path = this.basePath + '/store/order';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
}
|
209
samples/client/petstore/typescript-angular2/api/UserApi.ts
Normal file
209
samples/client/petstore/typescript-angular2/api/UserApi.ts
Normal file
@ -0,0 +1,209 @@
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http';
|
||||
import {Injectable} from 'angular2/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as model from "../model/model.d.ts"
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
'use strict';
|
||||
|
||||
@Injectable()
|
||||
export class UserApi {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
* @param body Created user object
|
||||
*/
|
||||
public createUser (body?: model.User, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* @param body List of user object
|
||||
*/
|
||||
public createUsersWithArrayInput (body?: model.Array<model.User>, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/createWithArray';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* @param body List of user object
|
||||
*/
|
||||
public createUsersWithListInput (body?: model.Array<model.User>, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/createWithList';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
* This can only be done by the logged in user.
|
||||
* @param username The name that needs to be deleted
|
||||
*/
|
||||
public deleteUser (username: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling deleteUser');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'DELETE',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||
*/
|
||||
public getUserByName (username: string, extraHttpRequestParams?: any ) : Observable<model.User> {
|
||||
const path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling getUserByName');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
* @param username The user name for login
|
||||
* @param password The password for login in clear text
|
||||
*/
|
||||
public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : Observable<string> {
|
||||
const path = this.basePath + '/user/login';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
if (username !== undefined) {
|
||||
queryParameters['username'] = username;
|
||||
}
|
||||
|
||||
if (password !== undefined) {
|
||||
queryParameters['password'] = password;
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*/
|
||||
public logoutUser (extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/logout';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated user
|
||||
* This can only be done by the logged in user.
|
||||
* @param username name that need to be deleted
|
||||
* @param body Updated user object
|
||||
*/
|
||||
public updateUser (username: string, body?: model.User, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling updateUser');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'PUT',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map(response => response.json());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
import * as model from "./model.d.ts"
|
||||
|
||||
export interface Category {
|
||||
|
||||
|
||||
id?: number;
|
||||
|
||||
|
||||
name?: string;
|
||||
}
|
||||
|
35
samples/client/petstore/typescript-angular2/model/Order.ts
Normal file
35
samples/client/petstore/typescript-angular2/model/Order.ts
Normal file
@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
import * as model from "./model.d.ts"
|
||||
|
||||
export interface Order {
|
||||
|
||||
|
||||
id?: number;
|
||||
|
||||
|
||||
petId?: number;
|
||||
|
||||
|
||||
quantity?: number;
|
||||
|
||||
|
||||
shipDate?: Date;
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
|
||||
status?: Order.StatusEnum;
|
||||
|
||||
|
||||
complete?: boolean;
|
||||
}
|
||||
|
||||
export namespace Order {
|
||||
|
||||
export enum StatusEnum {
|
||||
placed = <any> 'placed',
|
||||
approved = <any> 'approved',
|
||||
delivered = <any> 'delivered',
|
||||
}
|
||||
}
|
35
samples/client/petstore/typescript-angular2/model/Pet.ts
Normal file
35
samples/client/petstore/typescript-angular2/model/Pet.ts
Normal file
@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
import * as model from "./model.d.ts"
|
||||
|
||||
export interface Pet {
|
||||
|
||||
|
||||
id?: number;
|
||||
|
||||
|
||||
category?: model.Category;
|
||||
|
||||
|
||||
name?: string;
|
||||
|
||||
|
||||
photoUrls?: Array<string>;
|
||||
|
||||
|
||||
tags?: Array<model.Tag>;
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
|
||||
status?: Pet.StatusEnum;
|
||||
}
|
||||
|
||||
export namespace Pet {
|
||||
|
||||
export enum StatusEnum {
|
||||
available = <any> 'available',
|
||||
pending = <any> 'pending',
|
||||
sold = <any> 'sold',
|
||||
}
|
||||
}
|
12
samples/client/petstore/typescript-angular2/model/Tag.ts
Normal file
12
samples/client/petstore/typescript-angular2/model/Tag.ts
Normal file
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
import * as model from "./model.d.ts"
|
||||
|
||||
export interface Tag {
|
||||
|
||||
|
||||
id?: number;
|
||||
|
||||
|
||||
name?: string;
|
||||
}
|
||||
|
33
samples/client/petstore/typescript-angular2/model/User.ts
Normal file
33
samples/client/petstore/typescript-angular2/model/User.ts
Normal file
@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
import * as model from "./model.d.ts"
|
||||
|
||||
export interface User {
|
||||
|
||||
|
||||
id?: number;
|
||||
|
||||
|
||||
username?: string;
|
||||
|
||||
|
||||
firstName?: string;
|
||||
|
||||
|
||||
lastName?: string;
|
||||
|
||||
|
||||
email?: string;
|
||||
|
||||
|
||||
password?: string;
|
||||
|
||||
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* User Status
|
||||
*/
|
||||
|
||||
userStatus?: number;
|
||||
}
|
||||
|
13
samples/client/petstore/typescript-angular2/model/model.d.ts
vendored
Normal file
13
samples/client/petstore/typescript-angular2/model/model.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
export * from './Category';
|
||||
export * from './Order';
|
||||
export * from './Pet';
|
||||
export * from './Tag';
|
||||
export * from './User';
|
||||
|
||||
|
||||
|
||||
export * from '../api/PetApi';
|
||||
export * from '../api/StoreApi';
|
||||
export * from '../api/UserApi';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user