forked from loafle/openapi-generator-original
[typescript-axios] Implement useSingleRequestParameter option (#6288)
* Changes in mustache file to include new option - New options `useSingleRequestParameter` to use a single param for the request, instead of one param per request param. * Chanes in the documentation Include new parameter `useSingleRequestParameter`. Default value = `false` to keep compatibility with previous versions. * Include script to generate samples Also included script in the script that runs all * Generate new samples - Previous samples have a minor change (one line is deleted) - New sample generated with the new parameter set to true * Include scripts for windows * Include new CLI option in codegenerator class * Change the order for the new parameter in the docs
This commit is contained in:
@@ -4,5 +4,6 @@
|
||||
./bin/typescript-axios-petstore-with-npm-version.sh
|
||||
./bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.sh
|
||||
./bin/typescript-axios-petstore-with-complex-headers.sh
|
||||
./bin/typescript-axios-petstore-with-single-request-parameters.sh
|
||||
./bin/typescript-axios-petstore-interfaces.sh
|
||||
./bin/typescript-axios-petstore.sh
|
||||
|
||||
32
bin/typescript-axios-petstore-with-single-request-parameters.sh
Executable file
32
bin/typescript-axios-petstore-with-single-request-parameters.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} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/with-single-request-parameters --additional-properties useSingleRequestParameter=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -3,6 +3,7 @@
|
||||
call bin\windows\typescript-axios-petstore.bat
|
||||
call bin\windows\typescript-axios-petstore-target-es6.bat
|
||||
call bin\windows\typescript-axios-petstore-with-complex-headers.bat
|
||||
call bin\windows\typescript-axios-petstore-with-single-request-parameters.bat
|
||||
call bin\windows\typescript-axios-petstore-with-npm-version.bat
|
||||
call bin\windows\typescript-axios-petstore-interfaces.bat
|
||||
call bin\windows\typescript-axios-petstore-with-npm-version-and-separate-models-and-api.bat
|
||||
12
bin/windows/typescript-axios-petstore-with-single-request-parameters.bat
Executable file
12
bin/windows/typescript-axios-petstore-with-single-request-parameters.bat
Executable file
@@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\with-single-request-parameters --additional-properties useSingleRequestParameter=true
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -20,6 +20,7 @@ sidebar_label: typescript-axios
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|supportsES6|Generate code that conforms to ES6.| |false|
|
||||
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false|
|
||||
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|
||||
|withSeparateModelsAndApi|Put the model and api in separate folders and in separate classes| |false|
|
||||
|withoutPrefixEnums|Don't prefix enum names with class names| |false|
|
||||
|
||||
@@ -36,6 +36,7 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
|
||||
public static final String WITH_INTERFACES = "withInterfaces";
|
||||
public static final String SEPARATE_MODELS_AND_API = "withSeparateModelsAndApi";
|
||||
public static final String WITHOUT_PREFIX_ENUMS = "withoutPrefixEnums";
|
||||
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
|
||||
|
||||
protected String npmRepository = null;
|
||||
|
||||
@@ -57,6 +58,7 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(SEPARATE_MODELS_AND_API, "Put the model and api in separate folders and in separate classes", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(WITHOUT_PREFIX_ENUMS, "Don't prefix enum names with class names", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(USE_SINGLE_REQUEST_PARAMETER, "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,7 +207,7 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Apply the model file name to the imports as well
|
||||
for (Map<String, String> m : (List<Map<String, String>>) objs.get("imports")) {
|
||||
String javaImport = m.get("import").substring(modelPackage.length() + 1);
|
||||
|
||||
@@ -292,6 +292,31 @@ export interface {{classname}}Interface {
|
||||
}
|
||||
|
||||
{{/withInterfaces}}
|
||||
{{#useSingleRequestParameter}}
|
||||
{{#operation}}
|
||||
{{#allParams.0}}
|
||||
/**
|
||||
* Request parameters for {{nickname}} operation in {{classname}}.
|
||||
* @export
|
||||
* @interface {{classname}}{{operationIdCamelCase}}Request
|
||||
*/
|
||||
export interface {{classname}}{{operationIdCamelCase}}Request {
|
||||
{{#allParams}}
|
||||
/**
|
||||
* {{description}}
|
||||
* @type {{=<% %>=}}{<%&dataType%>}<%={{ }}=%>
|
||||
* @memberof {{classname}}{{operationIdCamelCase}}
|
||||
*/
|
||||
readonly {{paramName}}{{^required}}?{{/required}}: {{{dataType}}}
|
||||
{{^-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/allParams}}
|
||||
}
|
||||
|
||||
{{/allParams.0}}
|
||||
{{/operation}}
|
||||
{{/useSingleRequestParameter}}
|
||||
/**
|
||||
* {{classname}} - object-oriented interface{{#description}}
|
||||
* {{{description}}}{{/description}}
|
||||
@@ -311,17 +336,33 @@ export class {{classname}} extends BaseAPI {
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#useSingleRequestParameter}}
|
||||
{{#allParams.0}}
|
||||
* @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters.
|
||||
{{/allParams.0}}
|
||||
{{/useSingleRequestParameter}}
|
||||
{{^useSingleRequestParameter}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
{{/useSingleRequestParameter}}
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof {{classname}}
|
||||
*/
|
||||
{{#useSingleRequestParameter}}
|
||||
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request, {{/allParams.0}}options?: any) {
|
||||
return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
{{/useSingleRequestParameter}}
|
||||
{{^useSingleRequestParameter}}
|
||||
public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) {
|
||||
return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
{{/useSingleRequestParameter}}
|
||||
{{^-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
|
||||
@@ -986,7 +986,6 @@ export class PetApi extends BaseAPI {
|
||||
public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) {
|
||||
return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1313,7 +1312,6 @@ export class StoreApi extends BaseAPI {
|
||||
public placeOrder(body: Order, options?: any) {
|
||||
return StoreApiFp(this.configuration).placeOrder(body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1953,7 +1951,6 @@ export class UserApi extends BaseAPI {
|
||||
public updateUser(username: string, body: User, options?: any) {
|
||||
return UserApiFp(this.configuration).updateUser(username, body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -986,7 +986,6 @@ export class PetApi extends BaseAPI {
|
||||
public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) {
|
||||
return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1313,7 +1312,6 @@ export class StoreApi extends BaseAPI {
|
||||
public placeOrder(body: Order, options?: any) {
|
||||
return StoreApiFp(this.configuration).placeOrder(body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1953,7 +1951,6 @@ export class UserApi extends BaseAPI {
|
||||
public updateUser(username: string, body: User, options?: any) {
|
||||
return UserApiFp(this.configuration).updateUser(username, body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1041,7 +1041,6 @@ export class PetApi extends BaseAPI {
|
||||
public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) {
|
||||
return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1368,7 +1367,6 @@ export class StoreApi extends BaseAPI {
|
||||
public placeOrder(order: Order, options?: any) {
|
||||
return StoreApiFp(this.configuration).placeOrder(order, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2008,7 +2006,6 @@ export class UserApi extends BaseAPI {
|
||||
public updateUser(username: string, user: User, options?: any) {
|
||||
return UserApiFp(this.configuration).updateUser(username, user, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1079,7 +1079,6 @@ export class PetApi extends BaseAPI implements PetApiInterface {
|
||||
public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) {
|
||||
return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1453,7 +1452,6 @@ export class StoreApi extends BaseAPI implements StoreApiInterface {
|
||||
public placeOrder(body: Order, options?: any) {
|
||||
return StoreApiFp(this.configuration).placeOrder(body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2182,7 +2180,6 @@ export class UserApi extends BaseAPI implements UserApiInterface {
|
||||
public updateUser(username: string, body: User, options?: any) {
|
||||
return UserApiFp(this.configuration).updateUser(username, body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -762,5 +762,4 @@ export class PetApi extends BaseAPI {
|
||||
public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) {
|
||||
return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -343,5 +343,4 @@ export class StoreApi extends BaseAPI {
|
||||
public placeOrder(body: Order, options?: any) {
|
||||
return StoreApiFp(this.configuration).placeOrder(body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -656,5 +656,4 @@ export class UserApi extends BaseAPI {
|
||||
public updateUser(username: string, body: User, options?: any) {
|
||||
return UserApiFp(this.configuration).updateUser(username, body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -986,7 +986,6 @@ export class PetApi extends BaseAPI {
|
||||
public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any) {
|
||||
return PetApiFp(this.configuration).uploadFile(petId, additionalMetadata, file, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1313,7 +1312,6 @@ export class StoreApi extends BaseAPI {
|
||||
public placeOrder(body: Order, options?: any) {
|
||||
return StoreApiFp(this.configuration).placeOrder(body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1953,7 +1951,6 @@ export class UserApi extends BaseAPI {
|
||||
public updateUser(username: string, body: User, options?: any) {
|
||||
return UserApiFp(this.configuration).updateUser(username, body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
4
samples/client/petstore/typescript-axios/builds/with-single-request-parameters/.gitignore
vendored
Normal file
4
samples/client/petstore/typescript-axios/builds/with-single-request-parameters/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
||||
dist
|
||||
@@ -0,0 +1 @@
|
||||
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
|
||||
@@ -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 @@
|
||||
5.0.0-SNAPSHOT
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
import { Configuration } from "./configuration";
|
||||
// Some imports not used depending on template conditions
|
||||
// @ts-ignore
|
||||
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios';
|
||||
|
||||
export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, "");
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const COLLECTION_FORMATS = {
|
||||
csv: ",",
|
||||
ssv: " ",
|
||||
tsv: "\t",
|
||||
pipes: "|",
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface RequestArgs
|
||||
*/
|
||||
export interface RequestArgs {
|
||||
url: string;
|
||||
options: any;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @class BaseAPI
|
||||
*/
|
||||
export class BaseAPI {
|
||||
protected configuration: Configuration | undefined;
|
||||
|
||||
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
||||
if (configuration) {
|
||||
this.configuration = configuration;
|
||||
this.basePath = configuration.basePath || this.basePath;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @class RequiredError
|
||||
* @extends {Error}
|
||||
*/
|
||||
export class RequiredError extends Error {
|
||||
name: "RequiredError" = "RequiredError";
|
||||
constructor(public field: string, msg?: string) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | ((name?: string, scopes?: string[]) => string);
|
||||
basePath?: string;
|
||||
baseOptions?: any;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<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;
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.apiKey = param.apiKey;
|
||||
this.username = param.username;
|
||||
this.password = param.password;
|
||||
this.accessToken = param.accessToken;
|
||||
this.basePath = param.basePath;
|
||||
this.baseOptions = param.baseOptions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
||||
Reference in New Issue
Block a user