forked from loafle/openapi-generator-original
Ensured up to date
This commit is contained in:
@@ -27,6 +27,11 @@ 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"
|
||||
echo "Creating default (fetch) client!"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/default $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
echo "Creating jquery client!"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript -o samples/client/petstore/typescript/builds/jquery --additional-properties=framework=jquery,fileContentDataType=Blob $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -139,7 +139,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
frameworkOption.addEnum(option, option);
|
||||
}
|
||||
frameworkOption.defaultValue(FRAMEWORKS[0]);
|
||||
System.out.println("Added framework option");
|
||||
|
||||
cliOptions.add(frameworkOption);
|
||||
|
||||
|
||||
@@ -196,7 +196,8 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
objs.put("framework", additionalProperties.get(FRAMEWORK_SWITCH));
|
||||
objs.put("frameworks", frameworks);
|
||||
|
||||
objs.put("fileContentDataType", additionalProperties.get(FILE_CONTENT_DATA_TYPE));
|
||||
Object propDataType = additionalProperties.get(FILE_CONTENT_DATA_TYPE);
|
||||
objs.put("fileContentDataType", propDataType == null ? "Buffer" : propDataType);
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"license": "Unlicense",
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts" : {
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
|
||||
@@ -18,6 +18,7 @@ import { Configuration } from '../configuration';
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
|
||||
export class StoreApi {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders: Array<string> = [];
|
||||
|
||||
@@ -5,7 +5,6 @@ import * as FormData from "form-data";
|
||||
import * as URLParse from "url-parse";
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
|
||||
export * from './isomorphic-fetch';
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
"dependencies": {
|
||||
"es6-promise": "^4.2.4",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"btoa": "^1.2.1",
|
||||
"@types/isomorphic-fetch": "0.0.34",
|
||||
"btoa": "^1.2.1",
|
||||
"form-data": "^2.3.2",
|
||||
"@types/form-data": "^2.2.1",
|
||||
"url-parse": "^1.4.3",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"noLib": false,
|
||||
"lib": [ "es6"]
|
||||
"lib": [ "es6", "dom" ]
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import {HttpLibrary, RequestContext, ResponseContext} from './http';
|
||||
import * as e6p from 'es6-promise'
|
||||
import { from, Observable } from 'rxjs';
|
||||
e6p.polyfill();
|
||||
import 'isomorphic-fetch';
|
||||
|
||||
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
|
||||
|
||||
public send(request: RequestContext): Observable<ResponseContext> {
|
||||
let method = request.getHttpMethod().toString();
|
||||
let body = request.getBody();
|
||||
|
||||
const resultPromise = fetch(request.getUrl(), {
|
||||
method: method,
|
||||
body: body as any,
|
||||
headers: request.getHeaders(),
|
||||
credentials: "same-origin"
|
||||
}).then((resp) => {
|
||||
// hack
|
||||
let headers = (resp.headers as any)._headers;
|
||||
for (let key in headers) {
|
||||
headers[key] = (headers[key] as Array<string>).join("; ");
|
||||
}
|
||||
|
||||
return resp.text().then((body: string) => {
|
||||
return new ResponseContext(resp.status, headers, body)
|
||||
});
|
||||
});
|
||||
|
||||
return from(resultPromise);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user