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

Allow optionally passing spec object into init to override it. #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions src/gen/js/service.js.template
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Auto-generated, edits will be overwritten
import spec from './spec';;
import specification from './spec';;

export class ServiceError extends Error {}

let options = {};;
let spec = specification;;

export function init(serviceOptions) {
export function init(serviceOptions, apiSpec = spec) {
options = serviceOptions;;
spec = apiSpec;;
}

export function request(op, parameters, attempt) {
Expand Down
6 changes: 4 additions & 2 deletions src/gen/js/service.ts.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference path="../types.ts"/>
// Auto-generated, edits will be overwritten
import spec from './spec';;
import specification from './spec';;

export class ServiceError extends Error implements api.ServiceError {
status: number;;
Expand All @@ -9,9 +9,11 @@ export class ServiceError extends Error implements api.ServiceError {
}

let options: api.ServiceOptions = {};;
let spec = specification;;

export function init(serviceOptions: api.ServiceOptions) {
export function init(serviceOptions: api.ServiceOptions, apiSpec = spec) {
options = serviceOptions;;
spec = apiSpec;;
}

export function request(op: api.OperationInfo, parameters?: api.OperationParamGroups, attempt = 1): Promise<any> {
Expand Down