[typescript-nestjs] Upgrade to NestJS v8 (#12937)

* feat(typescript-nestjs): upgrade to nestjs v8

Set default nestVersion to 8.0.0

* chore(typescript-nestjs): create typescript-nestjs-v8-provided-in-root.yaml and add it to samples.json

* chore(typescript-nestjs): generate samples

* docs(typescript-nestjs): generate docs

* chore(typescript-nestjs): re-generate samples
This commit is contained in:
Paul Hagedorn 2022-07-21 13:41:32 +02:00 committed by GitHub
parent eeb1711f9f
commit 298ccfcfd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 1760 additions and 7 deletions

View File

@ -1226,6 +1226,12 @@
"Client: TypeScript"
]
},
{
"input": "typescript-nestjs-v8-petstore-provided-in-root.sh",
"matches": [
"Client: TypeScript"
]
},
{
"input": "typescript-node-petstore-with-npm.sh",
"matches": [

View File

@ -0,0 +1,10 @@
generatorName: typescript-nestjs
outputDir: samples/client/petstore/typescript-nestjs-v8-provided-in-root/builds/default
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/typescript-nestjs
additionalProperties:
nestVersion: 8.0.0
"npmName": "@openapitools/typescript-nestjs-petstore"
"npmVersion": "1.0.0"
"npmRepository" : "https://skimdb.npmjs.com/registry"
"snapshot" : false

View File

@ -11,7 +11,7 @@ title: Documentation for the typescript-nestjs Generator
| generator type | CLIENT | |
| generator language | Typescript | |
| generator default templating engine | mustache | |
| helpTxt | Generates a TypeScript Nestjs 6.x client library. | |
| helpTxt | Generates a TypeScript Nestjs 8.x or 6.x client library. | |
## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
@ -29,7 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|modelFileSuffix|The suffix of the file of the generated model (model<suffix>.ts).| |null|
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
|modelSuffix|The suffix of the generated model.| |null|
|nestVersion|The version of Nestjs.| |6.0.0|
|nestVersion|The version of Nestjs.|<dl><dt>**8.0.0**</dt><dd>Use new HttpModule and HttpService from @nestjs/axios.</dd><dt>**6.0.0**</dt><dd>Use old HttpModule and HttpService from @nestjs/common.</dd></dl>|8.0.0|
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|

View File

@ -53,7 +53,7 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
public static final String STRING_ENUMS = "stringEnums";
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
protected String nestVersion = "6.0.0";
protected String nestVersion = "8.0.0";
protected String npmRepository = null;
protected String serviceSuffix = "Service";
protected String serviceFileSuffix = ".service";
@ -91,7 +91,7 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
this.cliOptions.add(CliOption.newBoolean(TAGGED_UNIONS,
"Use discriminators to create tagged unions instead of extending interfaces.",
this.taggedUnions));
this.cliOptions.add(new CliOption(NEST_VERSION, "The version of Nestjs.").defaultValue(this.nestVersion));
this.cliOptions.add(new CliOption(NEST_VERSION, "The version of Nestjs.").addEnum("8.0.0","Use new HttpModule and HttpService from @nestjs/axios.").addEnum("6.0.0","Use old HttpModule and HttpService from @nestjs/common.").defaultValue(this.nestVersion));
this.cliOptions.add(new CliOption(SERVICE_SUFFIX, "The suffix of the generated service.").defaultValue(this.serviceSuffix));
this.cliOptions.add(new CliOption(SERVICE_FILE_SUFFIX, "The suffix of the file of the generated service (service<suffix>.ts).").defaultValue(this.serviceFileSuffix));
this.cliOptions.add(new CliOption(MODEL_SUFFIX, "The suffix of the generated model."));
@ -113,7 +113,7 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
@Override
public String getHelp() {
return "Generates a TypeScript Nestjs 6.x client library.";
return "Generates a TypeScript Nestjs 8.x or 6.x client library.";
}
@Override
@ -170,6 +170,7 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
additionalProperties.put("injectionToken", nestVersion.atLeast("4.0.0") ? "InjectionToken" : "OpaqueToken");
additionalProperties.put("injectionTokenTyped", nestVersion.atLeast("4.0.0"));
additionalProperties.put("useHttpClient", nestVersion.atLeast("4.3.0"));
additionalProperties.put("useAxiosHttpModule", nestVersion.atLeast("8.0.0"));
if (additionalProperties.containsKey(SERVICE_SUFFIX)) {
serviceSuffix = additionalProperties.get(SERVICE_SUFFIX).toString();
validateClassSuffixArgument("Service", serviceSuffix);

View File

@ -16,7 +16,7 @@ In your Nestjs project:
```
// without configuring providers
import { ApiModule } from '{{npmName}}';
import { HttpModule } from '@nestjs/common';
import { HttpModule } from '@nestjs/{{#useAxiosHttpModule}}axios{{/useAxiosHttpModule}}{{^useAxiosHttpModule}}common{{/useAxiosHttpModule}}';
@Module({
imports: [
@ -66,7 +66,7 @@ in order to avoid naming conflicts:
```
import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpModule } from '@nestjs/common';
import { HttpModule } from '@nestjs/{{#useAxiosHttpModule}}axios{{/useAxiosHttpModule}}{{^useAxiosHttpModule}}common{{/useAxiosHttpModule}}';
@Module({
imports: [

View File

@ -1,4 +1,10 @@
{{#useAxiosHttpModule}}
import { DynamicModule, Module, Global } from '@nestjs/common';
import { HttpModule, HttpService } from '@nestjs/axios';
{{/useAxiosHttpModule}}
{{^useAxiosHttpModule}}
import { DynamicModule, HttpService, HttpModule, Module, Global } from '@nestjs/common';
{{/useAxiosHttpModule}}
import { Configuration } from './configuration';
{{#apiInfo}}

View File

@ -1,7 +1,13 @@
{{>licenseInfo}}
/* tslint:disable:no-unused-variable member-ordering */
{{#useAxiosHttpModule}}
import { Inject, Injectable, Optional } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
{{/useAxiosHttpModule}}
{{^useAxiosHttpModule}}
import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
{{/useAxiosHttpModule}}
import { AxiosResponse } from 'axios';
import { Observable } from 'rxjs';
{{#imports}}

View File

@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist

View File

@ -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

View File

@ -0,0 +1,22 @@
.gitignore
README.md
api.module.ts
api/api.ts
api/pet.service.ts
api/store.service.ts
api/user.service.ts
configuration.ts
git_push.sh
index.ts
model/apiResponse.ts
model/category.ts
model/models.ts
model/order.ts
model/pet.ts
model/tag.ts
model/user.ts
package.json
tsconfig.build.json
tsconfig.json
tslint.json
variables.ts

View File

@ -0,0 +1,137 @@
## @openapitools/typescript-nestjs-petstore@1.0.0
### Building
To install the required dependencies and to build the typescript sources run:
```
npm install
npm run build
```
#### General usage
In your Nestjs project:
```
// without configuring providers
import { ApiModule } from '@openapitools/typescript-nestjs-petstore';
import { HttpModule } from '@nestjs/axios';
@Module({
imports: [
ApiModule,
HttpModule
],
providers: []
})
export class AppModule {}
```
```
// configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from '@openapitools/typescript-nestjs-petstore';
export function apiConfigFactory (): Configuration => {
const params: ConfigurationParameters = {
// set configuration parameters here.
}
return new Configuration(params);
}
@Module({
imports: [ ApiModule.forRoot(apiConfigFactory) ],
declarations: [ AppComponent ],
providers: [],
bootstrap: [ AppComponent ]
})
export class AppModule {}
```
```
import { DefaultApi } from '@openapitools/typescript-nestjs-petstore';
export class AppComponent {
constructor(private apiGateway: DefaultApi) { }
}
```
Note: The ApiModule a dynamic module and instantiated once app wide.
This is to ensure that all services are treated as singletons.
#### Using multiple swagger files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different swagger files,
you can create an alias name when importing the modules
in order to avoid naming conflicts:
```
import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpModule } from '@nestjs/axios';
@Module({
imports: [
ApiModule,
OtherApiModule,
HttpModule
]
})
export class AppModule {
}
```
### 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 '@openapitools/typescript-nestjs-petstore';
bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]);
```
or
```
import { BASE_PATH } from '@openapitools/typescript-nestjs-petstore';
@Module({
imports: [],
declarations: [ AppComponent ],
providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
bootstrap: [ AppComponent ]
})
export class AppModule {}
```
#### Using @nestjs/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path:
```
export const environment = {
production: false,
API_BASE_PATH: 'http://127.0.0.1:8080'
};
```
In the src/app/app.module.ts:
```
import { BASE_PATH } from '@openapitools/typescript-nestjs-petstore';
import { environment } from '../environments/environment';
@Module({
declarations: [
AppComponent
],
imports: [ ],
providers: [
{
provide: 'BASE_PATH',
useValue: environment.API_BASE_PATH
}
]
})
export class AppModule { }
```

View File

@ -0,0 +1,32 @@
import { DynamicModule, Module, Global } from '@nestjs/common';
import { HttpModule, HttpService } from '@nestjs/axios';
import { Configuration } from './configuration';
import { PetService } from './api/pet.service';
import { StoreService } from './api/store.service';
import { UserService } from './api/user.service';
@Global()
@Module({
imports: [ HttpModule ],
exports: [
PetService,
StoreService,
UserService
],
providers: [
PetService,
StoreService,
UserService
]
})
export class ApiModule {
public static forRoot(configurationFactory: () => Configuration): DynamicModule {
return {
module: ApiModule,
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
};
}
constructor( httpService: HttpService) { }
}

View File

@ -0,0 +1,7 @@
export * from './pet.service';
import { PetService } from './pet.service';
export * from './store.service';
import { StoreService } from './store.service';
export * from './user.service';
import { UserService } from './user.service';
export const APIS = [PetService, StoreService, UserService];

View File

@ -0,0 +1,475 @@
/**
* 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.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { AxiosResponse } from 'axios';
import { Observable } from 'rxjs';
import { ApiResponse } from '../model/apiResponse';
import { Pet } from '../model/pet';
import { Configuration } from '../configuration';
@Injectable()
export class PetService {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders: Record<string,string> = {};
public configuration = new Configuration();
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
this.configuration = configuration || this.configuration;
this.basePath = configuration?.basePath || this.basePath;
}
/**
* @param consumes string[] mime-types
* @return true: consumes contains 'multipart/form-data', false: otherwise
*/
private canConsumeForm(consumes: string[]): boolean {
const form = 'multipart/form-data';
return consumes.includes(form);
}
/**
* Add a new pet to the store
*
* @param pet Pet object that needs to be added to the store
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public addPet(pet: Pet, ): Observable<AxiosResponse<Pet>>;
public addPet(pet: Pet, ): Observable<any> {
if (pet === null || pet === undefined) {
throw new Error('Required parameter pet was null or undefined when calling addPet.');
}
let headers = this.defaultHeaders;
// authentication (petstore_auth) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headers['Authorization'] = 'Bearer ' + accessToken;
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
'application/json',
'application/xml'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected != undefined) {
headers['Content-Type'] = httpContentTypeSelected;
}
return this.httpClient.post<Pet>(`${this.basePath}/pet`,
pet,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Deletes a pet
*
* @param petId Pet id to delete
* @param apiKey
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public deletePet(petId: number, apiKey?: string, ): Observable<AxiosResponse<any>>;
public deletePet(petId: number, apiKey?: string, ): Observable<any> {
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling deletePet.');
}
let headers = this.defaultHeaders;
if (apiKey !== undefined && apiKey !== null) {
headers['api_key'] = String(apiKey);
}
// authentication (petstore_auth) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headers['Authorization'] = 'Bearer ' + accessToken;
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.delete<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, ): Observable<AxiosResponse<Array<Pet>>>;
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, ): Observable<any> {
if (status === null || status === undefined) {
throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.');
}
let queryParameters = {};
if (status) {
queryParameters['status'] = status.join(COLLECTION_FORMATS['csv']);
}
let headers = this.defaultHeaders;
// authentication (petstore_auth) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headers['Authorization'] = 'Bearer ' + accessToken;
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.get<Array<Pet>>(`${this.basePath}/pet/findByStatus`,
{
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public findPetsByTags(tags: Array<string>, ): Observable<AxiosResponse<Array<Pet>>>;
public findPetsByTags(tags: Array<string>, ): Observable<any> {
if (tags === null || tags === undefined) {
throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.');
}
let queryParameters = {};
if (tags) {
queryParameters['tags'] = tags.join(COLLECTION_FORMATS['csv']);
}
let headers = this.defaultHeaders;
// authentication (petstore_auth) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headers['Authorization'] = 'Bearer ' + accessToken;
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.get<Array<Pet>>(`${this.basePath}/pet/findByTags`,
{
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Find pet by ID
* Returns a single pet
* @param petId ID of pet to return
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getPetById(petId: number, ): Observable<AxiosResponse<Pet>>;
public getPetById(petId: number, ): Observable<any> {
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling getPetById.');
}
let headers = this.defaultHeaders;
// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.get<Pet>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Update an existing pet
*
* @param pet Pet object that needs to be added to the store
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public updatePet(pet: Pet, ): Observable<AxiosResponse<Pet>>;
public updatePet(pet: Pet, ): Observable<any> {
if (pet === null || pet === undefined) {
throw new Error('Required parameter pet was null or undefined when calling updatePet.');
}
let headers = this.defaultHeaders;
// authentication (petstore_auth) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headers['Authorization'] = 'Bearer ' + accessToken;
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
'application/json',
'application/xml'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected != undefined) {
headers['Content-Type'] = httpContentTypeSelected;
}
return this.httpClient.put<Pet>(`${this.basePath}/pet`,
pet,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Updates a pet in the store with form data
*
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet
* @param status Updated status of the pet
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public updatePetWithForm(petId: number, name?: string, status?: string, ): Observable<AxiosResponse<any>>;
public updatePetWithForm(petId: number, name?: string, status?: string, ): Observable<any> {
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.');
}
let headers = this.defaultHeaders;
// authentication (petstore_auth) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headers['Authorization'] = 'Bearer ' + accessToken;
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
'application/x-www-form-urlencoded'
];
const canConsumeForm = this.canConsumeForm(consumes);
let formParams: { append(param: string, value: any): void; };
let useForm = false;
let convertFormParamsToString = false;
if (useForm) {
formParams = new FormData();
} else {
// formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
}
if (name !== undefined) {
formParams.append('name', <any>name);
}
if (status !== undefined) {
formParams.append('status', <any>status);
}
return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
convertFormParamsToString ? formParams.toString() : formParams,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* uploads an image
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, ): Observable<AxiosResponse<ApiResponse>>;
public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, ): Observable<any> {
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling uploadFile.');
}
let headers = this.defaultHeaders;
// authentication (petstore_auth) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headers['Authorization'] = 'Bearer ' + accessToken;
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
'multipart/form-data'
];
const canConsumeForm = this.canConsumeForm(consumes);
let formParams: { append(param: string, value: any): void; };
let useForm = false;
let convertFormParamsToString = false;
// use FormData to transmit files using content-type "multipart/form-data"
// see https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data
useForm = canConsumeForm;
if (useForm) {
formParams = new FormData();
} else {
// formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
}
if (additionalMetadata !== undefined) {
formParams.append('additionalMetadata', <any>additionalMetadata);
}
if (file !== undefined) {
formParams.append('file', <any>file);
}
return this.httpClient.post<ApiResponse>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
convertFormParamsToString ? formParams.toString() : formParams,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
}

View File

@ -0,0 +1,190 @@
/**
* 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.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { AxiosResponse } from 'axios';
import { Observable } from 'rxjs';
import { Order } from '../model/order';
import { Configuration } from '../configuration';
@Injectable()
export class StoreService {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders: Record<string,string> = {};
public configuration = new Configuration();
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
this.configuration = configuration || this.configuration;
this.basePath = configuration?.basePath || this.basePath;
}
/**
* @param consumes string[] mime-types
* @return true: consumes contains 'multipart/form-data', false: otherwise
*/
private canConsumeForm(consumes: string[]): boolean {
const form = 'multipart/form-data';
return consumes.includes(form);
}
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public deleteOrder(orderId: string, ): Observable<AxiosResponse<any>>;
public deleteOrder(orderId: string, ): Observable<any> {
if (orderId === null || orderId === undefined) {
throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.');
}
let headers = this.defaultHeaders;
// to determine the Accept header
let httpHeaderAccepts: string[] = [
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.delete<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getInventory(): Observable<AxiosResponse<{ [key: string]: number; }>>;
public getInventory(): Observable<any> {
let headers = this.defaultHeaders;
// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.get<{ [key: string]: number; }>(`${this.basePath}/store/inventory`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getOrderById(orderId: number, ): Observable<AxiosResponse<Order>>;
public getOrderById(orderId: number, ): Observable<any> {
if (orderId === null || orderId === undefined) {
throw new Error('Required parameter orderId was null or undefined when calling getOrderById.');
}
let headers = this.defaultHeaders;
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.get<Order>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Place an order for a pet
*
* @param order order placed for purchasing the pet
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public placeOrder(order: Order, ): Observable<AxiosResponse<Order>>;
public placeOrder(order: Order, ): Observable<any> {
if (order === null || order === undefined) {
throw new Error('Required parameter order was null or undefined when calling placeOrder.');
}
let headers = this.defaultHeaders;
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected != undefined) {
headers['Content-Type'] = httpContentTypeSelected;
}
return this.httpClient.post<Order>(`${this.basePath}/store/order`,
order,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
}

View File

@ -0,0 +1,387 @@
/**
* 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.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { AxiosResponse } from 'axios';
import { Observable } from 'rxjs';
import { User } from '../model/user';
import { Configuration } from '../configuration';
@Injectable()
export class UserService {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders: Record<string,string> = {};
public configuration = new Configuration();
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
this.configuration = configuration || this.configuration;
this.basePath = configuration?.basePath || this.basePath;
}
/**
* @param consumes string[] mime-types
* @return true: consumes contains 'multipart/form-data', false: otherwise
*/
private canConsumeForm(consumes: string[]): boolean {
const form = 'multipart/form-data';
return consumes.includes(form);
}
/**
* Create user
* This can only be done by the logged in user.
* @param user Created user object
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public createUser(user: User, ): Observable<AxiosResponse<any>>;
public createUser(user: User, ): Observable<any> {
if (user === null || user === undefined) {
throw new Error('Required parameter user was null or undefined when calling createUser.');
}
let headers = this.defaultHeaders;
// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected != undefined) {
headers['Content-Type'] = httpContentTypeSelected;
}
return this.httpClient.post<any>(`${this.basePath}/user`,
user,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Creates list of users with given input array
*
* @param user List of user object
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public createUsersWithArrayInput(user: Array<User>, ): Observable<AxiosResponse<any>>;
public createUsersWithArrayInput(user: Array<User>, ): Observable<any> {
if (user === null || user === undefined) {
throw new Error('Required parameter user was null or undefined when calling createUsersWithArrayInput.');
}
let headers = this.defaultHeaders;
// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected != undefined) {
headers['Content-Type'] = httpContentTypeSelected;
}
return this.httpClient.post<any>(`${this.basePath}/user/createWithArray`,
user,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Creates list of users with given input array
*
* @param user List of user object
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public createUsersWithListInput(user: Array<User>, ): Observable<AxiosResponse<any>>;
public createUsersWithListInput(user: Array<User>, ): Observable<any> {
if (user === null || user === undefined) {
throw new Error('Required parameter user was null or undefined when calling createUsersWithListInput.');
}
let headers = this.defaultHeaders;
// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected != undefined) {
headers['Content-Type'] = httpContentTypeSelected;
}
return this.httpClient.post<any>(`${this.basePath}/user/createWithList`,
user,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Delete user
* This can only be done by the logged in user.
* @param username The name that needs to be deleted
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public deleteUser(username: string, ): Observable<AxiosResponse<any>>;
public deleteUser(username: string, ): Observable<any> {
if (username === null || username === undefined) {
throw new Error('Required parameter username was null or undefined when calling deleteUser.');
}
let headers = this.defaultHeaders;
// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.delete<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getUserByName(username: string, ): Observable<AxiosResponse<User>>;
public getUserByName(username: string, ): Observable<any> {
if (username === null || username === undefined) {
throw new Error('Required parameter username was null or undefined when calling getUserByName.');
}
let headers = this.defaultHeaders;
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.get<User>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Logs user into the system
*
* @param username The user name for login
* @param password The password for login in clear text
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public loginUser(username: string, password: string, ): Observable<AxiosResponse<string>>;
public loginUser(username: string, password: string, ): Observable<any> {
if (username === null || username === undefined) {
throw new Error('Required parameter username was null or undefined when calling loginUser.');
}
if (password === null || password === undefined) {
throw new Error('Required parameter password was null or undefined when calling loginUser.');
}
let queryParameters = {};
if (username !== undefined && username !== null) {
queryParameters['username'] = <any>username;
}
if (password !== undefined && password !== null) {
queryParameters['password'] = <any>password;
}
let headers = this.defaultHeaders;
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.get<string>(`${this.basePath}/user/login`,
{
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Logs out current logged in user session
*
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public logoutUser(): Observable<AxiosResponse<any>>;
public logoutUser(): Observable<any> {
let headers = this.defaultHeaders;
// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.get<any>(`${this.basePath}/user/logout`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted
* @param user Updated user object
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public updateUser(username: string, user: User, ): Observable<AxiosResponse<any>>;
public updateUser(username: string, user: User, ): Observable<any> {
if (username === null || username === undefined) {
throw new Error('Required parameter username was null or undefined when calling updateUser.');
}
if (user === null || user === undefined) {
throw new Error('Required parameter user was null or undefined when calling updateUser.');
}
let headers = this.defaultHeaders;
// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers['Accept'] = httpHeaderAcceptSelected;
}
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected != undefined) {
headers['Content-Type'] = httpContentTypeSelected;
}
return this.httpClient.put<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
user,
{
withCredentials: this.configuration.withCredentials,
headers: headers
}
);
}
}

View File

@ -0,0 +1,79 @@
export interface ConfigurationParameters {
apiKeys?: {[ key: string ]: string};
username?: string;
password?: string;
accessToken?: string | (() => string);
basePath?: string;
withCredentials?: boolean;
}
export class Configuration {
apiKeys?: {[ key: string ]: string};
username?: string;
password?: string;
accessToken?: string | (() => string);
basePath?: string;
withCredentials?: boolean;
constructor(configurationParameters: ConfigurationParameters = {}) {
this.apiKeys = configurationParameters.apiKeys;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;
this.basePath = configurationParameters.basePath;
this.withCredentials = configurationParameters.withCredentials;
}
/**
* Select the correct content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param contentTypes - the array of content types that are available for selection
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/
public selectHeaderContentType (contentTypes: string[]): string | undefined {
if (contentTypes.length == 0) {
return undefined;
}
let type = contentTypes.find(x => this.isJsonMime(x));
if (type === undefined) {
return contentTypes[0];
}
return type;
}
/**
* Select the correct accept content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param accepts - the array of content types that are available for selection.
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/
public selectHeaderAccept(accepts: string[]): string | undefined {
if (accepts.length == 0) {
return undefined;
}
let type = accepts.find(x => this.isJsonMime(x));
if (type === undefined) {
return accepts[0];
}
return type;
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
}

View File

@ -0,0 +1,57 @@
#!/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-petstore-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'

View File

@ -0,0 +1,5 @@
export * from './api/api';
export * from './model/models';
export * from './variables';
export * from './configuration';
export * from './api.module';

View File

@ -0,0 +1,22 @@
/**
* 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.
*/
/**
* Describes the result of uploading an image resource
*/
export interface ApiResponse {
code?: number;
type?: string;
message?: string;
}

View File

@ -0,0 +1,21 @@
/**
* 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.
*/
/**
* A category for a pet
*/
export interface Category {
id?: number;
name?: string;
}

View File

@ -0,0 +1,6 @@
export * from './apiResponse';
export * from './category';
export * from './order';
export * from './pet';
export * from './tag';
export * from './user';

View File

@ -0,0 +1,37 @@
/**
* 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.
*/
/**
* An order for a pets from the pet store
*/
export interface Order {
id?: number;
petId?: number;
quantity?: number;
shipDate?: string;
/**
* Order Status
*/
status?: Order.StatusEnum;
complete?: boolean;
}
export namespace Order {
export type StatusEnum = 'placed' | 'approved' | 'delivered';
export const StatusEnum = {
Placed: 'placed' as StatusEnum,
Approved: 'approved' as StatusEnum,
Delivered: 'delivered' as StatusEnum
};
}

View File

@ -0,0 +1,39 @@
/**
* 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 { Category } from './category';
import { Tag } from './tag';
/**
* A pet for sale in the pet store
*/
export interface Pet {
id?: number;
category?: Category;
name: string;
photoUrls: Array<string>;
tags?: Array<Tag>;
/**
* pet status in the store
*/
status?: Pet.StatusEnum;
}
export namespace Pet {
export type StatusEnum = 'available' | 'pending' | 'sold';
export const StatusEnum = {
Available: 'available' as StatusEnum,
Pending: 'pending' as StatusEnum,
Sold: 'sold' as StatusEnum
};
}

View File

@ -0,0 +1,21 @@
/**
* 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.
*/
/**
* A tag for a pet
*/
export interface Tag {
id?: number;
name?: string;
}

View File

@ -0,0 +1,30 @@
/**
* 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.
*/
/**
* A User who is purchasing from the pet store
*/
export interface User {
id?: number;
username?: string;
firstName?: string;
lastName?: string;
email?: string;
password?: string;
phone?: string;
/**
* User Status
*/
userStatus?: number;
}

View File

@ -0,0 +1,73 @@
{
"name": "@openapitools/typescript-nestjs-petstore",
"version": "1.0.0",
"description": "REST client for @openapitools/typescript-nestjs-petstore",
"author": "OpenAPI Generator Contributors",
"repository": {
"type": "git",
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
},
"keywords": [
"swagger-client"
],
"license": "Unlicense",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"build:clean": "rm -rf dist/ 2> /dev/null && tsc -p tsconfig.build.json",
"format": "prettier --write \"src/**/*.ts\"",
"start": "ts-node -r tsconfig-paths/register src/main.ts",
"start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ",
"start:debug": "nodemon --config nodemon-debug.json",
"prestart:prod": "rimraf dist && npm run build",
"start:prod": "node dist/main.js",
"lint": "tslint -p tsconfig.json -c tslint.json",
"lint:fix": "tslint -p tsconfig.json -c tslint.json --fix --force",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"@nestjs/platform-express": "^8.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^2.6.3",
"rxjs": "^6.5.2"
},
"devDependencies": {
"@nestjs/testing": "~8.0.0",
"@types/express": "^4.16.0",
"@types/jest": "^24.0.15",
"@types/node": "^12.6.1",
"@types/supertest": "^2.0.8",
"concurrently": "^4.1.1",
"nodemon": "^1.19.1",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "24.0.2",
"ts-node": "8.3.0",
"tsconfig-paths": "3.8.0",
"tslint": "5.18.0",
"typescript": "^4.0",
"wait-on": "^3.2.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"publishConfig": {
"registry": "https://skimdb.npmjs.com/registry"
}
}

View File

@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"exclude": [
"node_modules",
"test",
"dist",
"**/*spec.ts"
]
}

View File

@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true
},
"exclude": [
"node_modules",
"dist"
],
"filesGlob": [
"./model/*.ts",
"./api/*.ts"
]
}

View File

@ -0,0 +1,18 @@
{
"defaultSeverity": "error",
"extends": ["tslint:recommended"],
"jsRules": {
"no-unused-expression": true
},
"rules": {
"quotemark": [true, "single"],
"member-access": [false],
"ordered-imports": [false],
"max-line-length": [true, 150],
"member-ordering": [false],
"interface-name": [false],
"arrow-parens": false,
"object-literal-sort-keys": false
},
"rulesDirectory": []
}

View File

@ -0,0 +1,7 @@
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',
'ssv': ' ',
'pipes': '|'
}