mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
WIP: new javascript flowtyped generator (#176)
New Javascript flowtyped generator
This commit is contained in:
parent
c01f4bf220
commit
a0bfe2bf72
@ -128,4 +128,4 @@ after_success:
|
||||
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME && echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME"; fi; fi
|
||||
|
||||
env:
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test
|
||||
|
@ -46,7 +46,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
|
||||
| | Languages/Frameworks |
|
||||
|-|-|
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 6.x), Aurelia, Fetch, Inversify, jQuery, Node)
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 6.x), Aurelia, Fetch, Inversify, jQuery, Node)
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin**, **PHP** (Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), Scalatra)
|
||||
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||
@ -477,6 +477,7 @@ Here is a list of template creators:
|
||||
* Java (Rest-assured): @viclovsky
|
||||
* Javascript/NodeJS: @jfiala
|
||||
* Javascript (Closure-annotated Angular) @achew22
|
||||
* Javascript (Flow types) @jaypea
|
||||
* JMeter: @davidkiss
|
||||
* Kotlin: @jimschubert
|
||||
* Lua: @daurnimator
|
||||
|
32
bin/javascript-flowtyped-petstore.sh
Executable file
32
bin/javascript-flowtyped-petstore.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
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/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B 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 -t modules/openapi-generator/src/main/resources/Javascript-Flowtyped -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g javascript-flowtyped -o samples/client/petstore/javascript-flowtyped -DappName=PetstoreClient $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm");
|
||||
|
||||
public static final String NPM_NAME = "npmName";
|
||||
public static final String NPM_VERSION = "npmVersion";
|
||||
public static final String NPM_REPOSITORY = "npmRepository";
|
||||
public static final String SNAPSHOT = "snapshot";
|
||||
|
||||
protected String npmName = null;
|
||||
protected String npmVersion = "1.0.0";
|
||||
protected String npmRepository = null;
|
||||
|
||||
public JavascriptFlowtypedClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as TS does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
setReservedWordsLowerCase(Arrays.asList(
|
||||
// local variable names used in API methods (endpoints)
|
||||
"varLocalPath", "queryParameters", "headerParams", "formParams", "useFormData", "varLocalDeferred",
|
||||
"requestOptions",
|
||||
// Typescript reserved words
|
||||
"abstract", "arguments", "boolean", "break", "byte",
|
||||
"case", "catch", "char", "class", "const",
|
||||
"continue", "debugger", "default", "delete", "do",
|
||||
"double", "else", "enum", "eval", "export",
|
||||
"extends", "false", "final", "finally", "float",
|
||||
"for", "function", "goto", "if", "implements",
|
||||
"import", "in", "instanceof", "int", "interface",
|
||||
"let", "long", "native", "new", "null",
|
||||
"package", "private", "protected", "public", "return",
|
||||
"short", "static", "super", "switch", "synchronized",
|
||||
"this", "throw", "throws", "transient", "true",
|
||||
"try", "typeof", "var", "void", "volatile",
|
||||
"while", "with", "yield",
|
||||
"Array", "Date", "eval", "function", "hasOwnProperty",
|
||||
"Infinity", "isFinite", "isNaN", "isPrototypeOf",
|
||||
"Math", "NaN", "Number", "Object",
|
||||
"prototype", "String", "toString", "undefined", "valueOf"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList("string", "boolean", "number", "Array", "Object", "Date", "File", "Blob")
|
||||
);
|
||||
|
||||
instantiationTypes.put("array", "Array");
|
||||
instantiationTypes.put("list", "Array");
|
||||
instantiationTypes.put("map", "Object");
|
||||
typeMapping.clear();
|
||||
typeMapping.put("array", "Array");
|
||||
typeMapping.put("map", "Object");
|
||||
typeMapping.put("List", "Array");
|
||||
typeMapping.put("boolean", "boolean");
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("int", "number");
|
||||
typeMapping.put("float", "number");
|
||||
typeMapping.put("number", "number");
|
||||
typeMapping.put("DateTime", "Date");
|
||||
typeMapping.put("date", "Date");
|
||||
typeMapping.put("long", "number");
|
||||
typeMapping.put("short", "number");
|
||||
typeMapping.put("char", "string");
|
||||
typeMapping.put("double", "number");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("integer", "number");
|
||||
// file, binary not supported in JS client right now, using String as a workaround
|
||||
typeMapping.put("file", "string");
|
||||
typeMapping.put("binary", "string");
|
||||
typeMapping.put("ByteArray", "string");
|
||||
typeMapping.put("UUID", "string");
|
||||
|
||||
defaultIncludes = new HashSet<String>(languageSpecificPrimitives);
|
||||
outputFolder = "generated-code/javascript-flowtyped";
|
||||
embeddedTemplateDir = templateDir = "Javascript-Flowtyped";
|
||||
|
||||
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package"));
|
||||
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package"));
|
||||
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
||||
this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
|
||||
codegenModel.additionalPropertiesType = getTypeDeclaration((Schema) schema.getAdditionalProperties());
|
||||
addImport(codegenModel, codegenModel.additionalPropertiesType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "src", "index.js"));
|
||||
supportingFiles.add(new SupportingFile("api.mustache", "src", "api.js"));
|
||||
supportingFiles.add(new SupportingFile("configuration.mustache", "src", "configuration.js"));
|
||||
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
|
||||
|
||||
addNpmPackageGeneration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
Schema inner;
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
inner = ((ArraySchema) p).getItems();
|
||||
return this.getSchemaType(p) + "<" + this.getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
inner = (Schema) p.getAdditionalProperties();
|
||||
return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }";
|
||||
} else if (ModelUtils.isFileSchema(p)) {
|
||||
return "any";
|
||||
} else if (ModelUtils.isBinarySchema(p)) {
|
||||
return "any";
|
||||
} else {
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
}
|
||||
|
||||
private void addNpmPackageGeneration() {
|
||||
if (additionalProperties.containsKey(NPM_NAME)) {
|
||||
this.setNpmName(additionalProperties.get(NPM_NAME).toString());
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(NPM_VERSION)) {
|
||||
this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString());
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
|
||||
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
|
||||
}
|
||||
additionalProperties.put(NPM_VERSION, npmVersion);
|
||||
|
||||
if (additionalProperties.containsKey(NPM_REPOSITORY)) {
|
||||
this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString());
|
||||
}
|
||||
|
||||
//Files for building our lib
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
||||
supportingFiles.add(new SupportingFile("flowconfig.mustache", "", ".flowconfig"));
|
||||
supportingFiles.add(new SupportingFile("babelrc", "", ".babelrc"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
super.preprocessOpenAPI(openAPI);
|
||||
|
||||
if (openAPI.getInfo() != null) {
|
||||
Info info = openAPI.getInfo();
|
||||
if (StringUtils.isBlank(npmName) && info.getTitle() != null) {
|
||||
// when projectName is not specified, generate it from info.title
|
||||
npmName = sanitizeName(dashize(info.getTitle()));
|
||||
}
|
||||
if (StringUtils.isBlank(npmVersion)) {
|
||||
// when projectVersion is not specified, use info.version
|
||||
npmVersion = escapeUnsafeCharacters(escapeQuotationMark(info.getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
// default values
|
||||
if (StringUtils.isBlank(npmName)) {
|
||||
npmName = "openapi-js-client";
|
||||
}
|
||||
if (StringUtils.isBlank(npmVersion)) {
|
||||
npmVersion = "1.0.0";
|
||||
}
|
||||
|
||||
additionalProperties.put(NPM_NAME, npmName);
|
||||
additionalProperties.put(NPM_VERSION, npmVersion);
|
||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
// process enum in models
|
||||
List<Object> models = (List<Object>) postProcessModelsEnum(objs).get("models");
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
cm.imports = new TreeSet(cm.imports);
|
||||
// name enum with model name, e.g. StatusEnum => Pet.StatusEnum
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
if (Boolean.TRUE.equals(var.isEnum)) {
|
||||
var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + "" + var.enumName);
|
||||
}
|
||||
}
|
||||
if (cm.parent != null) {
|
||||
for (CodegenProperty var : cm.allVars) {
|
||||
if (Boolean.TRUE.equals(var.isEnum)) {
|
||||
var.datatypeWithEnum = var.datatypeWithEnum
|
||||
.replace(var.enumName, cm.classname + "" + var.enumName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove ', " to avoid code injection
|
||||
return input.replace("\"", "").replace("'", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "javascript-flowtyped";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Javascript client library (beta) using Flow types and Fetch API.";
|
||||
}
|
||||
|
||||
public String getNpmName() {
|
||||
return npmName;
|
||||
}
|
||||
|
||||
public void setNpmName(String npmName) {
|
||||
this.npmName = npmName;
|
||||
}
|
||||
|
||||
public String getNpmVersion() {
|
||||
return npmVersion;
|
||||
}
|
||||
|
||||
public void setNpmVersion(String npmVersion) {
|
||||
this.npmVersion = npmVersion;
|
||||
}
|
||||
|
||||
public String getNpmRepository() {
|
||||
return npmRepository;
|
||||
}
|
||||
|
||||
public void setNpmRepository(String npmRepository) {
|
||||
this.npmRepository = npmRepository;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
## {{npmName}}@{{npmVersion}}
|
||||
|
||||
This generator creates Flow typed JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:
|
||||
|
||||
Environment
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
|
||||
Language level
|
||||
* ES6
|
||||
|
||||
Module system
|
||||
* ES6 module system
|
||||
|
||||
### Building
|
||||
|
||||
To build an compile the flow typed sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### Consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of the following commands.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install {{npmName}}@{{npmVersion}} --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
@ -0,0 +1,266 @@
|
||||
// @flow
|
||||
/* eslint-disable no-use-before-define */
|
||||
{{>licenseInfo}}
|
||||
|
||||
import * as url from "url";
|
||||
import * as portableFetch from "portable-fetch";
|
||||
import { Configuration } from "./configuration";
|
||||
|
||||
const BASE_PATH: string = "{{{basePath}}}".replace(/\/+$/, "");
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const COLLECTION_FORMATS = {
|
||||
csv: ",",
|
||||
ssv: " ",
|
||||
tsv: "\t",
|
||||
pipes: "|",
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export type FetchAPI = {
|
||||
(url: string, init?: any): Promise<Response>;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export type FetchArgs = {
|
||||
url: string;
|
||||
options: {};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export type RequestOptions = {
|
||||
headers?: {};
|
||||
query?: {};
|
||||
body?: string | FormData;
|
||||
}
|
||||
|
||||
/**
|
||||
* * @export
|
||||
* @class RequiredError
|
||||
* @extends {Error}
|
||||
*/
|
||||
export class RequiredError extends Error {
|
||||
name:string = "RequiredError"
|
||||
constructor(field: string, msg?: string) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
{{#models}}
|
||||
{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}{{/model}}
|
||||
{{/models}}
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}
|
||||
/**
|
||||
* {{classname}} - fetch parameter creator{{#description}}
|
||||
* {{&description}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export const {{classname}}FetchParamCreator = function (configuration?: Configuration) {
|
||||
return {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: RequestOptions): FetchArgs {
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
// verify required parameter '{{paramName}}' is not null or undefined
|
||||
if ({{paramName}} === null || {{paramName}} === undefined) {
|
||||
throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
|
||||
}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
const localVarPath = `{{{path}}}`{{#pathParams}}
|
||||
.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}};
|
||||
const localVarUrlObj = url.parse(localVarPath, true);
|
||||
const localVarRequestOptions: RequestOptions = Object.assign({}, { method: '{{httpMethod}}' }, options);
|
||||
const localVarHeaderParameter = {};
|
||||
const localVarQueryParameter = {};
|
||||
{{#hasFormParams}}
|
||||
const localVarFormParams = new FormData();
|
||||
{{/hasFormParams}}
|
||||
|
||||
{{#authMethods}}
|
||||
// authentication {{name}} required
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInHeader}}
|
||||
if (configuration && configuration.apiKey) {
|
||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
||||
? configuration.apiKey("{{keyParamName}}")
|
||||
: configuration.apiKey;
|
||||
localVarHeaderParameter["{{keyParamName}}"] = localVarApiKeyValue;
|
||||
}
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
if (configuration && configuration.apiKey) {
|
||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
||||
? configuration.apiKey("{{keyParamName}}")
|
||||
: configuration.apiKey;
|
||||
localVarQueryParameter["{{keyParamName}}"] = localVarApiKeyValue;
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
// http basic authentication required
|
||||
if (configuration && (configuration.username || configuration.password)) {
|
||||
localVarHeaderParameter["Authorization"] = "Basic " + btoa(configuration.username + ":" + configuration.password);
|
||||
}
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
// oauth required
|
||||
if (configuration && configuration.accessToken) {
|
||||
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
||||
? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}])
|
||||
: configuration.accessToken;
|
||||
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
||||
}
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
||||
{{#queryParams}}
|
||||
{{#isListContainer}}
|
||||
if ({{paramName}}) {
|
||||
{{#isCollectionFormatMulti}}
|
||||
localVarQueryParameter['{{baseName}}'] = {{paramName}};
|
||||
{{/isCollectionFormatMulti}}
|
||||
{{^isCollectionFormatMulti}}
|
||||
localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
|
||||
{{/isCollectionFormatMulti}}
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
{{#isDateTime}}
|
||||
localVarQueryParameter['{{baseName}}'] = (({{paramName}}:any):Date).toISOString();
|
||||
{{/isDateTime}}
|
||||
{{^isDateTime}}
|
||||
{{#isDate}}
|
||||
localVarQueryParameter['{{baseName}}'] = (({{paramName}}:any):Date).toISOString();
|
||||
{{/isDate}}
|
||||
{{^isDate}}
|
||||
localVarQueryParameter['{{baseName}}'] = (({{paramName}}:any):string);
|
||||
{{/isDate}}
|
||||
{{/isDateTime}}
|
||||
}
|
||||
{{/isListContainer}}
|
||||
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
{{#isListContainer}}
|
||||
if ({{paramName}}) {
|
||||
localVarHeaderParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
if ({{paramName}} !== undefined && {{paramName}} !== null) {
|
||||
localVarHeaderParameter['{{baseName}}'] = (({{paramName}}:any):string);
|
||||
}
|
||||
{{/isListContainer}}
|
||||
|
||||
{{/headerParams}}
|
||||
{{#formParams}}
|
||||
{{#isListContainer}}
|
||||
if ({{paramName}}) {
|
||||
{{#isCollectionFormatMulti}}
|
||||
{{paramName}}.forEach((element) => {
|
||||
localVarFormParams.append('{{baseName}}', element);
|
||||
})
|
||||
{{/isCollectionFormatMulti}}
|
||||
{{^isCollectionFormatMulti}}
|
||||
localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]));
|
||||
{{/isCollectionFormatMulti}}
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
localVarFormParams.set('{{baseName}}', (({{paramName}}:any):string));
|
||||
}
|
||||
{{/isListContainer}}
|
||||
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}
|
||||
{{^consumes}}
|
||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||
{{/consumes}}
|
||||
{{#consumes.0}}
|
||||
localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}';
|
||||
{{/consumes.0}}
|
||||
|
||||
{{/bodyParam}}
|
||||
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
|
||||
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
||||
delete localVarUrlObj.search;
|
||||
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
|
||||
{{#hasFormParams}}
|
||||
localVarRequestOptions.body = localVarFormParams;
|
||||
{{/hasFormParams}}
|
||||
{{#bodyParam}}
|
||||
const needsSerialization = (typeof {{paramName}} !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
||||
localVarRequestOptions.body = needsSerialization ? JSON.stringify({{paramName}} || {}) : ((({{paramName}}:any):string) || "");
|
||||
{{/bodyParam}}
|
||||
|
||||
return {
|
||||
url: url.format(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
{{/operation}}
|
||||
}
|
||||
};
|
||||
|
||||
export type {{classname}}Type = { {{#operation}}
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>,
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
/**
|
||||
* {{classname}} - factory function to inject configuration {{#description}}
|
||||
* {{{description}}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export const {{classname}} = function(configuration?: Configuration, fetch: FetchAPI = portableFetch): {{classname}}Type {
|
||||
const basePath: string = (configuration && configuration.basePath) || BASE_PATH;
|
||||
return {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions = {}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> {
|
||||
const localVarFetchArgs = {{classname}}FetchParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options);
|
||||
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return response{{#returnType}}.json(){{/returnType}};
|
||||
} else {
|
||||
throw response;
|
||||
}
|
||||
});
|
||||
},
|
||||
{{/operation}}
|
||||
}
|
||||
};
|
||||
{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
export type ApiTypes = { {{#apiInfo}}{{#apis}}{{#operations}}
|
||||
{{classname}}: {{classname}}Type,
|
||||
{{/operations}}{{/apis}}{{/apiInfo}} }
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"presets": ["react-app"],
|
||||
"plugins": ["transform-flow-strip-types"]
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
// @flow
|
||||
{{>licenseInfo}}
|
||||
|
||||
export type ConfigurationParameters = {
|
||||
apiKey?: string | (name: string) => string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | (name: string, scopes?: string[]) => string;
|
||||
basePath?: string;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey: string | (name: string) => string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
username: string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
password: string;
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
accessToken: string | ((name: string, scopes?: string[]) => string);
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath: string;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
if (param.apiKey) {
|
||||
this.apiKey = param.apiKey;
|
||||
}
|
||||
if (param.username) {
|
||||
this.username = param.username;
|
||||
}
|
||||
if (param.password) {
|
||||
this.password = param.password;
|
||||
}
|
||||
if (param.accessToken) {
|
||||
this.accessToken = param.accessToken;
|
||||
}
|
||||
if (param.basePath) {
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
[ignore]
|
||||
|
||||
[include]
|
||||
|
||||
[libs]
|
||||
|
||||
[lints]
|
||||
|
||||
[options]
|
||||
|
||||
[strict]
|
@ -0,0 +1 @@
|
||||
node_modules
|
@ -0,0 +1,5 @@
|
||||
// @flow
|
||||
{{>licenseInfo}}
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* {{{appName}}}
|
||||
* {{{appDescription}}}
|
||||
*
|
||||
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
|
||||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||
*
|
||||
* 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.
|
||||
*/
|
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}};
|
@ -0,0 +1,27 @@
|
||||
{{#hasEnums}}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
|
||||
export type {{classname}}{{enumName}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}};
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{/hasEnums}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @export
|
||||
*/
|
||||
export type {{classname}} = {
|
||||
{{#additionalPropertiesType}}
|
||||
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
|
||||
|
||||
{{/additionalPropertiesType}}
|
||||
{{#vars}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
|
||||
* @memberof {{classname}}
|
||||
*/
|
||||
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
|
||||
{{/vars}}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "{{npmName}}",
|
||||
"version": "{{npmVersion}}",
|
||||
"description": "swagger client for {{npmName}}",
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"keywords": [
|
||||
"fetch",
|
||||
"flow",
|
||||
"swagger-client",
|
||||
"{{npmName}}"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"main": "./lib/index.js",
|
||||
"scripts": {
|
||||
"build": "npm run build:clean && npm run build:lib && npm run build:flow",
|
||||
"build:clean": "rimraf lib",
|
||||
"build:lib": "node_modules/.bin/babel -d lib src --ignore '**/__tests__/**'",
|
||||
"build:flow": "flow-copy-source -v -i '**/__tests__/**' src lib"
|
||||
},
|
||||
"dependencies": {
|
||||
"portable-fetch": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
||||
"babel-preset-react-app": "^3.1.1",
|
||||
"flow-copy-source": "^1.3.0",
|
||||
"rimraf": "^2.6.2"
|
||||
}{{#npmRepository}},{{/npmRepository}}
|
||||
{{#npmRepository}}
|
||||
"publishConfig":{
|
||||
"registry":"{{npmRepository}}"
|
||||
}
|
||||
{{/npmRepository}}
|
||||
}
|
@ -45,6 +45,7 @@ org.openapitools.codegen.languages.JavaResteasyServerCodegen
|
||||
org.openapitools.codegen.languages.JavaResteasyEapServerCodegen
|
||||
org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen
|
||||
org.openapitools.codegen.languages.JavascriptClientCodegen
|
||||
org.openapitools.codegen.languages.JavascriptFlowtypedClientCodegen
|
||||
org.openapitools.codegen.languages.JavascriptClosureAngularClientCodegen
|
||||
org.openapitools.codegen.languages.JMeterCodegen
|
||||
org.openapitools.codegen.languages.LuaClientCodegen
|
||||
|
1
pom.xml
1
pom.xml
@ -941,6 +941,7 @@
|
||||
<module>samples/client/petstore/javascript-es6</module>
|
||||
<module>samples/client/petstore/javascript-promise</module>
|
||||
<module>samples/client/petstore/javascript-promise-es6</module>
|
||||
<module>samples/client/petstore/javascript-flowtyped</module>
|
||||
<module>samples/client/petstore/python</module>
|
||||
<module>samples/client/petstore/python-tornado</module>
|
||||
<module>samples/client/petstore/python-asyncio</module>
|
||||
|
4
samples/client/petstore/javascript-flowtyped/.babelrc
Normal file
4
samples/client/petstore/javascript-flowtyped/.babelrc
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"presets": ["react-app"],
|
||||
"plugins": ["transform-flow-strip-types"]
|
||||
}
|
11
samples/client/petstore/javascript-flowtyped/.flowconfig
Normal file
11
samples/client/petstore/javascript-flowtyped/.flowconfig
Normal file
@ -0,0 +1,11 @@
|
||||
[ignore]
|
||||
|
||||
[include]
|
||||
|
||||
[libs]
|
||||
|
||||
[lints]
|
||||
|
||||
[options]
|
||||
|
||||
[strict]
|
1
samples/client/petstore/javascript-flowtyped/.gitignore
vendored
Normal file
1
samples/client/petstore/javascript-flowtyped/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# 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 OpenAPI Generator 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
|
@ -0,0 +1 @@
|
||||
3.0.0-SNAPSHOT
|
41
samples/client/petstore/javascript-flowtyped/README.md
Normal file
41
samples/client/petstore/javascript-flowtyped/README.md
Normal file
@ -0,0 +1,41 @@
|
||||
## open_api_petstore@1.0.0
|
||||
|
||||
This generator creates Flow typed JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:
|
||||
|
||||
Environment
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
|
||||
Language level
|
||||
* ES6
|
||||
|
||||
Module system
|
||||
* ES6 module system
|
||||
|
||||
### Building
|
||||
|
||||
To build an compile the flow typed sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### Consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of the following commands.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install open_api_petstore@1.0.0 --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
1193
samples/client/petstore/javascript-flowtyped/lib/api.js
Normal file
1193
samples/client/petstore/javascript-flowtyped/lib/api.js
Normal file
File diff suppressed because it is too large
Load Diff
1374
samples/client/petstore/javascript-flowtyped/lib/api.js.flow
Normal file
1374
samples/client/petstore/javascript-flowtyped/lib/api.js.flow
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,68 @@
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
export var Configuration =
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
function Configuration() {
|
||||
var param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
_classCallCheck(this, Configuration);
|
||||
|
||||
if (param.apiKey) {
|
||||
this.apiKey = param.apiKey;
|
||||
}
|
||||
if (param.username) {
|
||||
this.username = param.username;
|
||||
}
|
||||
if (param.password) {
|
||||
this.password = param.password;
|
||||
}
|
||||
if (param.accessToken) {
|
||||
this.accessToken = param.accessToken;
|
||||
}
|
||||
if (param.basePath) {
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
;
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*/
|
@ -0,0 +1,76 @@
|
||||
// @flow
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
export type ConfigurationParameters = {
|
||||
apiKey?: string | (name: string) => string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | (name: string, scopes?: string[]) => string;
|
||||
basePath?: string;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey: string | (name: string) => string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
username: string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
password: string;
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
accessToken: string | ((name: string, scopes?: string[]) => string);
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath: string;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
if (param.apiKey) {
|
||||
this.apiKey = param.apiKey;
|
||||
}
|
||||
if (param.username) {
|
||||
this.username = param.username;
|
||||
}
|
||||
if (param.password) {
|
||||
this.password = param.password;
|
||||
}
|
||||
if (param.accessToken) {
|
||||
this.accessToken = param.accessToken;
|
||||
}
|
||||
if (param.basePath) {
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
}
|
||||
}
|
15
samples/client/petstore/javascript-flowtyped/lib/index.js
Normal file
15
samples/client/petstore/javascript-flowtyped/lib/index.js
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
@ -0,0 +1,16 @@
|
||||
// @flow
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
4052
samples/client/petstore/javascript-flowtyped/package-lock.json
generated
Normal file
4052
samples/client/petstore/javascript-flowtyped/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
samples/client/petstore/javascript-flowtyped/package.json
Normal file
31
samples/client/petstore/javascript-flowtyped/package.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "open_api_petstore",
|
||||
"version": "1.0.0",
|
||||
"description": "swagger client for open_api_petstore",
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"keywords": [
|
||||
"fetch",
|
||||
"flow",
|
||||
"swagger-client",
|
||||
"open_api_petstore"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"main": "./lib/index.js",
|
||||
"scripts": {
|
||||
"build": "npm run build:clean && npm run build:lib && npm run build:flow",
|
||||
"build:clean": "rimraf lib",
|
||||
"build:lib": "node_modules/.bin/babel -d lib src --ignore '**/__tests__/**'",
|
||||
"build:flow": "flow-copy-source -v -i '**/__tests__/**' src lib"
|
||||
},
|
||||
"dependencies": {
|
||||
"portable-fetch": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
||||
"babel-preset-react-app": "^3.1.1",
|
||||
"flow-copy-source": "^1.3.0",
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
46
samples/client/petstore/javascript-flowtyped/pom.xml
Normal file
46
samples/client/petstore/javascript-flowtyped/pom.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-petstore-javascript-flowtyped</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>Petstore JS Flowtyped Client</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>npm-install</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>npm</executable>
|
||||
<arguments>
|
||||
<argument>install</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>mocha</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>npm</executable>
|
||||
<arguments>
|
||||
<argument>run</argument>
|
||||
<argument>build</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
1374
samples/client/petstore/javascript-flowtyped/src/api.js
Normal file
1374
samples/client/petstore/javascript-flowtyped/src/api.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,76 @@
|
||||
// @flow
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
export type ConfigurationParameters = {
|
||||
apiKey?: string | (name: string) => string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | (name: string, scopes?: string[]) => string;
|
||||
basePath?: string;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey: string | (name: string) => string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
username: string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
password: string;
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
accessToken: string | ((name: string, scopes?: string[]) => string);
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath: string;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
if (param.apiKey) {
|
||||
this.apiKey = param.apiKey;
|
||||
}
|
||||
if (param.username) {
|
||||
this.username = param.username;
|
||||
}
|
||||
if (param.password) {
|
||||
this.password = param.password;
|
||||
}
|
||||
if (param.accessToken) {
|
||||
this.accessToken = param.accessToken;
|
||||
}
|
||||
if (param.basePath) {
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
}
|
||||
}
|
16
samples/client/petstore/javascript-flowtyped/src/index.js
Normal file
16
samples/client/petstore/javascript-flowtyped/src/index.js
Normal file
@ -0,0 +1,16 @@
|
||||
// @flow
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
Loading…
Reference in New Issue
Block a user