diff --git a/README.md b/README.md index 33f6fd5..8396818 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ const client = new RemotePinningServiceClient(config) // Get 10 failed Pins const pinsGetOptions: PinsGetRequest = { limit: 10, - status: new Set([Status.Failed]) // requires a set, and not an array + status: [Status.Failed] } const {count, results}: PinResults = await client.pinsGet(pinsGetOptions) @@ -53,6 +53,8 @@ npm run build To update the client, you need to `npm run gen` npm script. This will fetch the latest version of the OpenAPI spec and generate the client. However, openapi-generator-cli does not currently generate the client code with proper import syntax. So you must modify the imports in `generated/fetch/**` directly, or just `git checkout -p` to remove the invalid import path changes. +It also uses `Set`s for all collection types though it cannot serialize or deserialize these types to/from JSON. They must be manually changed to be `Array`s. + If you need to modify the generated code's import paths, you will have to run `npm run postgen` manually. ### Contributing diff --git a/generated/fetch/src/apis/PinsApi.ts b/generated/fetch/src/apis/PinsApi.ts index ca6e981..f8e8459 100644 --- a/generated/fetch/src/apis/PinsApi.ts +++ b/generated/fetch/src/apis/PinsApi.ts @@ -36,10 +36,10 @@ import { } from '../models/index.js'; export interface PinsGetRequest { - cid?: Set; + cid?: Array; name?: string; match?: TextMatchingStrategy; - status?: Set; + status?: Array; before?: Date; after?: Date; limit?: number; @@ -73,10 +73,10 @@ export interface PinsApiInterface { /** * List all the pin objects, matching optional filters; when no filter is provided, only successful pins are returned * @summary List pin objects - * @param {Set} [cid] Return pin objects responsible for pinning the specified CID(s); be aware that using longer hash functions introduces further constraints on the number of CIDs that will fit under the limit of 2000 characters per URL in browser contexts + * @param {Array} [cid] Return pin objects responsible for pinning the specified CID(s); be aware that using longer hash functions introduces further constraints on the number of CIDs that will fit under the limit of 2000 characters per URL in browser contexts * @param {string} [name] Return pin objects with specified name (by default a case-sensitive, exact match) * @param {TextMatchingStrategy} [match] Customize the text matching strategy applied when name filter is present - * @param {Set} [status] Return pin objects for pins with the specified status + * @param {Array} [status] Return pin objects for pins with the specified status * @param {Date} [before] Return results created (queued) before provided timestamp * @param {Date} [after] Return results created (queued) after provided timestamp * @param {number} [limit] Max records to return @@ -173,7 +173,7 @@ export class PinsApi extends runtime.BaseAPI implements PinsApiInterface { const queryParameters: any = {}; if (requestParameters.cid) { - queryParameters['cid'] = Array.from(requestParameters.cid).join(runtime.COLLECTION_FORMATS["csv"]); + queryParameters['cid'] = requestParameters.cid.join(runtime.COLLECTION_FORMATS["csv"]); } if (requestParameters.name !== undefined) { @@ -185,7 +185,7 @@ export class PinsApi extends runtime.BaseAPI implements PinsApiInterface { } if (requestParameters.status) { - queryParameters['status'] = Array.from(requestParameters.status).join(runtime.COLLECTION_FORMATS["csv"]); + queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); } if (requestParameters.before !== undefined) { diff --git a/generated/fetch/src/models/Pin.ts b/generated/fetch/src/models/Pin.ts index bcaec15..24184cb 100644 --- a/generated/fetch/src/models/Pin.ts +++ b/generated/fetch/src/models/Pin.ts @@ -33,10 +33,10 @@ export interface Pin { name?: string; /** * Optional list of multiaddrs known to provide the data - * @type {Set} + * @type {Array} * @memberof Pin */ - origins?: Set; + origins?: Array; /** * Optional metadata for pin object * @type {{ [key: string]: string; }} diff --git a/generated/fetch/src/models/PinResults.ts b/generated/fetch/src/models/PinResults.ts index a948695..2f3826b 100644 --- a/generated/fetch/src/models/PinResults.ts +++ b/generated/fetch/src/models/PinResults.ts @@ -34,10 +34,10 @@ export interface PinResults { count: number; /** * An array of PinStatus results - * @type {Set} + * @type {Array} * @memberof PinResults */ - results: Set; + results: Array; } export function PinResultsFromJSON(json: any): PinResults { @@ -51,7 +51,7 @@ export function PinResultsFromJSONTyped(json: any, ignoreDiscriminator: boolean) return { 'count': json['count'], - 'results': (new Set((json['results'] as Array).map(PinStatusFromJSON))), + 'results': ((json['results'] as Array).map(PinStatusFromJSON)), }; } @@ -65,7 +65,7 @@ export function PinResultsToJSON(value?: PinResults | null): any { return { 'count': value.count, - 'results': (Array.from(value.results as Set).map(PinStatusToJSON)), + 'results': ((value.results as Array).map(PinStatusToJSON)), }; } diff --git a/generated/fetch/src/models/PinStatus.ts b/generated/fetch/src/models/PinStatus.ts index 4609939..841f9a0 100644 --- a/generated/fetch/src/models/PinStatus.ts +++ b/generated/fetch/src/models/PinStatus.ts @@ -58,10 +58,10 @@ export interface PinStatus { pin: Pin; /** * List of multiaddrs designated by pinning service for transferring any new data from external peers - * @type {Set} + * @type {Array} * @memberof PinStatus */ - delegates: Set; + delegates: Array; /** * Optional info for PinStatus response * @type {{ [key: string]: string; }} diff --git a/test/client.spec.ts b/test/client.spec.ts index 28149f4..3352464 100644 --- a/test/client.spec.ts +++ b/test/client.spec.ts @@ -38,8 +38,8 @@ describe('Client', () => { it('GET: Can get failed Pins', async () => { const Client = new RemotePinningServiceClient(Config) - const response = await Client.pinsGet({ limit: 1, status: new Set([Status.Failed]) }) - expect(response).to.deep.eq({ count: 0, results: new Set() }) + const response = await Client.pinsGet({ limit: 1, status: [Status.Failed] }) + expect(response).to.deep.eq({ count: 0, results: [] }) }) it('GET: Can add a Pin successfully', async () => {