From 2d4f5c5fb5f52ee7216641be36d93fd918b34508 Mon Sep 17 00:00:00 2001 From: Jesse Michael Date: Mon, 8 Jun 2020 11:57:07 -0700 Subject: [PATCH] fix: update ts client --- .github/workflows/tag.yaml | 2 +- .openapi-generator/FILES | 15 ++++++++ Makefile | 7 +--- api/defaultApi.ts | 20 +++++++---- model/asset.ts | 16 ++------- model/assetUpdate.ts | 70 ++++++++++++++++++++++++++++++++++++++ model/kind.ts | 23 +++++++++++++ model/models.ts | 7 +++- 8 files changed, 133 insertions(+), 27 deletions(-) create mode 100644 .openapi-generator/FILES create mode 100644 model/assetUpdate.ts create mode 100644 model/kind.ts diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index 2c0a830..f08e550 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -15,4 +15,4 @@ jobs: - name: Semantic Release uses: ridedott/release-me-action@master env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.PAT }} diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES new file mode 100644 index 0000000..68b171d --- /dev/null +++ b/.openapi-generator/FILES @@ -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 diff --git a/Makefile b/Makefile index 6cf0688..56039a4 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/api/defaultApi.ts b/api/defaultApi.ts index 8a42829..6d3dfb6 100644 --- a/api/defaultApi.ts +++ b/api/defaultApi.ts @@ -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'; @@ -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 = (Object).assign({}, this._defaultHeaders); @@ -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 = (Object).assign({}, this._defaultHeaders); @@ -245,7 +246,7 @@ export class DefaultApi { let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', + method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, @@ -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 = (Object).assign({}, this._defaultHeaders); const produces = ['application/json']; @@ -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 = (Object).assign({}, this._defaultHeaders); @@ -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.'); + } + (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; @@ -448,6 +455,7 @@ export class DefaultApi { uri: localVarPath, useQuerystring: this._useQuerystring, json: true, + body: ObjectSerializer.serialize(assetUpdate, "AssetUpdate") }; let authenticationPromise = Promise.resolve(); diff --git a/model/asset.ts b/model/asset.ts index e9ddc70..29afcf2 100644 --- a/model/asset.ts +++ b/model/asset.ts @@ -12,6 +12,7 @@ import { RequestFile } from '../api'; import { AssetFile } from './assetFile'; +import { Kind } from './kind'; import { Version } from './version'; /** @@ -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; /** @@ -52,7 +50,7 @@ export class Asset { { "name": "kind", "baseName": "kind", - "type": "Asset.KindEnum" + "type": "Kind" }, { "name": "version", @@ -85,11 +83,3 @@ export class Asset { } } -export namespace Asset { - export enum KindEnum { - Image = 'image', - Video = 'video', - Audio = 'audio', - Text = 'text' - } -} diff --git a/model/assetUpdate.ts b/model/assetUpdate.ts new file mode 100644 index 0000000..7b231fd --- /dev/null +++ b/model/assetUpdate.ts @@ -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; + /** + * A list of metadata tags associated with the asset + */ + 'tags'?: Array; + /** + * 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" + }, + { + "name": "tags", + "baseName": "tags", + "type": "Array" + }, + { + "name": "metadata", + "baseName": "metadata", + "type": "{ [key: string]: object; }" + } ]; + + static getAttributeTypeMap() { + return AssetUpdate.attributeTypeMap; + } +} + diff --git a/model/kind.ts b/model/kind.ts new file mode 100644 index 0000000..2ce0a45 --- /dev/null +++ b/model/kind.ts @@ -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 = 'image', + Video = 'video', + Audio = 'audio', + Text = 'text' +} diff --git a/model/models.ts b/model/models.ts index 6503cde..ca71565 100644 --- a/model/models.ts +++ b/model/models.ts @@ -1,8 +1,10 @@ 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'); @@ -10,8 +12,10 @@ 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 */ @@ -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,