Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts"));
supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts"));
supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts"));
supportingFiles.add(new SupportingFile("variables.mustache", getIndexDirectory(), "variables.ts"));
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@ npm install PATH_TO_GENERATED_PACKAGE --save
In your angular2 project:

TODO: paste example.

### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service.

```
import { BASE_PATH } from './path-to-swagger-gen-service/index';

bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]);
```
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{{>licenseInfo}}
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
import {Injectable, Optional} from '@angular/core';
import {Inject, Injectable, Optional} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import * as models from '../model/models';
import {BASE_PATH} from '../variables';
import 'rxjs/Rx';

/* tslint:disable:no-unused-variable member-ordering */
Expand All @@ -20,7 +21,7 @@ export class {{classname}} {
protected basePath = '{{basePath}}';
public defaultHeaders : Headers = new Headers();

constructor(protected http: Http, @Optional() basePath: string) {
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
if (basePath) {
this.basePath = basePath;
}
Expand All @@ -32,7 +33,7 @@ export class {{classname}} {
* {{notes}}
{{#allParams}}* @param {{paramName}} {{description}}
{{/allParams}}*/
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> {
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}};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './api/api';
export * from './model/models';
export * from './model/models';
export * from './variables';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { OpaqueToken } from '@angular/core';

export const BASE_PATH = new OpaqueToken('basePath');