Skip to content

Commit

Permalink
fix: update ts client
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse0Michael committed Jun 8, 2020
1 parent 8fd5897 commit 2d4f5c5
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- name: Semantic Release
uses: ridedott/release-me-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PAT }}
15 changes: 15 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.gitignore
api.ts
api/apis.ts
api/defaultApi.ts
model/./apiError.ts
model/./asset.ts
model/./assetFile.ts
model/./assetUpdate.ts
model/./assets.ts
model/./job.ts
model/./kind.ts
model/./version.ts
model/models.ts
package.json
tsconfig.json
7 changes: 1 addition & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
.PHONY: build test

gen:
docker run -v ${PWD}:/open-dam openapitools/openapi-generator-cli generate -i https://raw.githubusercontent.com/open-dam/open-dam-api/master/api/openapi.yaml?token=AAFBO7SEHL2EO2EHECKUEYC6YQDK4 -g typescript-node -o /open-dam/ --git-user-id open-dam --git-repo-id open-dam-api --additional-properties=npmName=@open-dam/open-dam-api,npmVersion=1.0.0

gen-docs:
# Requrires [Redoc](https://github.com/Redocly/redoc)
# `npm install redoc-cli -g --save`
redoc-cli bundle api/openapi.yaml -o docs/index.html --options.disableSearch --options.hideDownloadButton
docker run -v ${PWD}:/open-dam openapitools/openapi-generator-cli generate -i https://raw.githubusercontent.com/open-dam/open-dam-api/master/api/openapi.yaml -g typescript-node -o /open-dam/ --git-user-id open-dam --git-repo-id open-dam-api --additional-properties=npmName=@open-dam/open-dam-api,npmVersion=1.0.0

build:
npm install
Expand Down
20 changes: 14 additions & 6 deletions api/defaultApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import http = require('http');
/* tslint:disable:no-unused-locals */
import { ApiError } from '../model/apiError';
import { Asset } from '../model/asset';
import { AssetUpdate } from '../model/assetUpdate';
import { Assets } from '../model/assets';
import { Job } from '../model/job';

Expand Down Expand Up @@ -93,7 +94,7 @@ export class DefaultApi {
* @param assetId
*/
public async deleteAsset (assetId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Job; }> {
const localVarPath = this.basePath + '/asset/{asset_id}'
const localVarPath = this.basePath + '/assets/{asset_id}'
.replace('{' + 'asset_id' + '}', encodeURIComponent(String(assetId)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
Expand Down Expand Up @@ -161,7 +162,7 @@ export class DefaultApi {
* @param assetId
*/
public async getAsset (assetId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Asset; }> {
const localVarPath = this.basePath + '/asset/{asset_id}'
const localVarPath = this.basePath + '/assets/{asset_id}'
.replace('{' + 'asset_id' + '}', encodeURIComponent(String(assetId)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
Expand Down Expand Up @@ -245,7 +246,7 @@ export class DefaultApi {
let localVarUseFormData = false;

let localVarRequestOptions: localVarRequest.Options = {
method: 'POST',
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
Expand Down Expand Up @@ -357,7 +358,7 @@ export class DefaultApi {
*
*/
public async postAsset (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Job; }> {
const localVarPath = this.basePath + '/asset';
const localVarPath = this.basePath + '/assets';
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
const produces = ['application/json'];
Expand Down Expand Up @@ -417,9 +418,10 @@ export class DefaultApi {
/**
*
* @param assetId
* @param assetUpdate
*/
public async putAsset (assetId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Job; }> {
const localVarPath = this.basePath + '/asset/{asset_id}'
public async putAsset (assetId: string, assetUpdate: AssetUpdate, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Job; }> {
const localVarPath = this.basePath + '/assets/{asset_id}'
.replace('{' + 'asset_id' + '}', encodeURIComponent(String(assetId)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
Expand All @@ -437,6 +439,11 @@ export class DefaultApi {
throw new Error('Required parameter assetId was null or undefined when calling putAsset.');
}

// verify required parameter 'assetUpdate' is not null or undefined
if (assetUpdate === null || assetUpdate === undefined) {
throw new Error('Required parameter assetUpdate was null or undefined when calling putAsset.');
}

(<any>Object).assign(localVarHeaderParams, options.headers);

let localVarUseFormData = false;
Expand All @@ -448,6 +455,7 @@ export class DefaultApi {
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: ObjectSerializer.serialize(assetUpdate, "AssetUpdate")
};

let authenticationPromise = Promise.resolve();
Expand Down
16 changes: 3 additions & 13 deletions model/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import { RequestFile } from '../api';
import { AssetFile } from './assetFile';
import { Kind } from './kind';
import { Version } from './version';

/**
Expand All @@ -22,10 +23,7 @@ export class Asset {
* The unique id of the asset
*/
'assetId': string;
/**
* The kind of media
*/
'kind': Asset.KindEnum;
'kind': Kind;
'version': Version;
'file': AssetFile;
/**
Expand All @@ -52,7 +50,7 @@ export class Asset {
{
"name": "kind",
"baseName": "kind",
"type": "Asset.KindEnum"
"type": "Kind"
},
{
"name": "version",
Expand Down Expand Up @@ -85,11 +83,3 @@ export class Asset {
}
}

export namespace Asset {
export enum KindEnum {
Image = <any> 'image',
Video = <any> 'video',
Audio = <any> 'audio',
Text = <any> 'text'
}
}
70 changes: 70 additions & 0 deletions model/assetUpdate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Open DAM API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.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 { RequestFile } from '../api';
import { Asset } from './asset';
import { AssetFile } from './assetFile';
import { Kind } from './kind';

/**
* A limited view of an asset with only editable fields. Formats, tags, and metadata are merged with any existing values
*/
export class AssetUpdate {
'kind'?: Kind;
'file'?: AssetFile;
/**
* additional assets/files associated with the asset
*/
'formats'?: Array<Asset>;
/**
* A list of metadata tags associated with the asset
*/
'tags'?: Array<string>;
/**
* Any user supplied metadata for the asset
*/
'metadata'?: { [key: string]: object; };

static discriminator: string | undefined = undefined;

static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "kind",
"baseName": "kind",
"type": "Kind"
},
{
"name": "file",
"baseName": "file",
"type": "AssetFile"
},
{
"name": "formats",
"baseName": "formats",
"type": "Array<Asset>"
},
{
"name": "tags",
"baseName": "tags",
"type": "Array<string>"
},
{
"name": "metadata",
"baseName": "metadata",
"type": "{ [key: string]: object; }"
} ];

static getAttributeTypeMap() {
return AssetUpdate.attributeTypeMap;
}
}

23 changes: 23 additions & 0 deletions model/kind.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Open DAM API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.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 { RequestFile } from '../api';

/**
* The kind of media
*/
export enum Kind {
Image = <any> 'image',
Video = <any> 'video',
Audio = <any> 'audio',
Text = <any> 'text'
}
7 changes: 6 additions & 1 deletion model/models.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
export * from './apiError';
export * from './asset';
export * from './assetFile';
export * from './assetUpdate';
export * from './assets';
export * from './job';
export * from './kind';
export * from './version';

import localVarRequest = require('request');

import { ApiError } from './apiError';
import { Asset } from './asset';
import { AssetFile } from './assetFile';
import { AssetUpdate } from './assetUpdate';
import { Assets } from './assets';
import { Job } from './job';
import { Kind } from './kind';
import { Version } from './version';

/* tslint:disable:no-unused-variable */
Expand All @@ -27,14 +31,15 @@ let primitives = [
];

let enumsMap: {[index: string]: any} = {
"Asset.KindEnum": Asset.KindEnum,
"Job.StateEnum": Job.StateEnum,
"Kind": Kind,
}

let typeMap: {[index: string]: any} = {
"ApiError": ApiError,
"Asset": Asset,
"AssetFile": AssetFile,
"AssetUpdate": AssetUpdate,
"Assets": Assets,
"Job": Job,
"Version": Version,
Expand Down

0 comments on commit 2d4f5c5

Please sign in to comment.